Skip to content

Commit

Permalink
feat: add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
drawcall committed Sep 17, 2021
1 parent 91da7f1 commit 6abadac
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffcreatorlite",
"version": "2.3.1",
"version": "2.3.2",
"description": "FFCreatorLite is a lightweight and flexible short video production library",
"main": "lib/index.js",
"scripts": {
Expand Down
61 changes: 31 additions & 30 deletions test/unit/core/base.test.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
const FFBase = require('@/core/base')
const FFBase = require('@/core/base');

jest.mock('events')
jest.mock('@/conf/conf', ()=> ({
getFakeConf: jest.fn(()=> ({}))
}))
jest.mock('@/utils/utils', ()=> ({
generateID: jest.fn(()=> 1)
}))
jest.mock('events');
jest.mock('@/conf/conf', () => ({
getFakeConf: jest.fn(() => ({})),
}));
jest.mock('@/utils/utils', () => ({
generateID: jest.fn(() => 1),
genId: jest.fn(() => 1),
}));

describe('core/base', ()=> {
let base = null
describe('core/base', () => {
let base = null;
base = new FFBase();

test('instantiation component needs to succeed', ()=> {
base = new FFBase()
expect(base).toBeInstanceOf(FFBase)
})
test('instantiation component needs to succeed', () => {
expect(base).toBeInstanceOf(FFBase);
});

test('generateID: set id success', ()=> {
base.generateID()
expect(base.id).toBe(1)
})
test('generateID: set id success', () => {
base.genId();
expect(base.id).toBe(1);
});

test('root: should return self', ()=> {
expect(base.root()).toBe(base)
})
test('root: should return self', () => {
expect(base.root()).toBe(base);
});

test('rootConf: should return conf', ()=> {
const conf = base.rootConf()
expect(conf).toMatchObject({})
})
test('rootConf: should return conf', () => {
const conf = base.rootConf();
expect(conf).toMatchObject({});
});

test('destroy: destroy function invoke success', ()=> {
base.destroy()
expect(base.parent).toBeFalsy()
})
})
test('destroy: destroy function invoke success', () => {
base.destroy();
expect(base.parent).toBeFalsy();
});
});
5 changes: 3 additions & 2 deletions test/unit/node/node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ jest.mock('@/conf/conf', () => ({
}));
jest.mock('@/utils/utils', () => ({
generateID: jest.fn(() => 1),
genId: jest.fn(() => 1),
}));

describe('node/node', () => {
let node = null;
node = new FFNode();

test('instantiation component needs to succeed', () => {
node = new FFNode();
expect(node).toBeInstanceOf(FFNode);
});

test('generateID: set id success', () => {
node.generateID();
node.genId();
expect(node.id).toBe(1);
});

Expand Down

0 comments on commit 6abadac

Please sign in to comment.