1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-12-22 16:21:41 +03:00
leon/test/unit/server/core/synchronizer.spec.js

46 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-02-10 15:26:50 +03:00
import Synchronizer from '@/core/synchronizer'
describe('synchronizer', () => {
describe('constructor()', () => {
test('creates a new instance of Synchronizer', () => {
const sync = new Synchronizer({ }, { }, { })
expect(sync).toBeInstanceOf(Synchronizer)
})
})
describe('synchronize()', () => {
test('executes direct synchronization method', () => {
const brain = { socket: { } }
brain.talk = brain.socket.emit = brain.wernicke = jest.fn()
const sync = new Synchronizer(brain, { }, { method: 'direct' })
sync.direct = jest.fn()
sync.synchronize(() => {
expect(sync.direct).toHaveBeenCalledTimes(1)
})
})
test('executes Google Drive synchronization method', () => {
const brain = { socket: { } }
brain.talk = brain.socket.emit = brain.wernicke = jest.fn()
const sync = new Synchronizer(brain, { }, { method: 'google-drive' })
sync.googleDrive = jest.fn()
sync.synchronize(() => {
expect(sync.googleDrive).toHaveBeenCalledTimes(1)
})
})
})
describe('direct()', () => {
test('emits the download', () => {
const brain = { socket: { emit: jest.fn() } }
const sync = new Synchronizer(brain, { }, { })
sync.direct()
expect(sync.brain.socket.emit.mock.calls[0][0]).toBe('download')
})
})
})