arraysort
Version:
Array sorting utility.
27 lines (23 loc) • 555 B
JavaScript
/**
* Test case for stringCompare.
* Runs with nodeunit.
*/
;
const stringCompare = require('../lib/string_compare.js');
exports['Sort string.'] = function (test) {
test.deepEqual(
['a', 'b', 'c'],
['a', 'c', 'b'].sort(stringCompare())
);
test.deepEqual(
['c', 'b', 'a'],
['a', 'c', 'b'].sort(stringCompare({desc: true}))
);
test.done();
};
exports['Try invalid args.'] = function (test) {
test.throws(function () {
stringCompare('foo', 'bar');
});
test.done();
};