Files
30-seconds-of-code/test/stableSort/stableSort.test.js
2018-02-11 15:56:19 +02:00

21 lines
696 B
JavaScript

const test = require('tape');
const stableSort = require('./stableSort.js');
test('Testing stableSort', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof stableSort === 'function', 'stableSort is a Function');
//t.deepEqual(stableSort(args..), 'Expected');
//t.equal(stableSort(args..), 'Expected');
//t.false(stableSort(args..), 'Expected');
//t.throws(stableSort(args..), 'Expected');
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const compare = () => 0;
// stable
t.deepEqual(stableSort(arr, compare), arr);
// unstable
t.notDeepEqual([...arr].sort(compare), arr);
t.end();
});