From 56f977bf631999cd93395f5dec7115f99abbb65c Mon Sep 17 00:00:00 2001 From: King Date: Mon, 15 Jan 2018 10:52:30 -0500 Subject: [PATCH] add error, type, test for quicksort --- test/quickSort/quickSort.test.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/quickSort/quickSort.test.js b/test/quickSort/quickSort.test.js index 691226205..1252196cd 100644 --- a/test/quickSort/quickSort.test.js +++ b/test/quickSort/quickSort.test.js @@ -5,9 +5,18 @@ test('Testing quickSort', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof quickSort === 'function', 'quickSort is a Function'); - //t.deepEqual(quickSort(args..), 'Expected'); - //t.equal(quickSort(args..), 'Expected'); - //t.false(quickSort(args..), 'Expected'); - //t.throws(quickSort(args..), 'Expected'); + t.deepEqual(quickSort([5, 6, 4, 3, 1, 2]), [1, 2, 3, 4, 5, 6], 'quickSort([5, 6, 4, 3, 1, 2]) returns [1, 2, 3, 4, 5, 6]'); + t.deepEqual(quickSort([-1, 0, -2]), [-2, -1, 0], 'quickSort([-1, 0, -2]) returns [-2, -1, 0]'); + t.throws(() => quickSort(), 'quickSort() throws an error'); + t.throws(() => quickSort(123), 'quickSort(123) throws an error'); + t.throws(() => quickSort({ 234: string}), 'quickSort({ 234: string}) throws an error'); + t.throws(() => quickSort(null), 'quickSort(null) throws an error'); + t.throws(() => quickSort(undefined), 'quickSort(undefined) throws an error'); + + let start = new Date().getTime(); + quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]); + let end = new Date().getTime(); + t.true((end - start) < 2000, 'quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run'); + t.end(); }); \ No newline at end of file