-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.test.js
34 lines (28 loc) · 969 Bytes
/
model.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
import { Checkpoint } from '.'
import * as socket from './socket'
import { Journey } from '../journey'
import { User } from '../user'
const ioMock = {
emit: jest.fn()
}
socket.register(ioMock)
let checkpoint
beforeEach(async () => {
const owner = await User.create({ name: 'user', email: 'g@g.com', password: '123456'})
const journey = await Journey.create({ name: 'Test Journey', description: 'Test description', owner: owner })
checkpoint = await Checkpoint.create({ journey: journey, heartRate: 67 })
})
describe('view', () => {
it('returns simple view', () => {
const view = checkpoint.view()
expect(typeof view).toBe('object')
expect(view.id).toBe(checkpoint.id)
expect(view.heartRate).toBe(checkpoint.heartRate)
})
it('returns full view', () => {
const view = checkpoint.view(true)
expect(typeof view).toBe('object')
expect(view.id).toBe(checkpoint.id)
expect(view.heartRate).toBe(checkpoint.heartRate)
})
})