Files
30-seconds-of-code/test/shank/shank.test.js
Brian Boyko efce13b1e1 shank() - array - duplicates Array.prototype.splice() except returns a new array instead of mutating in-place
Update shank.md

Update shank.md

Update shank.js

Update shank.test.js

Update tag_database

remove testlog
2018-09-27 14:59:50 +02:00

23 lines
619 B
JavaScript

const expect = require("expect");
const shank = require("./shank.js");
test("shank is a Function", () => {
expect(shank).toBeInstanceOf(Function);
});
const names = ['alpha', 'bravo', 'charlie'];
test("Returns an array with the added elements.", () => {
expect(shank(names, 1, 0, 'delta')).toEqual(['alpha', 'delta', 'bravo', 'charlie']);
});
test("Returns an array with the removed elements.", () => {
expect(shank(names, 1, 1)).toEqual(['alpha', 'charlie']);
});
test("Does not mutate the original array", () => {
shank(names, 1, 0, 'delta');
expect(names).toEqual(['alpha', 'bravo', 'charlie']);
});