| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- import { AvailableNow } from './index';
- const critters = [
- {
- "name": "bitterling",
- "time": [
- [ 0, 24 ]
- ],
- "months": [ 1, 2, 3, 11, 12 ]
- },
- {
- "name": "pale chub",
- "time": [
- [ 9, 16 ]
- ],
- "months": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]
- },
- {
- "name": "dace",
- "time": [
- [ 16, 9 ]
- ],
- "months": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]
- },
- {
- "name": "snapping turtle",
- "time": [
- [ 21, 4 ]
- ],
- "months": [ 4, 5, 6, 7, 8, 9, 10 ]
- },
- {
- "name": "piranha",
- "time": [
- [ 9, 16 ],
- [ 21, 4 ]
- ],
- "months": [ 6, 7, 8, 9 ]
- },
- {
- "name": "dorado",
- "time": [
- [ 4, 21 ]
- ],
- "months": [ 6, 7, 8, 9 ]
- }
- ]
- describe('AvailableNow:', () => {
- test('pale chub available on 05/05 @ 11:30hs', () => {
- const date = new Date("2020-05-05 11:30")
- expect(AvailableNow(critters, date)).toEqual(
- expect.arrayContaining([
- expect.objectContaining({name: 'pale chub'})
- ])
- )
- });
- test('bitterling available on 09/02 @ 15:30hs', () => {
- const date = new Date("2020-02-09 15:30")
- expect(AvailableNow(critters, date)).toEqual(
- expect.arrayContaining([
- expect.objectContaining({name: 'bitterling'})
- ])
- )
- })
- test('snapping turtle available on 10/09 @ 22:45hs', () => {
- const date = new Date("2020-09-10 22:45")
- expect(AvailableNow(critters, date)).toEqual(
- expect.arrayContaining([
- expect.objectContaining({name: 'snapping turtle'})
- ])
- )
- })
- test('dace available on 10/09 @ 7:15hs', () => {
- const date = new Date("2020-09-10 7:15")
- expect(AvailableNow(critters, date)).toEqual(
- expect.arrayContaining([
- expect.objectContaining({name: 'dace'})
- ])
- )
- })
- test('piranha available on 20/06 @ 13:00hs and 03:52hs', () => {
- const date1 = new Date("2020-06-20 13:00")
- expect(AvailableNow(critters, date1)).toEqual(
- expect.arrayContaining([
- expect.objectContaining({name: 'piranha'})
- ])
- )
-
- const date2 = new Date("2020-06-20 @ 03:52")
- expect(AvailableNow(critters, date2)).toEqual(
- expect.arrayContaining([
- expect.objectContaining({name: 'piranha'})
- ])
- )
- })
- test('dorado available on 17/7 @ 20hs but not on april', () => {
- const date = new Date("2020-07-17 20:00")
- expect(AvailableNow(critters, date)).toEqual(
- expect.arrayContaining([
- expect.objectContaining({name: 'dorado'})
- ])
- )
- const date2 = new Date("2020-03-17 20:00")
- expect(AvailableNow(critters, date)).toEqual(
- expect.arrayContaining([
- expect.objectContaining({name: 'dorado'})
- ])
- )
- })
- })
|