-
Notifications
You must be signed in to change notification settings - Fork 11k
/
Copy pathindexTest.js
81 lines (62 loc) · 2.88 KB
/
indexTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require ( './helpers.js' );
describe('index.js', function () {
describe('cats', function () {
it('is assigned an initial value of ["Milo", "Otis", "Garfield"]', function () {
expect(cats).to.have.ordered.members(["Milo", "Otis", "Garfield"]);
});
});
describe('Array functions', function () {
beforeEach(function () {
cats.length = 0;
cats.push('Milo', 'Otis', 'Garfield');
});
describe('destructivelyAppendCat(name)', function () {
it('appends a cat to the end of the cats array', function () {
destructivelyAppendCat('Ralph');
expect(cats).to.have.ordered.members(["Milo", "Otis", "Garfield", "Ralph"]);
});
});
describe('destructivelyPrependCat(name)', function () {
it('prepends a cat to the beginning of the cats array', function () {
destructivelyPrependCat("Bob");
expect(cats).to.have.ordered.members(["Bob", "Milo", "Otis", "Garfield"]);
});
});
describe('destructivelyRemoveLastCat()', function () {
it('removes the last cat from the cats array', function () {
destructivelyRemoveLastCat();
expect(cats).to.have.ordered.members(["Milo", "Otis"]).and.to.not.include('Garfield');
});
});
describe('destructivelyRemoveFirstCat()', function () {
it('removes the first cat from the cats array', function () {
destructivelyRemoveFirstCat();
expect(cats).to.have.ordered.members(["Otis", "Garfield"]).and.to.not.include('Milo');
});
});
describe('appendCat(name)', function () {
it('appends a cat to the cats array and returns a new array, leaving the cats array unchanged', function () {
expect(appendCat("Broom")).to.have.ordered.members(["Milo", "Otis", "Garfield", "Broom"]);
expect(cats).to.have.ordered.members(["Milo", "Otis", "Garfield"]);
});
});
describe('prependCat(name)', function () {
it('prepends a cat to the cats array and returns a new array, leaving the cats array unchanged', function () {
expect(prependCat("Arnold")).to.have.ordered.members(["Arnold", "Milo", "Otis", "Garfield"]);
expect(cats).to.have.ordered.members(["Milo", "Otis", "Garfield"]);
});
});
describe('removeLastCat()', function () {
it('removes the last cat in the cats array and returns a new array, leaving the cats array unchanged', function () {
expect(removeLastCat()).to.have.ordered.members(["Milo", "Otis"]);
expect(cats).to.have.ordered.members(["Milo", "Otis", "Garfield"]);
});
});
describe('removeFirstCat()', function () {
it('removes the first cat from the cats array and returns a new array, leaving the cats array unchanged', function () {
expect(removeFirstCat()).to.have.ordered.members(["Otis", "Garfield"]);
expect(cats).to.have.ordered.members(["Milo", "Otis", "Garfield"]);
});
});
});
});