Skip to content

Commit

Permalink
Merge pull request #665 from alpheios-project/fix-unit-tests
Browse files Browse the repository at this point in the history
Fix unit tests
  • Loading branch information
irina060981 authored Nov 18, 2021
2 parents 8ec34cd + 537b049 commit 1d4fc97
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/components/tests/lib/controllers/app-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ describe('AppController', () => {

it('88 AppController - onShortDefinitionsReady: should update the short definitions data', async () => {
const homonym = {
lexemes: [], language: 'lat'
lexemes: [], language: 'lat', targetWord: 'bar'
}
appC = AppController.jestCreate(uiState)
await appC.init()
Expand All @@ -1203,7 +1203,7 @@ describe('AppController', () => {
const showLanguageInfoSpy = jest.spyOn(appC, 'showLanguageInfo')
expect(appC._store.state.ui.messages).toEqual([])
expect(appC._store.state.app.shortDefUpdateTime).toBe(0)
appC.onShortDefinitionsReady({ homonym, requestType: 'foo', word: 'bar' })
appC.onShortDefinitionsReady({ homonym, requestType: 'foo' })
expect(appC.api.app.homonym).toBe(homonym)
expect(updateProvidersSpy).toBeCalledTimes(1)
expect(updateProvidersSpy).toBeCalledWith(homonym)
Expand All @@ -1216,25 +1216,28 @@ describe('AppController', () => {

it('89 AppController - onFullDefinitionsReady: should update the full definitions data', async () => {
const homonym = {
lexemes: [], language: 'lat'
lexemes: [], language: 'lat', targetWord: 'bar'
}
appC = AppController.jestCreate(uiState)
await appC.init()
await appC.activate()
const updateProvidersSpy = jest.spyOn(appC, 'updateProviders')
expect(appC._store.state.ui.messages).toEqual([])
expect(appC._store.state.app.fullDefUpdateTime).toBe(0)
appC.onFullDefinitionsReady({ homonym, requestType: 'foo', word: 'bar' })
appC.onFullDefinitionsReady({ homonym, requestType: 'foo' })
expect(updateProvidersSpy).toBeCalledTimes(1)
expect(updateProvidersSpy).toBeCalledWith(homonym)
expect(appC._store.state.ui.messages).toEqual([expect.stringContaining('request is completed successfully. Lemma')])
expect(appC._store.state.app.fullDefUpdateTime).toBeGreaterThan(0)
})

it('90 AppController - onDefinitionsNotFound: should commit a message', async () => {
const homonym = {
lexemes: [], language: 'lat', targetWord: 'bar'
}
const data = {
requestType: 'Test request type',
word: 'Test word'
homonym,
requestType: 'Test request type'
}
appC = AppController.jestCreate(uiState)
await appC.init()
Expand Down

0 comments on commit 1d4fc97

Please sign in to comment.