-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathbalanced-parens-test.js
39 lines (29 loc) · 1.2 KB
/
balanced-parens-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
const test = require('tape')
const parensAreBalanced = require('./balanced-parens')
test('it matches braces when only one pair of one type exists', assert => {
assert.equal(parensAreBalanced('()'), true)
assert.equal(parensAreBalanced('[]'), true)
assert.equal(parensAreBalanced('('), false)
assert.equal(parensAreBalanced(']'), false)
assert.end()
})
test.skip('it matches braces when multiple pairs of one type exist', assert => {
assert.equal(parensAreBalanced('((()))'), true)
assert.equal(parensAreBalanced('((())'), false)
assert.end()
})
test.skip('it matches braces when multiple pairs of multiple types exist', assert => {
assert.equal(parensAreBalanced('{([])}'), true)
assert.equal(parensAreBalanced('{([]}'), false)
assert.end()
})
test.skip('it works correctly when no braces exist', assert => {
assert.equal(parensAreBalanced(''), true)
assert.equal(parensAreBalanced('hello world'), true)
assert.end()
})
test.skip('it matches braces when braces and other characters exist', assert => {
assert.equal(parensAreBalanced('function () { console.log(["cat", "dog"]) }'), true)
assert.equal(parensAreBalanced('function ( { console.log(["cat", "dog"]) }'), false)
assert.end()
})