table.test.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import { AvailableNow } from './index';
  2. const critters = [
  3. {
  4. "name": "bitterling",
  5. "time": [
  6. [ 0, 24 ]
  7. ],
  8. "months": [ 1, 2, 3, 11, 12 ]
  9. },
  10. {
  11. "name": "pale chub",
  12. "time": [
  13. [ 9, 16 ]
  14. ],
  15. "months": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]
  16. },
  17. {
  18. "name": "dace",
  19. "time": [
  20. [ 16, 9 ]
  21. ],
  22. "months": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]
  23. },
  24. {
  25. "name": "snapping turtle",
  26. "time": [
  27. [ 21, 4 ]
  28. ],
  29. "months": [ 4, 5, 6, 7, 8, 9, 10 ]
  30. },
  31. {
  32. "name": "piranha",
  33. "time": [
  34. [ 9, 16 ],
  35. [ 21, 4 ]
  36. ],
  37. "months": [ 6, 7, 8, 9 ]
  38. },
  39. {
  40. "name": "dorado",
  41. "time": [
  42. [ 4, 21 ]
  43. ],
  44. "months": [ 6, 7, 8, 9 ]
  45. }
  46. ]
  47. describe('AvailableNow:', () => {
  48. test('pale chub available on 05/05 @ 11:30hs', () => {
  49. const date = new Date("2020-05-05 11:30")
  50. expect(AvailableNow(critters, date)).toEqual(
  51. expect.arrayContaining([
  52. expect.objectContaining({name: 'pale chub'})
  53. ])
  54. )
  55. });
  56. test('bitterling available on 09/02 @ 15:30hs', () => {
  57. const date = new Date("2020-02-09 15:30")
  58. expect(AvailableNow(critters, date)).toEqual(
  59. expect.arrayContaining([
  60. expect.objectContaining({name: 'bitterling'})
  61. ])
  62. )
  63. })
  64. test('snapping turtle available on 10/09 @ 22:45hs', () => {
  65. const date = new Date("2020-09-10 22:45")
  66. expect(AvailableNow(critters, date)).toEqual(
  67. expect.arrayContaining([
  68. expect.objectContaining({name: 'snapping turtle'})
  69. ])
  70. )
  71. })
  72. test('dace available on 10/09 @ 7:15hs', () => {
  73. const date = new Date("2020-09-10 7:15")
  74. expect(AvailableNow(critters, date)).toEqual(
  75. expect.arrayContaining([
  76. expect.objectContaining({name: 'dace'})
  77. ])
  78. )
  79. })
  80. test('piranha available on 20/06 @ 13:00hs and 03:52hs', () => {
  81. const date1 = new Date("2020-06-20 13:00")
  82. expect(AvailableNow(critters, date1)).toEqual(
  83. expect.arrayContaining([
  84. expect.objectContaining({name: 'piranha'})
  85. ])
  86. )
  87. const date2 = new Date("2020-06-20 @ 03:52")
  88. expect(AvailableNow(critters, date2)).toEqual(
  89. expect.arrayContaining([
  90. expect.objectContaining({name: 'piranha'})
  91. ])
  92. )
  93. })
  94. test('dorado available on 17/7 @ 20hs but not on april', () => {
  95. const date = new Date("2020-07-17 20:00")
  96. expect(AvailableNow(critters, date)).toEqual(
  97. expect.arrayContaining([
  98. expect.objectContaining({name: 'dorado'})
  99. ])
  100. )
  101. const date2 = new Date("2020-03-17 20:00")
  102. expect(AvailableNow(critters, date)).toEqual(
  103. expect.arrayContaining([
  104. expect.objectContaining({name: 'dorado'})
  105. ])
  106. )
  107. })
  108. })