diff --git a/test/helpers.tests.js b/__tests__/helpers-test.js similarity index 92% rename from test/helpers.tests.js rename to __tests__/helpers-test.js index 96a5bb1..d69365f 100644 --- a/test/helpers.tests.js +++ b/__tests__/helpers-test.js @@ -1,5 +1,7 @@ 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', () => { @@ -32,14 +34,10 @@ describe('helpers test', () => { it('should return unique names', () => { const name1 = makeName(), - name2 = makeName(), - name3 = require('../src/helpers').makeName(); + name2 = makeName(); expect(name1).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(name3); - expect(name2).not.to.be.equal(name3); }); }); diff --git a/test/menuRetistry.tests.js b/__tests__/menuRegistry-test.js similarity index 84% rename from test/menuRetistry.tests.js rename to __tests__/menuRegistry-test.js index 43a4135..6fa132f 100644 --- a/test/menuRetistry.tests.js +++ b/__tests__/menuRegistry-test.js @@ -1,5 +1,7 @@ import { expect } from 'chai'; -import makeMenuRetistry from '../src/menuRegistry'; + +jest.dontMock('../src/menuRegistry'); +const makeMenuRegistry = require('../src/menuRegistry').default; describe('menuRegistry tests', () => { @@ -18,11 +20,11 @@ describe('menuRegistry tests', () => { }; it('should export function', () => { - expect(makeMenuRetistry).to.be.a('function'); + expect(makeMenuRegistry).to.be.a('function'); }); it('should create an object', () => { - expect(makeMenuRetistry(new Map())).to.be.an('object'); + expect(makeMenuRegistry(new Map())).to.be.an('object'); }); describe('getMenu', () => { @@ -30,14 +32,14 @@ describe('menuRegistry tests', () => { const menus = new Map([ [menu1.name, menu1] ]); - const registry = makeMenuRetistry(menus); + const registry = makeMenuRegistry(menus); expect(registry.getMenu(menu1.name)).to.eql(menu1); }); }); describe('subscribe', () => { it('should subscribe menu', () => { - const registry = makeMenuRetistry(); + const registry = makeMenuRegistry(); registry.subscribe(menu1.name, menu1); expect(registry.getMenu(menu1.name)).to.eql(menu1); }); @@ -49,7 +51,7 @@ describe('menuRegistry tests', () => { [menu1.name, menu1], [menu2.name, menu2] ]); - const registry = makeMenuRetistry(menus); + const registry = makeMenuRegistry(menus); registry.unsubscribe(menu1.name); expect(registry.getMenu(menu1.name)).to.be.undefined; expect(registry.getMenu(menu2.name)).to.eql(menu2); @@ -66,7 +68,7 @@ describe('menuRegistry tests', () => { triggerLayout: 5, optionsLayout: 6 }]]); - const registry = makeMenuRetistry(menus); + const registry = makeMenuRegistry(menus); registry.update('menu3', { options: [7, 8], trigger: 'trigger3x', @@ -91,7 +93,7 @@ describe('menuRegistry tests', () => { triggerLayout: 5, optionsLayout: 6 }]]); - const registry = makeMenuRetistry(menus); + const registry = makeMenuRegistry(menus); registry.updateLayoutInfo('menu3', { optionsLayout: 7 }); expect(registry.getMenu('menu3')).to.eql({ name: 'menu3', @@ -106,7 +108,7 @@ describe('menuRegistry tests', () => { triggerLayout: 5, optionsLayout: 6 }]]); - const registry = makeMenuRetistry(menus); + const registry = makeMenuRegistry(menus); registry.updateLayoutInfo('menu3', { triggerLayout: 7 }); expect(registry.getMenu('menu3')).to.eql({ name: 'menu3', diff --git a/package.json b/package.json index 9f87fa4..b4a5795 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,7 @@ "example": "examples" }, "scripts": { - "test-mocha": "mocha --compilers js:babel-core/register", - "test": "rm -rf ./node_modules/jest-cli/.haste_cache && jest", + "test": "jest", "lint": "eslint ." }, "repository": { @@ -23,10 +22,15 @@ "homepage": "https://github.com/instea/react-native-popup-menu", "jest": { "scriptPreprocessor": "/node_modules/babel-jest", - "testFileExtensions": [ "js" ], - "moduleFileExtensions": [ "js" ], + "testFileExtensions": [ + "js" + ], + "moduleFileExtensions": [ + "js" + ], "unmockedModulePathPatterns": [ "/node_modules/react", + "/node_modules/chai", "/node_modules/fbjs" ], "verbose": true, diff --git a/src/menuRegistry.js b/src/menuRegistry.js index 494a36f..e6d161d 100644 --- a/src/menuRegistry.js +++ b/src/menuRegistry.js @@ -10,7 +10,7 @@ * optionsLayout: Object * } */ -export default function makeMenuRetistry(menus = new Map()) { +export default function makeMenuRegistry(menus = new Map()) { /** * Subscribes menu by name. diff --git a/test/mocha.opts b/test/mocha.opts deleted file mode 100644 index 4a52320..0000000 --- a/test/mocha.opts +++ /dev/null @@ -1 +0,0 @@ ---recursive