-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbubbleSort.test.js
More file actions
49 lines (44 loc) · 1.53 KB
/
Copy pathbubbleSort.test.js
File metadata and controls
49 lines (44 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// const assert = require('assert');
const expect = require('chai').expect;
const bubbleSort = require('../sort/bubbleSort');
const source = [4, 5, 3, 6, 1, 2, 9, 10];
const target = [1, 2, 3, 4, 5, 6, 9, 10];
describe('#bubbleSort.js', () => {
describe('#bubbleSort1()', () => {
it(`bubbleSort1(${source}) should return ${target}`, () => {
const result = bubbleSort.bubbleSort1(source);
let pass = true;
for (let i = 0, len = result.length; i < len; i++) {
if (result[i] !== target[i]) {
pass = false;
}
}
if (!pass) {
throw new Error(`bubbleSort1(${source}) didnot return ${target}`);
}
});
});
});
describe('#bubbleSort.js width chai', () => {
describe('#bubbleSort1()', () => {
it(`${source} should deep equal ${source}`, () => {
expect(source).to.deep.equal(source);
});
it(`bubbleSort1(${source}) should return ${target}`, () => {
const result = bubbleSort.bubbleSort1(source);
expect(result).to.deep.equal(target);
});
it(`bubbleSort2(${source}) should return ${target}`, () => {
const result = bubbleSort.bubbleSort2(source);
expect(result).to.deep.equal(target);
});
it(`bubbleSort3(${source}) should return ${target}`, () => {
const result = bubbleSort.bubbleSort3(source);
expect(result).to.deep.equal(target);
});
it(`bubbleSort4(${source}) should return ${target}`, () => {
const result = bubbleSort.bubbleSort4(source);
expect(result).to.deep.equal(target);
});
});
});