-
Notifications
You must be signed in to change notification settings - Fork 350
Expand file tree
/
Copy pathStudyAnswer.spec.js
More file actions
37 lines (31 loc) · 1.08 KB
/
StudyAnswer.spec.js
File metadata and controls
37 lines (31 loc) · 1.08 KB
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
import StudyAnswer from '@/shared/models/StudyAnswer'
describe('StudyAnswer', () => {
describe('constructor', () => {
it('sets type from provided data', () => {
const answer = new StudyAnswer({ type: 'HEURISTIC' })
expect(answer.type).toBe('HEURISTIC')
})
it('handles missing type', () => {
const answer = new StudyAnswer({})
expect(answer.type).toBeUndefined()
})
it('handles no arguments', () => {
const answer = new StudyAnswer()
expect(answer.type).toBeUndefined()
})
})
describe('toFirestore', () => {
it('returns correct shape with type', () => {
const answer = new StudyAnswer({ type: 'USER' })
expect(answer.toFirestore()).toEqual({ type: 'USER' })
})
it('defaults type to empty string when null', () => {
const answer = new StudyAnswer({ type: null })
expect(answer.toFirestore()).toEqual({ type: '' })
})
it('defaults type to empty string when undefined', () => {
const answer = new StudyAnswer({})
expect(answer.toFirestore()).toEqual({ type: '' })
})
})
})