forked from Kahoot-Clone/kahoot-clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.test.js
65 lines (60 loc) · 1.92 KB
/
functions.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
60
61
62
63
64
65
const fn = require('./functions');
describe('Game Methods', () => {
test('Should return a truthy value', () => {
expect(fn.generatePin()).toBeTruthy()
})
test('Should return number greater than 0', () => {
expect(fn.generatePin()).toBeGreaterThan(0)
})
test('Should return number less than 10000', () => {
expect(fn.generatePin()).toBeLessThan(10000)
})
test('Should not return NaN', () => {
expect(fn.generatePin()).not.toBe(NaN)
})
test('Should not return "I like green eggz and ham"', () => {
expect(fn.generatePin()).not.toBe('I like green eggz and ham')
})
})
describe('Adding player Method', () => {
let players = fn.addPlayer('dill', 789)
test('Should return anything', () => {
expect(fn.addPlayer('dill', 123)).toBeTruthy()
})
test('Should be an array', ()=> {
expect(fn.addPlayer('dill', 456)).arrayContaining
})
test('Should resolve', () => {
expect(fn.addPlayer('dill', 456)).resolves
})
test('Should add name to player', () => {
expect(players[0].name).toBe('dill')
})
test('Should start false', () => {
expect(players[0].qAnswered).toBeFalsy()
})
test('Should start false', () => {
expect(players[0].answeredCorrect).toBeFalsy()
})
})
// describe('Submit Answer Method', () => {
// let players = fn.addPlayer('bill', 789)
// let submit = fn.submitAnswer('bill', 3)
// })
describe('Submit Nickname Method', () => {
test('Should return a truthy value', () => {
expect(fn.handleNicknameInput("Ryan")).toBeTruthy()
})
test('Should be a string value', () => {
expect(fn.handleNicknameInput('Ryan')).toBe('Ryan')
})
test('Should not return NaN', () => {
expect(fn.handleNicknameInput()).not.toBe(NaN)
})
test('Should not return undefined', () => {
expect(fn.handleNicknameInput("ryan")).not.toBe(undefined)
})
test('Should not return Falsy value', () => {
expect(fn.handleNicknameInput("Ryan")).not.toBeFalsy()
})
})