InstitutionHelperTests.js 1.9 KB

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