/
check-answer.test.js
36 lines (34 loc) · 1.66 KB
/
check-answer.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
const check = require('../lib/quiz/check-answer.js')
describe('checkAnswer', () => {
it('accepts the right answer, or leaving off one character, but not adding a character', () => {
expect(check('salmonella', 'salmonella')).toBe(true)
expect(check('salmonella', 'salmonell')).toBe(true)
expect(check('salmonell', 'salmonella')).toBe(false)
})
it('ignores (lowercase or title-case) articles at the beginning and middle of things, but not the end', () => {
expect(check('a check', 'check')).toBe(true)
expect(check('A check', 'check')).toBe(true)
expect(check('check', 'a check')).toBe(true)
expect(check('check', 'check a')).toBe(false)
expect(check('check', 'A check')).toBe(true)
expect(check('check', 'check A')).toBe(false)
expect(check('an check', 'check')).toBe(true)
expect(check('check an', 'check')).toBe(false)
expect(check('An check', 'check')).toBe(true)
expect(check('check An', 'check')).toBe(false)
expect(check('check', 'an check')).toBe(true)
expect(check('check', 'check an')).toBe(false)
expect(check('check', 'An check')).toBe(true)
expect(check('check', 'check An')).toBe(false)
expect(check('the check', 'check')).toBe(true)
expect(check('check the', 'check')).toBe(false)
expect(check('The check', 'check')).toBe(true)
expect(check('check The', 'check')).toBe(false)
expect(check('check', 'the check')).toBe(true)
expect(check('check', 'check the')).toBe(false)
expect(check('check', 'The check')).toBe(true)
expect(check('check', 'Theck the')).toBe(false)
expect(check('chEqUe', 'CHeQuE')).toBe(true)
expect(check('chEqU e', 'CHe QuE')).toBe(true)
})
})