Skip to content

Commit a996b2d

Browse files
committed
add: more test cases
1 parent 4fd02bc commit a996b2d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/immutable_sequence.test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ describe('Immutable Sequence', function () {
1313
s.size().should.eql(3);
1414
});
1515

16+
it('should be able to get the first element', function () {
17+
var s = ImmutableSequence.fromArray([]);
18+
(s.peekFirst() === null).should.be.true;
19+
20+
s = ImmutableSequence.fromArray([1, 2, 3]);
21+
s.peekFirst().should.equal(1);
22+
});
23+
24+
it('should be able to get the last element', function () {
25+
var s = ImmutableSequence.fromArray([]);
26+
(s.peekLast() === null).should.be.true;
27+
28+
s = ImmutableSequence.fromArray([1, 2, 3]);
29+
s.peekLast().should.equal(3);
30+
});
31+
1632
it('should be able to add an element to the end', function () {
1733
var s = ImmutableSequence.fromArray([]);
1834
s = s.addLast(1);
@@ -43,6 +59,22 @@ describe('Immutable Sequence', function () {
4359
}).should.throw();
4460
});
4561

62+
it('should be able to remove an element from the front', function () {
63+
var s = ImmutableSequence.fromArray([1, 2, 3]);
64+
s = s.removeFirst();
65+
s.size().should.equal(2);
66+
s.peekFirst().should.equal(2);
67+
s.peekLast().should.equal(3);
68+
});
69+
70+
it('should be able to remove an element from the end', function () {
71+
var s = ImmutableSequence.fromArray([1, 2, 3]);
72+
s = s.removeLast();
73+
s.size().should.equal(2);
74+
s.peekFirst().should.equal(1);
75+
s.peekLast().should.equal(2);
76+
});
77+
4678
it('should be able to split at a certain position', function () {
4779
var s = ImmutableSequence.fromArray([1, 2, 3]);
4880
var split = s.splitAt(1);

0 commit comments

Comments
 (0)