Skip to content

Commit ba8a15e

Browse files
author
Josh Lory
committed
Add basic unit test for gathering nectar from a flower with 2 capacity
1 parent 64b1005 commit ba8a15e

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

test/unit/bee.test.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* global describe, it, expect */
22

33
import Bee from '../../src/bee';
4-
import BeeCell from '../../src/beeCell';
4+
import BeeCell, {FeatureType} from '../../src/beeCell';
55
import MazeMap from '../../src/mazeMap';
66

77
const baseLevel = {
@@ -55,4 +55,28 @@ describe("Bee", function () {
5555
validate('purpleNectarHidden', 'FC', 1, false, 'overriden cloud');
5656
});
5757
});
58+
59+
describe('getting nectar', () => {
60+
let bee;
61+
62+
it('builds the map', () => {
63+
const map = new MazeMap([
64+
[new BeeCell(1, FeatureType.FLOWER, 2)],
65+
]);
66+
67+
bee = new Bee({
68+
map,
69+
pegmanX: 0,
70+
pegmanY: 0,
71+
});
72+
73+
bee.reset();
74+
expect(bee.getCell(0, 0).isFlower()).toEqual(true);
75+
76+
// Can get nectar twice.
77+
expect(bee.tryGetNectar()).toEqual(true);
78+
expect(bee.tryGetNectar()).toEqual(true);
79+
expect(bee.tryGetNectar()).toEqual(false);
80+
})
81+
});
5882
});

0 commit comments

Comments
 (0)