Skip to content

Commit 1e11926

Browse files
committed
mocha tests moved to jest
1 parent 9c2bb2a commit 1e11926

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

test/helpers.tests.js renamed to __tests__/helpers-test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { expect } from 'chai';
2-
import { measure, makeName, computeBestMenuPosition } from '../src/helpers';
2+
3+
jest.dontMock('../src/helpers');
4+
const { measure, makeName, computeBestMenuPosition } = require('../src/helpers');
35

46
describe('helpers test', () => {
57

@@ -32,14 +34,10 @@ describe('helpers test', () => {
3234

3335
it('should return unique names', () => {
3436
const name1 = makeName(),
35-
name2 = makeName(),
36-
name3 = require('../src/helpers').makeName();
37+
name2 = makeName();
3738
expect(name1).to.be.a('string');
3839
expect(name2).to.be.a('string');
39-
expect(name3).to.be.a('string');
4040
expect(name1).not.to.be.equal(name2);
41-
expect(name1).not.to.be.equal(name3);
42-
expect(name2).not.to.be.equal(name3);
4341
});
4442

4543
});

test/menuRetistry.tests.js renamed to __tests__/menuRegistry-test.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { expect } from 'chai';
2-
import makeMenuRetistry from '../src/menuRegistry';
2+
3+
jest.dontMock('../src/menuRegistry');
4+
const makeMenuRegistry = require('../src/menuRegistry').default;
35

46
describe('menuRegistry tests', () => {
57

@@ -18,26 +20,26 @@ describe('menuRegistry tests', () => {
1820
};
1921

2022
it('should export function', () => {
21-
expect(makeMenuRetistry).to.be.a('function');
23+
expect(makeMenuRegistry).to.be.a('function');
2224
});
2325

2426
it('should create an object', () => {
25-
expect(makeMenuRetistry(new Map())).to.be.an('object');
27+
expect(makeMenuRegistry(new Map())).to.be.an('object');
2628
});
2729

2830
describe('getMenu', () => {
2931
it('should return menu', () => {
3032
const menus = new Map([
3133
[menu1.name, menu1]
3234
]);
33-
const registry = makeMenuRetistry(menus);
35+
const registry = makeMenuRegistry(menus);
3436
expect(registry.getMenu(menu1.name)).to.eql(menu1);
3537
});
3638
});
3739

3840
describe('subscribe', () => {
3941
it('should subscribe menu', () => {
40-
const registry = makeMenuRetistry();
42+
const registry = makeMenuRegistry();
4143
registry.subscribe(menu1.name, menu1);
4244
expect(registry.getMenu(menu1.name)).to.eql(menu1);
4345
});
@@ -49,7 +51,7 @@ describe('menuRegistry tests', () => {
4951
[menu1.name, menu1],
5052
[menu2.name, menu2]
5153
]);
52-
const registry = makeMenuRetistry(menus);
54+
const registry = makeMenuRegistry(menus);
5355
registry.unsubscribe(menu1.name);
5456
expect(registry.getMenu(menu1.name)).to.be.undefined;
5557
expect(registry.getMenu(menu2.name)).to.eql(menu2);
@@ -66,7 +68,7 @@ describe('menuRegistry tests', () => {
6668
triggerLayout: 5,
6769
optionsLayout: 6
6870
}]]);
69-
const registry = makeMenuRetistry(menus);
71+
const registry = makeMenuRegistry(menus);
7072
registry.update('menu3', {
7173
options: [7, 8],
7274
trigger: 'trigger3x',
@@ -91,7 +93,7 @@ describe('menuRegistry tests', () => {
9193
triggerLayout: 5,
9294
optionsLayout: 6
9395
}]]);
94-
const registry = makeMenuRetistry(menus);
96+
const registry = makeMenuRegistry(menus);
9597
registry.updateLayoutInfo('menu3', { optionsLayout: 7 });
9698
expect(registry.getMenu('menu3')).to.eql({
9799
name: 'menu3',
@@ -106,7 +108,7 @@ describe('menuRegistry tests', () => {
106108
triggerLayout: 5,
107109
optionsLayout: 6
108110
}]]);
109-
const registry = makeMenuRetistry(menus);
111+
const registry = makeMenuRegistry(menus);
110112
registry.updateLayoutInfo('menu3', { triggerLayout: 7 });
111113
expect(registry.getMenu('menu3')).to.eql({
112114
name: 'menu3',

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"example": "examples"
88
},
99
"scripts": {
10-
"test-mocha": "mocha --compilers js:babel-core/register",
11-
"test": "rm -rf ./node_modules/jest-cli/.haste_cache && jest",
10+
"test": "jest",
1211
"lint": "eslint ."
1312
},
1413
"repository": {
@@ -23,10 +22,15 @@
2322
"homepage": "https://github.com/instea/react-native-popup-menu",
2423
"jest": {
2524
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
26-
"testFileExtensions": [ "js" ],
27-
"moduleFileExtensions": [ "js" ],
25+
"testFileExtensions": [
26+
"js"
27+
],
28+
"moduleFileExtensions": [
29+
"js"
30+
],
2831
"unmockedModulePathPatterns": [
2932
"<rootDir>/node_modules/react",
33+
"<rootDir>/node_modules/chai",
3034
"<rootDir>/node_modules/fbjs"
3135
],
3236
"verbose": true,

src/menuRegistry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* optionsLayout: Object
1111
* }
1212
*/
13-
export default function makeMenuRetistry(menus = new Map()) {
13+
export default function makeMenuRegistry(menus = new Map()) {
1414

1515
/**
1616
* Subscribes menu by name.

test/mocha.opts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)