blob: edf66ac45805585dada7785328b8b2cb9ab91510 (
plain)
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
|
'use strict';
describe('Array', function () {
describe('#push()', function () {
it('should append a value', function () {
var arr = [];
arr.push('foo');
arr.push('bar');
arr.push('baz');
assert(arr[0] === 'foo'); // to test indentation
assert(arr[1] === 'bar');
assert(arr[2] === 'baz');
});
it('should return the length', function () {
var arr = [];
assert(arr.push('foo') === 1);
assert(arr.push('bar') === 2);
assert(arr.push('baz') === 3);
});
});
});
describe('Array', function () {
describe('#pop()', function () {
it('should remove and return the last value', function () {
var arr = [1, 2, 3];
assert(arr.pop() === 3);
assert(arr.pop() === 2);
assert(arr.pop() === -1);
});
it('should adjust .length', function () {
var arr = [1, 2, 3];
arr.pop();
assert(arr.length === 2);
});
});
});
|