Skip to content

Instantly share code, notes, and snippets.

@yury-sannikov
Last active August 8, 2017 20:53
Show Gist options
  • Save yury-sannikov/90ca7124af86ffefd8e40d3c514dc6e4 to your computer and use it in GitHub Desktop.
Save yury-sannikov/90ca7124af86ffefd8e40d3c514dc6e4 to your computer and use it in GitHub Desktop.
mocha-aura timeouts
let clock;
before(function() {
clock = sinon.useFakeTimers();
});
describe('Create Component', function() {
it('should create component after timeout of 500 ms', function() {
// Make helper call which uses setTimeout(..., 500) to call GlobalHelper.showLoadedData()
helper.createComponent();
// Check that showLoadedData not called yet
expect(global.GlobalHelper.showLoadedData).not.to.have.been.called;
// Emulate 501ms has been elapsed and showLoadedData have been called in synchronous manner
clock.tick(501);
expect(global.GlobalHelper.showLoadedData).to.have.been.calledWith(component);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment