Fix compile errors

This commit is contained in:
Jerko Steiner 2019-10-31 20:09:39 -04:00
parent 1bd19286fa
commit cef39b2edd
5 changed files with 18 additions and 49 deletions

View File

@ -134,7 +134,8 @@ export class AddUser extends React.PureComponent<AddUserProps, AddUserState> {
export class TeamUserList extends React.PureComponent<TeamUsersProps> { export class TeamUserList extends React.PureComponent<TeamUsersProps> {
async componentDidMount() { async componentDidMount() {
await this.fetchUsersInTeam(this.props.team.id) await this.fetchUsersInTeam(this.props.team.id)
} async componentWillReceiveProps(nextProps: TeamUsersProps) { }
async componentWillReceiveProps(nextProps: TeamUsersProps) {
const {team} = nextProps const {team} = nextProps
if (team.id !== this.props.team.id) { if (team.id !== this.props.team.id) {
this.fetchUsersInTeam(team.id) this.fetchUsersInTeam(team.id)

View File

@ -4,7 +4,7 @@ jest.mock('../log')
import cp from 'child_process' import cp from 'child_process'
import * as fs from 'fs' import * as fs from 'fs'
import {update, Outdated} from './update' import {update} from './update'
describe('update', () => { describe('update', () => {
@ -15,19 +15,12 @@ describe('update', () => {
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 unknown as jest.Mock<typeof cp.execFileSync> const cpMock = cp.execFileSync as unknown as jest.Mock<typeof cp.execFileSync>
let outdated: Record<string, Outdated> = {}
beforeEach(() => { beforeEach(() => {
outdated = {}
cpMock.mockClear() cpMock.mockClear()
readMock.mockClear() readMock.mockClear()
writeMock.mockClear() writeMock.mockClear()
cpMock.mockImplementation(() => { cpMock.mockImplementation(() => Buffer.from('7.8.9\n') as any)
const err = new Error('Exit code 1');
(err as any).stdout = stringify(outdated)
throw err
})
readMock.mockReturnValue(stringify({ readMock.mockReturnValue(stringify({
name: 'test', name: 'test',
dependencies: { dependencies: {
@ -39,43 +32,30 @@ describe('update', () => {
}) as any) }) as any)
}) })
it('does not change when no changes', async () => {
cpMock.mockReturnValue('{}' as any)
await update('update', '/my/dir')
expect(writeMock.mock.calls.length).toBe(0)
})
it('does not change when npm outdated output is empty', async () => {
cpMock.mockReturnValue('' as any)
await update('update', '/my/dir')
expect(writeMock.mock.calls.length).toBe(0)
})
it('updates outdated dependencies in package.json', async () => { it('updates outdated dependencies in package.json', async () => {
outdated = {
a: {
wanted: '1.2.3',
latest: '1.4.0',
location: '',
},
b: {
wanted: '3.4.6',
latest: '3.4.7',
location: '',
},
}
await update('update', '/my/dir') await update('update', '/my/dir')
expect(writeMock.mock.calls).toEqual([[ expect(writeMock.mock.calls).toEqual([[
'/my/dir/package.json', stringify({ '/my/dir/package.json', stringify({
name: 'test', name: 'test',
dependencies: { dependencies: {
a: '^1.4.0', a: '^7.8.9',
}, },
devDependencies: { devDependencies: {
b: '^3.4.7', b: '^7.8.9',
}, },
}), }),
]]) ]])
}) })
it('does not fail when package has no deps', async () => {
readMock.mockReturnValue(stringify({}) as any)
await update('update', '/my/dir')
})
it('does not write when dryRun', async () => {
readMock.mockReturnValue(stringify({}) as any)
await update('update', '--dryRun', '/my/dir')
expect(writeMock.mock.calls.length).toBe(0)
})
}) })

View File

@ -4,12 +4,6 @@ import cp from 'child_process'
import {argparse, arg} from '@rondo.dev/argparse' import {argparse, arg} from '@rondo.dev/argparse'
import {info} from '../log' import {info} from '../log'
export interface Outdated {
wanted: string
latest: string
location: string
}
export interface Package { export interface Package {
dependencies?: Record<string, string> dependencies?: Record<string, string>
devDependencies?: Record<string, string> devDependencies?: Record<string, string>

View File

@ -1,16 +1,13 @@
declare namespace Application { declare namespace Express {
export interface User { export interface User {
id: number id: number
username: string username: string
firstName: string firstName: string
lastName: string lastName: string
} }
}
declare namespace Express {
export interface Request { export interface Request {
correlationId: string correlationId: string
user?: Application.User
logInPromise(user: any): Promise<void> logInPromise(user: any): Promise<void>
} }
} }

View File

@ -14,9 +14,6 @@
{ {
"path": "../common" "path": "../common"
}, },
{
"path": "../common"
},
{ {
"path": "../config" "path": "../config"
}, },