Last active
February 10, 2017 18:41
-
-
Save ppsirius/614c5068085f1cf6df2d964b9febdd1f to your computer and use it in GitHub Desktop.
Jest mock dependencies
This file contains hidden or 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
| import ScheduleFactory from "./factory/services/schedule-factory.service"; | |
| import ScheduleManager from "./schedule-manager.service"; | |
| function SampleApp() { | |
| var appElement; | |
| function newScheduleHandler(pEvent) { | |
| var scheduleModel; | |
| Logger.info("New Schedule"); | |
| if (!pEvent.data) { | |
| return; | |
| } | |
| scheduleModel = ScheduleFactory.prepareScheduleModel(pEvent.data, pEvent.filepath + "/"); | |
| ScheduleManager.updateSchedule(scheduleModel); | |
| } | |
| function init() { | |
| ScheduleFactory; | |
| } | |
| return { | |
| init: init | |
| }; | |
| } | |
| export default SampleApp; |
This file contains hidden or 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
| function ScheduleFactory() { | |
| return false; | |
| } | |
| module.exports = ScheduleFactory; |
This file contains hidden or 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
| jest.mock('../src/js/factory/services/schedule-factory.service', ScheduleFactory => { | |
| return { | |
| prepareScheduleModel: jest.fn() | |
| } | |
| }); | |
| import SampleApp from '../src/js/sampleApp'; | |
| test('sample App init', () => { | |
| expect(SampleApp().init()).toBe(false); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment