-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests for the manual initializer J=SLAP-1371 TEST=auto
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ManualInitializer from '../../../static/js/manual-initializer'; | ||
|
||
describe('The manual initializer works', () => { | ||
let initAnswers; | ||
|
||
beforeEach(() => { | ||
window.AnswersExperience = { | ||
runtimeConfig: { | ||
get: jest.fn(), | ||
set: jest.fn() | ||
} | ||
}; | ||
initAnswers = jest.fn(); | ||
const manualInitializer = new ManualInitializer(initAnswers); | ||
manualInitializer.setup(); | ||
}) | ||
|
||
it('The manual init function calls initAnswers', () => { | ||
window.AnswersExperience.init(); | ||
expect(initAnswers).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('Data passed into the init function is set on the runtimeConfig', () => { | ||
window.AnswersExperience.init({ | ||
token: '123abc', | ||
linkTarget: '_blank' | ||
}); | ||
const runtimeConfigSet = window.AnswersExperience.runtimeConfig.set; | ||
expect(runtimeConfigSet).toHaveBeenCalledWith('token', '123abc'); | ||
expect(runtimeConfigSet).toHaveBeenCalledWith('linkTarget', '_blank'); | ||
}); | ||
}); |