mirror of
https://github.com/leon-ai/leon.git
synced 2024-12-20 07:11:40 +03:00
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
'use strict'
|
|
|
|
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')
|
|
})
|
|
})
|
|
})
|