1 | import chai from 'chai';
|
2 | import chaiWarrior from './helpers/chaiWarrior';
|
3 | import chaiEnemy from './helpers/chaiEnemy';
|
4 | import chaiCaptive from './helpers/chaiCaptive';
|
5 | import chaiWall from './helpers/chaiWall';
|
6 | import chaiStairs from './helpers/chaiStairs';
|
7 | import chaiPlayer from './helpers/chaiPlayer';
|
8 | import chaiTicking from './helpers/chaiTicking';
|
9 | import Floor from '../src/Floor';
|
10 | import Warrior from '../src/units/Warrior';
|
11 | import Sludge from '../src/units/Sludge';
|
12 | import Captive from '../src/units/Captive';
|
13 |
|
14 | chai.should();
|
15 | chai.use(chaiWarrior);
|
16 | chai.use(chaiEnemy);
|
17 | chai.use(chaiCaptive);
|
18 | chai.use(chaiWall);
|
19 | chai.use(chaiStairs);
|
20 | chai.use(chaiPlayer);
|
21 | chai.use(chaiTicking);
|
22 |
|
23 | describe('Space', function () {
|
24 | beforeEach(function () {
|
25 | this.floor = new Floor(2, 3);
|
26 | });
|
27 |
|
28 | describe('with empty space', function () {
|
29 | beforeEach(function () {
|
30 | this.space = this.floor.getSpaceAt(0, 0);
|
31 | });
|
32 |
|
33 | it('should not be enemy', function () {
|
34 | this.space.should.not.be.enemy;
|
35 | });
|
36 |
|
37 | it('should not be warrior', function () {
|
38 | this.space.should.not.be.warrior;
|
39 | });
|
40 |
|
41 | it('should be empty', function () {
|
42 | this.space.isEmpty().should.be.true;
|
43 | });
|
44 |
|
45 | it('should not be wall', function () {
|
46 | this.space.should.not.be.wall;
|
47 | });
|
48 |
|
49 | it('should not be stairs', function () {
|
50 | this.space.should.not.be.stairs;
|
51 | });
|
52 |
|
53 | it('should not be captive', function () {
|
54 | this.space.should.not.be.captive;
|
55 | });
|
56 |
|
57 | it('should say \'nothing\' as name', function () {
|
58 | this.space.toString().should.equal('nothing');
|
59 | });
|
60 |
|
61 | it('should not be ticking', function () {
|
62 | this.space.should.not.be.ticking;
|
63 | });
|
64 | });
|
65 |
|
66 | describe('out of bounds', function () {
|
67 | beforeEach(function () {
|
68 | this.space = this.floor.getSpaceAt(-1, 1);
|
69 | });
|
70 |
|
71 | it('should be wall', function () {
|
72 | this.space.should.be.wall;
|
73 | });
|
74 |
|
75 | it('should not be empty', function () {
|
76 | this.space.isEmpty().should.be.false;
|
77 | });
|
78 |
|
79 | it('should have name of \'wall\'', function () {
|
80 | this.space.toString().should.equal('wall');
|
81 | });
|
82 | });
|
83 |
|
84 | describe('with warrior', function () {
|
85 | beforeEach(function () {
|
86 | this.floor.addUnit(new Warrior(), 0, 0);
|
87 | this.space = this.floor.getSpaceAt(0, 0);
|
88 | });
|
89 |
|
90 | it('should be warrior', function () {
|
91 | this.space.should.be.warrior;
|
92 | });
|
93 |
|
94 | it('should be player', function () {
|
95 | this.space.should.be.player;
|
96 | });
|
97 |
|
98 | it('should not be enemy', function () {
|
99 | this.space.should.not.be.enemy;
|
100 | });
|
101 |
|
102 | it('should not be empty', function () {
|
103 | this.space.should.not.be.empty;
|
104 | });
|
105 |
|
106 | it('should know what unit is on that space', function () {
|
107 | this.space.unit.should.be.instanceOf(Warrior);
|
108 | });
|
109 | });
|
110 |
|
111 | describe('with enemy', function () {
|
112 | beforeEach(function () {
|
113 | this.floor.addUnit(new Sludge(), 0, 0);
|
114 | this.space = this.floor.getSpaceAt(0, 0);
|
115 | });
|
116 |
|
117 | it('should be enemy', function () {
|
118 | this.space.should.be.enemy;
|
119 | });
|
120 |
|
121 | it('should not be warrior', function () {
|
122 | this.space.should.not.be.warrior;
|
123 | });
|
124 |
|
125 | it('should not be empty', function () {
|
126 | this.space.should.not.be.empty;
|
127 | });
|
128 |
|
129 | it('should have name of unit', function () {
|
130 | this.space.toString().should.equal('Sludge');
|
131 | });
|
132 |
|
133 | describe('bound', function () {
|
134 | beforeEach(function () {
|
135 | this.space.unit.bind();
|
136 | });
|
137 |
|
138 | it('should be captive', function () {
|
139 | this.space.should.be.captive;
|
140 | });
|
141 |
|
142 | it('should not look like enemy', function () {
|
143 | this.space.should.not.be.enemy;
|
144 | });
|
145 | });
|
146 | });
|
147 |
|
148 | describe('with captive', function () {
|
149 | beforeEach(function () {
|
150 | this.captive = new Captive();
|
151 | this.floor.addUnit(this.captive, 0, 0);
|
152 | this.space = this.floor.getSpaceAt(0, 0);
|
153 | });
|
154 |
|
155 | it('should be captive', function () {
|
156 | this.space.should.be.captive;
|
157 | });
|
158 |
|
159 | it('should not be enemy', function () {
|
160 | this.space.should.not.be.enemy;
|
161 | });
|
162 |
|
163 | it('should be ticking if captive has time bomb', function () {
|
164 | this.captive.addAbilities([{ name: 'explode', args: [] }]);
|
165 | this.space.should.be.ticking;
|
166 | });
|
167 |
|
168 | it('should not be ticking if captive does not have time bomb', function () {
|
169 | this.space.should.not.be.ticking;
|
170 | });
|
171 | });
|
172 |
|
173 | describe('player object', function () {
|
174 | beforeEach(function () {
|
175 | this.space = this.floor.getSpaceAt(0, 0);
|
176 | this.playerObject = this.space.toPlayerObject();
|
177 | });
|
178 | });
|
179 | });
|