Created
May 28, 2017 09:35
-
-
Save pahund/b839ba95c2ab0f00464de6c0bfd68a5e to your computer and use it in GitHub Desktop.
Attempt to solve problem of stubbing require.ensure in Mocha unit tests (see https://stackoverflow.com/questions/44114737/how-do-i-stub-webpacks-require-ensure)
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
/** | |
* PageHeaderTest.js | |
* | |
* (C) 2017 mobile.de GmbH | |
* | |
* @author <a href="mailto:[email protected]">Patrick Hund</a> | |
* @since 28 Mai 2017 | |
*/ | |
import { mount } from 'enzyme'; | |
import React from 'react'; | |
import PageHeader from '../../../../src/shared/components/pageHeader/PageHeader'; | |
import { sandbox } from 'sinon'; | |
describe('[shared/components/pageHeader/PageHeader]', () => { | |
describe('When I render the component', () => { | |
let mySandbox; | |
const dummyFunction = () => { | |
// intentionally left blank | |
}; | |
beforeEach(() => { | |
mySandbox = sandbox.create(); | |
require.ensure = sandbox.stub(); | |
mount(<PageHeader requestBoardData={dummyFunction} />); | |
}); | |
describe('webpack code splitting', () => it('is used to load modules asynchronously', () => | |
require.ensure.should.have.been.called | |
)); | |
afterEach(() => { | |
mySandbox.restore(); | |
delete require.ensure; | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment