|
| 1 | +import content from '../../website/common/script/content'; |
| 2 | + |
| 3 | +describe('content index', () => { |
| 4 | + let clock; |
| 5 | + |
| 6 | + afterEach(() => { |
| 7 | + if (clock) { |
| 8 | + clock.restore(); |
| 9 | + } |
| 10 | + }); |
| 11 | + |
| 12 | + it('Releases eggs when appropriate without needing restarting', () => { |
| 13 | + clock = sinon.useFakeTimers(new Date('2024-06-20')); |
| 14 | + const mayEggs = content.eggs; |
| 15 | + expect(mayEggs.Chameleon).to.not.exist; |
| 16 | + clock.restore(); |
| 17 | + clock = sinon.useFakeTimers(new Date('2024-07-20')); |
| 18 | + const juneEggs = content.eggs; |
| 19 | + expect(juneEggs.Chameleon).to.exist; |
| 20 | + expect(Object.keys(mayEggs).length, '').to.equal(Object.keys(juneEggs).length - 1); |
| 21 | + }); |
| 22 | + |
| 23 | + it('Releases hatching potions when appropriate without needing restarting', () => { |
| 24 | + clock = sinon.useFakeTimers(new Date('2024-05-20')); |
| 25 | + const mayHatchingPotions = content.hatchingPotions; |
| 26 | + expect(mayHatchingPotions.Koi).to.not.exist; |
| 27 | + clock.restore(); |
| 28 | + clock = sinon.useFakeTimers(new Date('2024-06-20')); |
| 29 | + const juneHatchingPotions = content.hatchingPotions; |
| 30 | + expect(juneHatchingPotions.Koi).to.exist; |
| 31 | + expect(Object.keys(mayHatchingPotions).length, '').to.equal(Object.keys(juneHatchingPotions).length - 1); |
| 32 | + }); |
| 33 | + |
| 34 | + it('Releases armoire gear when appropriate without needing restarting', () => { |
| 35 | + clock = sinon.useFakeTimers(new Date('2024-06-20')); |
| 36 | + const juneGear = content.gear.flat; |
| 37 | + expect(juneGear.armor_armoire_corsairsCoatAndCape).to.not.exist; |
| 38 | + clock.restore(); |
| 39 | + clock = sinon.useFakeTimers(new Date('2024-07-10')); |
| 40 | + const julyGear = content.gear.flat; |
| 41 | + expect(julyGear.armor_armoire_corsairsCoatAndCape).to.exist; |
| 42 | + expect(Object.keys(juneGear).length, '').to.equal(Object.keys(julyGear).length - 3); |
| 43 | + }); |
| 44 | + |
| 45 | + it('Releases pets gear when appropriate without needing restarting', () => { |
| 46 | + clock = sinon.useFakeTimers(new Date('2024-06-20')); |
| 47 | + const junePets = content.petInfo; |
| 48 | + expect(junePets['Chameleon-Base']).to.not.exist; |
| 49 | + clock.restore(); |
| 50 | + clock = sinon.useFakeTimers(new Date('2024-07-10')); |
| 51 | + const julyPets = content.petInfo; |
| 52 | + expect(julyPets['Chameleon-Base']).to.exist; |
| 53 | + expect(Object.keys(junePets).length, '').to.equal(Object.keys(julyPets).length - 10); |
| 54 | + }); |
| 55 | + |
| 56 | + it('Releases mounts gear when appropriate without needing restarting', () => { |
| 57 | + clock = sinon.useFakeTimers(new Date('2024-06-20')); |
| 58 | + const juneMounts = content.mountInfo; |
| 59 | + expect(juneMounts['Chameleon-Base']).to.not.exist; |
| 60 | + clock.restore(); |
| 61 | + clock = sinon.useFakeTimers(new Date('2024-07-10')); |
| 62 | + const julyMounts = content.mountInfo; |
| 63 | + expect(julyMounts['Chameleon-Base']).to.exist; |
| 64 | + expect(Object.keys(juneMounts).length, '').to.equal(Object.keys(julyMounts).length - 10); |
| 65 | + }); |
| 66 | + |
| 67 | + it('marks regular food as buyable and droppable without any events', () => { |
| 68 | + clock = sinon.useFakeTimers(new Date('2024-06-20')); |
| 69 | + const { food } = content; |
| 70 | + Object.keys(food).forEach(key => { |
| 71 | + if (key === 'Saddle') { |
| 72 | + expect(food[key].canBuy(), `${key} canBuy`).to.be.true; |
| 73 | + expect(food[key].canDrop, `${key} canDrop`).to.be.false; |
| 74 | + return; |
| 75 | + } |
| 76 | + let expected = true; |
| 77 | + if (key.startsWith('Cake_')) { |
| 78 | + expected = false; |
| 79 | + } else if (key.startsWith('Candy_')) { |
| 80 | + expected = false; |
| 81 | + } else if (key.startsWith('Pie_')) { |
| 82 | + expected = false; |
| 83 | + } |
| 84 | + expect(food[key].canBuy(), `${key} canBuy`).to.equal(expected); |
| 85 | + expect(food[key].canDrop, `${key} canDrop`).to.equal(expected); |
| 86 | + }); |
| 87 | + }); |
| 88 | + |
| 89 | + it('marks candy as buyable and droppable during habitoween', () => { |
| 90 | + clock = sinon.useFakeTimers(new Date('2024-10-31')); |
| 91 | + const { food } = content; |
| 92 | + Object.keys(food).forEach(key => { |
| 93 | + if (key === 'Saddle') { |
| 94 | + expect(food[key].canBuy(), `${key} canBuy`).to.be.true; |
| 95 | + expect(food[key].canDrop, `${key} canDrop`).to.be.false; |
| 96 | + return; |
| 97 | + } |
| 98 | + let expected = false; |
| 99 | + if (key.startsWith('Cake_')) { |
| 100 | + expected = false; |
| 101 | + } else if (key.startsWith('Candy_')) { |
| 102 | + expected = true; |
| 103 | + } else if (key.startsWith('Pie_')) { |
| 104 | + expected = false; |
| 105 | + } |
| 106 | + expect(food[key].canBuy(), `${key} canBuy`).to.equal(expected); |
| 107 | + expect(food[key].canDrop, `${key} canDrop`).to.equal(expected); |
| 108 | + }); |
| 109 | + }); |
| 110 | + |
| 111 | + it('marks cake as buyable and droppable during birthday', () => { |
| 112 | + clock = sinon.useFakeTimers(new Date('2024-01-31')); |
| 113 | + const { food } = content; |
| 114 | + Object.keys(food).forEach(key => { |
| 115 | + if (key === 'Saddle') { |
| 116 | + expect(food[key].canBuy(), `${key} canBuy`).to.be.true; |
| 117 | + expect(food[key].canDrop, `${key} canDrop`).to.be.false; |
| 118 | + return; |
| 119 | + } |
| 120 | + let expected = false; |
| 121 | + if (key.startsWith('Cake_')) { |
| 122 | + expected = true; |
| 123 | + } else if (key.startsWith('Candy_')) { |
| 124 | + expected = false; |
| 125 | + } else if (key.startsWith('Pie_')) { |
| 126 | + expected = false; |
| 127 | + } |
| 128 | + expect(food[key].canBuy(), `${key} canBuy`).to.equal(expected); |
| 129 | + expect(food[key].canDrop, `${key} canDrop`).to.equal(expected); |
| 130 | + }); |
| 131 | + }); |
| 132 | + |
| 133 | + it('marks pie as buyable and droppable during pi day', () => { |
| 134 | + clock = sinon.useFakeTimers(new Date('2024-03-14')); |
| 135 | + const { food } = content; |
| 136 | + Object.keys(food).forEach(key => { |
| 137 | + if (key === 'Saddle') { |
| 138 | + expect(food[key].canBuy(), `${key} canBuy`).to.be.true; |
| 139 | + expect(food[key].canDrop, `${key} canDrop`).to.be.false; |
| 140 | + return; |
| 141 | + } |
| 142 | + let expected = false; |
| 143 | + if (key.startsWith('Cake_')) { |
| 144 | + expected = false; |
| 145 | + } else if (key.startsWith('Candy_')) { |
| 146 | + expected = false; |
| 147 | + } else if (key.startsWith('Pie_')) { |
| 148 | + expected = true; |
| 149 | + } |
| 150 | + expect(food[key].canBuy(), `${key} canBuy`).to.equal(expected); |
| 151 | + expect(food[key].canDrop, `${key} canDrop`).to.equal(expected); |
| 152 | + }); |
| 153 | + }); |
| 154 | +}); |
0 commit comments