Fix broken tests
This commit is contained in:
parent
5b5adb6408
commit
6a456eb6e8
@ -41,6 +41,7 @@ export class TeamManager extends React.PureComponent<ITeamManagerProps> {
|
|||||||
const action = this.props.createTeam(team)
|
const action = this.props.createTeam(team)
|
||||||
action.payload
|
action.payload
|
||||||
.then(() => this.props.history.push('/teams'))
|
.then(() => this.props.history.push('/teams'))
|
||||||
|
.catch(() => {/* do nothing */})
|
||||||
return action
|
return action
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
@ -31,10 +31,14 @@ export class TestUtils {
|
|||||||
readonly createStore = createStore
|
readonly createStore = createStore
|
||||||
|
|
||||||
render(jsx: JSX.Element) {
|
render(jsx: JSX.Element) {
|
||||||
const component = T
|
const $div = document.createElement('div')
|
||||||
.renderIntoDocument(jsx) as unknown as React.Component<any>
|
const component = ReactDOM.render(
|
||||||
const node = ReactDOM.findDOMNode(component) as Element
|
<div>{jsx}</div>, $div) as unknown as React.Component<any>
|
||||||
return {component, node}
|
const node = (ReactDOM.findDOMNode(component) as Element).children[0]
|
||||||
|
return {
|
||||||
|
component,
|
||||||
|
node,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
combineReducers<S>(reducers: ReducersMapObject<S, any>): Reducer<S>
|
combineReducers<S>(reducers: ReducersMapObject<S, any>): Reducer<S>
|
||||||
|
|||||||
@ -26,8 +26,8 @@ export class Subprocess {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (this.stdio === StdioOptions.PIPE) {
|
if (this.stdio === StdioOptions.PIPE) {
|
||||||
subprocess.stdout.on('data', data => process.stdout.write(data))
|
subprocess.stdout!.on('data', data => process.stdout.write(data))
|
||||||
subprocess.stderr.on('data', data => process.stderr.write(data))
|
subprocess.stderr!.on('data', data => process.stderr.write(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
subprocess.on('close', code => {
|
subprocess.on('close', code => {
|
||||||
|
|||||||
@ -10,9 +10,10 @@ describe('update', () => {
|
|||||||
|
|
||||||
const stringify = (obj: object) => JSON.stringify(obj, null, ' ')
|
const stringify = (obj: object) => JSON.stringify(obj, null, ' ')
|
||||||
|
|
||||||
const readMock = fs.readFileSync as jest.Mock<typeof fs.readFileSync>
|
const readMock =
|
||||||
|
fs.readFileSync as unknown as jest.Mock<typeof fs.readFileSync>
|
||||||
const writeMock = fs.writeFileSync as jest.Mock<typeof fs.writeFileSync>
|
const writeMock = fs.writeFileSync as jest.Mock<typeof fs.writeFileSync>
|
||||||
const cpMock = cp.execFileSync as jest.Mock<typeof cp.execFileSync>
|
const cpMock = cp.execFileSync as unknown as jest.Mock<typeof cp.execFileSync>
|
||||||
|
|
||||||
let outdated: Record<string, IOutdated> = {}
|
let outdated: Record<string, IOutdated> = {}
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -35,17 +36,17 @@ describe('update', () => {
|
|||||||
devDependencies: {
|
devDependencies: {
|
||||||
b: '^3.4.6',
|
b: '^3.4.6',
|
||||||
},
|
},
|
||||||
}))
|
}) as any)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not change when no changes', async () => {
|
it('does not change when no changes', async () => {
|
||||||
cpMock.mockReturnValue('{}')
|
cpMock.mockReturnValue('{}' as any)
|
||||||
await update('update', '/my/dir')
|
await update('update', '/my/dir')
|
||||||
expect(writeMock.mock.calls.length).toBe(0)
|
expect(writeMock.mock.calls.length).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not change when npm outdated output is empty', async () => {
|
it('does not change when npm outdated output is empty', async () => {
|
||||||
cpMock.mockReturnValue('')
|
cpMock.mockReturnValue('' as any)
|
||||||
await update('update', '/my/dir')
|
await update('update', '/my/dir')
|
||||||
expect(writeMock.mock.calls.length).toBe(0)
|
expect(writeMock.mock.calls.length).toBe(0)
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user