mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2025-12-25 01:04:14 -05:00
test: add test-utils (#333)
This commit is contained in:
committed by
GitHub
parent
02b063cab1
commit
4af3a40672
69
apis/test-utils/src/__tests__/index.spec.js
Normal file
69
apis/test-utils/src/__tests__/index.spec.js
Normal file
@@ -0,0 +1,69 @@
|
||||
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/supernova', () => ({ 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);
|
||||
});
|
||||
});
|
||||
@@ -9,6 +9,7 @@ module.exports = {
|
||||
'**/__stories__/**',
|
||||
'**/apis/supernova/index.js',
|
||||
'**/apis/nucleus/index.js',
|
||||
'**/apis/test-utils/index.js',
|
||||
'**/packages/ui/icons/**/*.js', // Exclude the defined icons but test the `<SvgIcon />`
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user