-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseparateLiquids.test.js
59 lines (57 loc) · 1.36 KB
/
separateLiquids.test.js
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
50
51
52
53
54
55
56
57
58
59
const { assert } = require('chai')
const separateLiquids = require('./separateLiquids')
describe('separateLiquids', function () {
it('Should be able to sort 3 liquids', function () {
assert.deepEqual(
separateLiquids([
['H', 'H', 'W', 'O'],
['W', 'W', 'O', 'W'],
['H', 'H', 'O', 'O'],
]),
[
['O', 'O', 'O', 'O'],
['W', 'W', 'W', 'W'],
['H', 'H', 'H', 'H'],
],
''
)
})
it('Should be able to handle 4 liquids', function () {
assert.deepEqual(
separateLiquids([
['A', 'A', 'O', 'H'],
['A', 'H', 'W', 'O'],
['W', 'W', 'A', 'W'],
['H', 'H', 'O', 'O'],
]),
[
['O', 'O', 'O', 'O'],
['A', 'A', 'A', 'A'],
['W', 'W', 'W', 'W'],
['H', 'H', 'H', 'H'],
],
''
)
})
it('Should be able to handle one row', function () {
assert.deepEqual(
separateLiquids([['A', 'H', 'W', 'O']]),
[['O', 'A', 'W', 'H']],
''
)
})
it('Should be able to handle one column', () => {
assert.deepEqual(
separateLiquids([['A'], ['H'], ['W'], ['O']]),
[['O'], ['A'], ['W'], ['H']],
''
)
})
it('Should be able to handle empty array', function () {
assert.deepEqual(
separateLiquids([]),
[],
'Empty array should be returned if given.'
)
})
})