Home Manual Reference Source Test Repository

test/unit/filter/metadata.spec.js

  1. import assert from 'assert';
  2.  
  3. import metadata from '../../../lib/filter/metadata';
  4.  
  5. describe('filter/metadata metadata', () => {
  6. it('should return true when a match is found', () => {
  7. assert.equal(
  8. metadata(
  9. {
  10. data: {
  11. draft: true,
  12. title: 'test',
  13. },
  14. },
  15. {
  16. draft: true,
  17. }
  18. ),
  19. true
  20. );
  21.  
  22. assert.equal(
  23. metadata(
  24. {
  25. data: {
  26. draft: true,
  27. title: 'test',
  28. },
  29. },
  30. {
  31. draft: true,
  32. title: 'test',
  33. }
  34. ),
  35. true
  36. );
  37.  
  38. assert.equal(
  39. metadata(
  40. {
  41. data: {
  42. draft: true,
  43. title: 'test',
  44. date: 'ok',
  45. },
  46. },
  47. {
  48. draft: true,
  49. title: 'test',
  50. }
  51. ),
  52. true
  53. );
  54. });
  55.  
  56. it('should return false when a match is not found', () => {
  57. assert.equal(
  58. metadata(
  59. {
  60. data: {
  61. draft: false,
  62. title: 'test',
  63. },
  64. },
  65. {
  66. draft: true,
  67. }
  68. ),
  69. false
  70. );
  71.  
  72. assert.equal(
  73. metadata(
  74. {
  75. data: {
  76. draft: true,
  77. },
  78. },
  79. {
  80. draft: true,
  81. title: 'test',
  82. }
  83. ),
  84. false
  85. );
  86.  
  87. assert.equal(
  88. metadata(
  89. {
  90. data: {
  91. draft: true,
  92. title: 'surprise',
  93. },
  94. },
  95. {
  96. draft: true,
  97. title: 'test',
  98. }
  99. ),
  100. false
  101. );
  102.  
  103. assert.equal(
  104. metadata(
  105. {
  106. data: {
  107. draft: true,
  108. title: 'surprise',
  109. date: 'ok',
  110. },
  111. },
  112. {
  113. draft: true,
  114. title: 'test',
  115. }
  116. ),
  117. false
  118. );
  119. });
  120. });