Skip to content

Commit e2394e7

Browse files
misterpekertMaksim Shastsel
authored and
Maksim Shastsel
committed
insertAt shouldn't replace existing values (#13)
1 parent a3ac1fc commit e2394e7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/linked-list.spec.js

+15
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,21 @@ describe('LinkedList', () => {
8181

8282
expect(list.at(position)).to.equal(data);
8383
});
84+
85+
it ('shouldn\'t replace existing values', () => {
86+
const list = new LinkedList();
87+
const position = 1;
88+
const data = 42;
89+
let values = [10, 20];
90+
values.forEach((value) => { list.append(value) });
91+
92+
list.insertAt(position, data);
93+
values.splice(position, 0, data);
94+
95+
values.forEach((value, index) => {
96+
expect(list.at(index)).to.equal(value);
97+
});
98+
});
8499
});
85100
describe('#isEmpty', () => {
86101
it('should return true if list is empty', () => {

0 commit comments

Comments
 (0)