mocha tests moved to jest
This commit is contained in:
parent
9c2bb2a5a6
commit
1e11926ebc
|
@ -1,5 +1,7 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { measure, makeName, computeBestMenuPosition } from '../src/helpers';
|
|
||||||
|
jest.dontMock('../src/helpers');
|
||||||
|
const { measure, makeName, computeBestMenuPosition } = require('../src/helpers');
|
||||||
|
|
||||||
describe('helpers test', () => {
|
describe('helpers test', () => {
|
||||||
|
|
||||||
|
@ -32,14 +34,10 @@ describe('helpers test', () => {
|
||||||
|
|
||||||
it('should return unique names', () => {
|
it('should return unique names', () => {
|
||||||
const name1 = makeName(),
|
const name1 = makeName(),
|
||||||
name2 = makeName(),
|
name2 = makeName();
|
||||||
name3 = require('../src/helpers').makeName();
|
|
||||||
expect(name1).to.be.a('string');
|
expect(name1).to.be.a('string');
|
||||||
expect(name2).to.be.a('string');
|
expect(name2).to.be.a('string');
|
||||||
expect(name3).to.be.a('string');
|
|
||||||
expect(name1).not.to.be.equal(name2);
|
expect(name1).not.to.be.equal(name2);
|
||||||
expect(name1).not.to.be.equal(name3);
|
|
||||||
expect(name2).not.to.be.equal(name3);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
|
@ -1,5 +1,7 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import makeMenuRetistry from '../src/menuRegistry';
|
|
||||||
|
jest.dontMock('../src/menuRegistry');
|
||||||
|
const makeMenuRegistry = require('../src/menuRegistry').default;
|
||||||
|
|
||||||
describe('menuRegistry tests', () => {
|
describe('menuRegistry tests', () => {
|
||||||
|
|
||||||
|
@ -18,11 +20,11 @@ describe('menuRegistry tests', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should export function', () => {
|
it('should export function', () => {
|
||||||
expect(makeMenuRetistry).to.be.a('function');
|
expect(makeMenuRegistry).to.be.a('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create an object', () => {
|
it('should create an object', () => {
|
||||||
expect(makeMenuRetistry(new Map())).to.be.an('object');
|
expect(makeMenuRegistry(new Map())).to.be.an('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getMenu', () => {
|
describe('getMenu', () => {
|
||||||
|
@ -30,14 +32,14 @@ describe('menuRegistry tests', () => {
|
||||||
const menus = new Map([
|
const menus = new Map([
|
||||||
[menu1.name, menu1]
|
[menu1.name, menu1]
|
||||||
]);
|
]);
|
||||||
const registry = makeMenuRetistry(menus);
|
const registry = makeMenuRegistry(menus);
|
||||||
expect(registry.getMenu(menu1.name)).to.eql(menu1);
|
expect(registry.getMenu(menu1.name)).to.eql(menu1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('subscribe', () => {
|
describe('subscribe', () => {
|
||||||
it('should subscribe menu', () => {
|
it('should subscribe menu', () => {
|
||||||
const registry = makeMenuRetistry();
|
const registry = makeMenuRegistry();
|
||||||
registry.subscribe(menu1.name, menu1);
|
registry.subscribe(menu1.name, menu1);
|
||||||
expect(registry.getMenu(menu1.name)).to.eql(menu1);
|
expect(registry.getMenu(menu1.name)).to.eql(menu1);
|
||||||
});
|
});
|
||||||
|
@ -49,7 +51,7 @@ describe('menuRegistry tests', () => {
|
||||||
[menu1.name, menu1],
|
[menu1.name, menu1],
|
||||||
[menu2.name, menu2]
|
[menu2.name, menu2]
|
||||||
]);
|
]);
|
||||||
const registry = makeMenuRetistry(menus);
|
const registry = makeMenuRegistry(menus);
|
||||||
registry.unsubscribe(menu1.name);
|
registry.unsubscribe(menu1.name);
|
||||||
expect(registry.getMenu(menu1.name)).to.be.undefined;
|
expect(registry.getMenu(menu1.name)).to.be.undefined;
|
||||||
expect(registry.getMenu(menu2.name)).to.eql(menu2);
|
expect(registry.getMenu(menu2.name)).to.eql(menu2);
|
||||||
|
@ -66,7 +68,7 @@ describe('menuRegistry tests', () => {
|
||||||
triggerLayout: 5,
|
triggerLayout: 5,
|
||||||
optionsLayout: 6
|
optionsLayout: 6
|
||||||
}]]);
|
}]]);
|
||||||
const registry = makeMenuRetistry(menus);
|
const registry = makeMenuRegistry(menus);
|
||||||
registry.update('menu3', {
|
registry.update('menu3', {
|
||||||
options: [7, 8],
|
options: [7, 8],
|
||||||
trigger: 'trigger3x',
|
trigger: 'trigger3x',
|
||||||
|
@ -91,7 +93,7 @@ describe('menuRegistry tests', () => {
|
||||||
triggerLayout: 5,
|
triggerLayout: 5,
|
||||||
optionsLayout: 6
|
optionsLayout: 6
|
||||||
}]]);
|
}]]);
|
||||||
const registry = makeMenuRetistry(menus);
|
const registry = makeMenuRegistry(menus);
|
||||||
registry.updateLayoutInfo('menu3', { optionsLayout: 7 });
|
registry.updateLayoutInfo('menu3', { optionsLayout: 7 });
|
||||||
expect(registry.getMenu('menu3')).to.eql({
|
expect(registry.getMenu('menu3')).to.eql({
|
||||||
name: 'menu3',
|
name: 'menu3',
|
||||||
|
@ -106,7 +108,7 @@ describe('menuRegistry tests', () => {
|
||||||
triggerLayout: 5,
|
triggerLayout: 5,
|
||||||
optionsLayout: 6
|
optionsLayout: 6
|
||||||
}]]);
|
}]]);
|
||||||
const registry = makeMenuRetistry(menus);
|
const registry = makeMenuRegistry(menus);
|
||||||
registry.updateLayoutInfo('menu3', { triggerLayout: 7 });
|
registry.updateLayoutInfo('menu3', { triggerLayout: 7 });
|
||||||
expect(registry.getMenu('menu3')).to.eql({
|
expect(registry.getMenu('menu3')).to.eql({
|
||||||
name: 'menu3',
|
name: 'menu3',
|
12
package.json
12
package.json
|
@ -7,8 +7,7 @@
|
||||||
"example": "examples"
|
"example": "examples"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test-mocha": "mocha --compilers js:babel-core/register",
|
"test": "jest",
|
||||||
"test": "rm -rf ./node_modules/jest-cli/.haste_cache && jest",
|
|
||||||
"lint": "eslint ."
|
"lint": "eslint ."
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -23,10 +22,15 @@
|
||||||
"homepage": "https://github.com/instea/react-native-popup-menu",
|
"homepage": "https://github.com/instea/react-native-popup-menu",
|
||||||
"jest": {
|
"jest": {
|
||||||
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
|
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
|
||||||
"testFileExtensions": [ "js" ],
|
"testFileExtensions": [
|
||||||
"moduleFileExtensions": [ "js" ],
|
"js"
|
||||||
|
],
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"js"
|
||||||
|
],
|
||||||
"unmockedModulePathPatterns": [
|
"unmockedModulePathPatterns": [
|
||||||
"<rootDir>/node_modules/react",
|
"<rootDir>/node_modules/react",
|
||||||
|
"<rootDir>/node_modules/chai",
|
||||||
"<rootDir>/node_modules/fbjs"
|
"<rootDir>/node_modules/fbjs"
|
||||||
],
|
],
|
||||||
"verbose": true,
|
"verbose": true,
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
* optionsLayout: Object
|
* optionsLayout: Object
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
export default function makeMenuRetistry(menus = new Map()) {
|
export default function makeMenuRegistry(menus = new Map()) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes menu by name.
|
* Subscribes menu by name.
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
--recursive
|
|
Loading…
Reference in New Issue