-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
50 lines (40 loc) · 1.75 KB
/
index.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
// import {isValidUsingTraversing as isValid} from './index'
import {isValidUsingRegex as isValid} from './index'
describe('Day 3 challenge', () => {
test('is valid letter without parenthesis', () => {
expect(isValid('bici coche peluche')).toBeTruthy()
})
test('is valid letter with one parenthesis', () => {
expect(isValid('bici coche (balón) peluche')).toBeTruthy()
})
test('is valid letter with two parenthesis', () => {
expect(isValid('bici coche (balón) tren (moto) peluche')).toBeTruthy()
})
test('is valid letter starting with parenthesis', () => {
expect(isValid('(bici) coche peluche')).toBeTruthy()
})
test('is valid letter finishing with parenthesis', () => {
expect(isValid('bici coche (peluche)')).toBeTruthy()
})
test('is invalid letter with empty parenthesis', () => {
expect(isValid('bici () peluche')).toBeFalsy()
})
test('is invalid letter with unclosed parenthesis', () => {
expect(isValid('bici (coche peluche')).toBeFalsy()
expect(isValid('bici (coche) (peluche')).toBeFalsy()
})
test('is invalid letter with invalid chracters', () => {
expect(isValid('bici (tren [coche) peluche')).toBeFalsy()
expect(isValid('bici (tren ]coche) peluche')).toBeFalsy()
expect(isValid('bici (tren {coche) peluche')).toBeFalsy()
expect(isValid('bici (tren }coche) peluche')).toBeFalsy()
})
test('is invalid letter with unpair parenthesis', () => {
expect(isValid('bici coche (tren (moto) peluche')).toBeFalsy()
expect(isValid('bici (coche) (tren (moto) peluche')).toBeFalsy()
})
test('is invalid letter with inner parenthesis', () => {
expect(isValid('bici coche (tren (moto)) peluche')).toBeFalsy()
expect(isValid('bici (coche) (tren (moto)) peluche')).toBeFalsy()
})
})