receiver.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. describe('ReceiverService', function () {
  2. let $service;
  3. // Ignoring page reload request
  4. beforeAll(() => window.onbeforeunload = () => null);
  5. beforeEach(function () {
  6. module('3ema.services');
  7. // Inject the service
  8. inject(function (ReceiverService) {
  9. $service = ReceiverService;
  10. });
  11. });
  12. describe('Receiver', () => {
  13. it('is not blocked', () => {
  14. expect($service.isBlocked({
  15. id: 'FOOOOBAR',
  16. type: 'contact',
  17. isBlocked: false
  18. })).toEqual(false);
  19. });
  20. it('is blocked', () => {
  21. expect($service.isBlocked({
  22. id: 'FOOOOBAR',
  23. type: 'contact',
  24. isBlocked: true
  25. })).toEqual(true);
  26. });
  27. });
  28. describe('Invalid receiver', () => {
  29. it('group is not blocked', () => {
  30. expect($service.isBlocked({
  31. id: 'FOOOOBAR',
  32. type: 'group',
  33. isBlocked: false
  34. })).toEqual(false);
  35. });
  36. it('invalidType is not blocked', () => {
  37. expect($service.isBlocked({
  38. id: 'FOOOOBAR',
  39. type: 'invalidType',
  40. isBlocked: true
  41. })).toEqual(false);
  42. });
  43. });
  44. describe('Receiver without isBlocked flag', () => {
  45. it('is not blocked', () => {
  46. expect($service.isBlocked({
  47. id: 'FOOOOBAR',
  48. type: 'contact'
  49. })).toEqual(false);
  50. });
  51. it('and invalid type is blocked', () => {
  52. expect($service.isBlocked({
  53. id: 'FOOOOBAR',
  54. type: 'invalidType'
  55. })).toEqual(false);
  56. });
  57. });
  58. describe('Undefined receiver', () => {
  59. it('is not blocked', () => {
  60. expect($service.isBlocked(undefined)).toEqual(false);
  61. });
  62. });
  63. });