Files
nebula.js/apis/test-utils/src/__tests__/index.spec.js
Miralem Drek 6a28ec3dd4 refactor: expose nucleus and supernova via stardust package (#415)
BREAKING CHANGE: nucleus and supernova are no longer public packages and are both replaced by stardust
2020-04-28 13:02:41 +02:00

70 lines
1.6 KiB
JavaScript

describe('test-utils', () => {
let sandbox;
let create;
let hook;
let hooked;
before(() => {
sandbox = sinon.createSandbox();
hooked = {
__hooked: true,
fn: sandbox.stub(),
initiate: sandbox.stub(),
run: sandbox.stub(),
teardown: sandbox.stub(),
runSnaps: sandbox.stub(),
observeActions: sandbox.stub(),
getImperativeHandle: sandbox.stub(),
updateRectOnNextRun: sandbox.stub(),
};
hook = sandbox.stub().returns(hooked);
[{ create }] = aw.mock([['@nebula.js/stardust', () => ({ __DO_NOT_USE__: { hook } })]], ['../index']);
});
afterEach(() => {
sandbox.restore();
});
it('should return api', () => {
const c = create();
expect(c.update).to.be.a('function');
expect(c.unmount).to.be.a('function');
expect(c.takeSnapshot).to.be.a('function');
expect(c.actions).to.be.a('function');
});
it('should update', () => {
const c = create();
c.update();
expect(hooked.run.callCount).to.equal(1);
hooked.run.reset();
const translator = {};
const context = { translator };
c.update(context);
expect(hooked.run).to.have.been.calledWithExactly(
sinon.match({
context,
})
);
});
it('should update', () => {
const c = create();
c.unmount();
expect(hooked.teardown.callCount).to.equal(1);
});
it('should take snapshot', () => {
const c = create();
c.takeSnapshot();
expect(hooked.runSnaps.callCount).to.equal(1);
});
it('should do actions', () => {
const c = create();
expect(c.actions()).to.have.length(0);
});
});