Skip to content

Commit fa26d05

Browse files
author
Josh Lory
committed
Verify "flowerEmpty" event is emitted
1 parent ba8a15e commit fa26d05

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/unit/bee.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global describe, it, expect */
1+
/* global jest, describe, it, expect */
22

33
import Bee from '../../src/bee';
44
import BeeCell, {FeatureType} from '../../src/beeCell';
@@ -70,13 +70,18 @@ describe("Bee", function () {
7070
pegmanY: 0,
7171
});
7272

73+
const flowerEmptySpy = jest.fn();
74+
bee.on('flowerEmpty', flowerEmptySpy);
7375
bee.reset();
7476
expect(bee.getCell(0, 0).isFlower()).toEqual(true);
7577

7678
// Can get nectar twice.
7779
expect(bee.tryGetNectar()).toEqual(true);
7880
expect(bee.tryGetNectar()).toEqual(true);
81+
82+
// Getting nectar again returns false, and emits a "flowerEmpty" event.
7983
expect(bee.tryGetNectar()).toEqual(false);
84+
expect(flowerEmptySpy).toHaveBeenCalledTimes(1);
8085
})
8186
});
8287
});

0 commit comments

Comments
 (0)