-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
389 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
/*import React from 'react'; | ||
import addBar from './index';*/ | ||
|
||
const React = require('react'); | ||
const addBar = require('./index').default; | ||
import React from 'react'; | ||
import addBar from './index'; | ||
|
||
class SomeComponent extends React.Component { | ||
render() { | ||
return React.createElement('div', null, addBar(this.props.value)); | ||
} | ||
render() { | ||
return React.createElement('div', null, addBar(this.props.value)); | ||
} | ||
} | ||
|
||
module.exports.default = SomeComponent; | ||
// export default SomeComponent; | ||
// export default SomeComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
//import * as bar from 'anotherRoot/bar'; | ||
const bar = require('anotherRoot/bar'); | ||
import bar from 'anotherRoot/bar'; | ||
|
||
function addBar(y) { | ||
// ESM: | ||
return bar.default() + y; | ||
function addBar(y) { | ||
return bar() + y; | ||
} | ||
|
||
//export default addBar; | ||
module.exports.default = addBar; | ||
export default addBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
transform: { | ||
'\\.m?js$': '<rootDir>/node_modules/esm/esm.js' | ||
}, | ||
moduleNameMapper: { | ||
'^anotherRoot/(.*)$': '<rootDir>/lib/anotherRoot/$1' | ||
}, | ||
transformIgnorePatterns: [] | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
{ | ||
"name": "esm-jest", | ||
"scripts": { | ||
"test": "node node_modules/jest/bin/jest.js --runInBand --no-cache --config jestconfig.js" | ||
}, | ||
"directories": { | ||
"test": "test" | ||
"test": "node -r esm node_modules/jest/bin/jest.js --runInBand --no-cache --config jest.config.js" | ||
}, | ||
"dependencies": { | ||
"esm": "3.0.12", | ||
"esm": "3.1.0", | ||
"enzyme": "3.3.0", | ||
"enzyme-adapter-react-16": "1.1.1", | ||
"react": "16.3.0", | ||
"react-dom": "16.3.0" | ||
}, | ||
"devDependencies": { | ||
"jest": "^22.4.3" | ||
"jest": "^23.6.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
/* | ||
import React from 'react'; | ||
import Enzyme from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
import { shallow } from 'enzyme'; | ||
import SomeComponent from '../../SomeComponent'; | ||
import * as bar from 'anotherRoot/bar'; | ||
*/ | ||
|
||
const React = require('react'); | ||
const Enzyme = require('enzyme'); | ||
const Adapter = require('enzyme-adapter-react-16'); | ||
|
||
const shallow = Enzyme.shallow; | ||
|
||
const SomeComponent = require('../../SomeComponent').default; | ||
const bar = require('anotherRoot/bar'); | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
describe('SomeComponent', () => { | ||
it('should test component', () => { | ||
spyOn(bar, 'default').and.returnValue(7); | ||
const wrapper = shallow(React.createElement(SomeComponent, {value: 1})); | ||
expect(wrapper.text()).toBe('8'); | ||
}); | ||
}); | ||
it('should test component', () => { | ||
spyOn(bar, 'default').and.returnValue(7); | ||
const wrapper = shallow(React.createElement(SomeComponent, { value: 1 })); | ||
expect(wrapper.text()).toBe('8'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
/* | ||
import { addBar } from '../../index'; | ||
import * as bar from 'anotherRoot/bar'; | ||
*/ | ||
|
||
const bar = require('anotherRoot/bar'); | ||
const addBar = require('../../index').default; | ||
|
||
test('addBar should be add five', () => { | ||
expect(addBar(2)).toBe(7); | ||
expect(addBar(2)).toBe(7); | ||
}); | ||
|
||
test('addBar should be add another number', () => { | ||
spyOn(bar, 'default').and.returnValue(6); | ||
expect(addBar(2)).toBe(8); | ||
spyOn(bar, 'default').and.returnValue(6); | ||
expect(addBar(2)).toBe(8); | ||
}); | ||
|
Oops, something went wrong.