InstitutionHelperTests.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const { expect } = require('chai')
  2. const path = require('path')
  3. const InstitutionsHelper = require(path.join(
  4. __dirname,
  5. '/../../../../app/src/Features/Institutions/InstitutionsHelper'
  6. ))
  7. describe('InstitutionsHelper', function () {
  8. describe('emailHasLicence', function () {
  9. it('returns licence', function () {
  10. const emailHasLicence = InstitutionsHelper.emailHasLicence({
  11. confirmedAt: new Date(),
  12. affiliation: {
  13. institution: { confirmed: true },
  14. licence: 'pro_plus',
  15. },
  16. })
  17. expect(emailHasLicence).to.be.true
  18. })
  19. it('returns false if licence is free', function () {
  20. const emailHasLicence = InstitutionsHelper.emailHasLicence({
  21. confirmedAt: new Date(),
  22. affiliation: {
  23. institution: { confirmed: true },
  24. licence: 'free',
  25. },
  26. })
  27. expect(emailHasLicence).to.be.false
  28. })
  29. it('returns false if licence is null', function () {
  30. const emailHasLicence = InstitutionsHelper.emailHasLicence({
  31. confirmedAt: new Date(),
  32. affiliation: {
  33. institution: { confirmed: true },
  34. licence: null,
  35. },
  36. })
  37. expect(emailHasLicence).to.be.false
  38. })
  39. it('returns false if institution is not confirmed', function () {
  40. const emailHasLicence = InstitutionsHelper.emailHasLicence({
  41. confirmedAt: new Date(),
  42. affiliation: {
  43. institution: { confirmed: false },
  44. licence: 'pro_plus',
  45. },
  46. })
  47. expect(emailHasLicence).to.be.false
  48. })
  49. it('returns false if email is not confirmed', function () {
  50. const emailHasLicence = InstitutionsHelper.emailHasLicence({
  51. confirmedAt: null,
  52. affiliation: {
  53. institution: { confirmed: true },
  54. licence: 'pro_plus',
  55. },
  56. })
  57. expect(emailHasLicence).to.be.false
  58. })
  59. })
  60. })