Skip to content

Commit

Permalink
Merge branch 'master' into deploy_cicd_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
purplecabbage authored Aug 5, 2021
2 parents e22e082 + 6214800 commit 305b93f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/lib/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Cleanup {
*/
// if (this.resources.length < 1) {
const dummyProc = execa('node')
this.add(async () => (await dummyProc).kill(), 'stopping sigint waiter...')
this.add(async () => await dummyProc.kill(), 'stopping sigint waiter...')
// }
// bind cleanup function
process.on('SIGINT', async () => {
Expand Down
22 changes: 8 additions & 14 deletions test/commands/lib/cleanup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ process.exit = jest.fn()
process.on = jest.fn()

let theCleanup
const mockKill = jest.fn()

beforeEach(() => {
theCleanup = new Cleanup()
mockLogger.mockReset()
process.exit.mockReset()
process.on.mockReset()
execa.mockReset()
mockKill.mockReset()

execa.mockImplementation(() => {
const p = new Promise(resolve => resolve(0))
p.kill = mockKill // execa puts properties on the returned Promise
return p
})
})

test('exports', () => {
Expand Down Expand Up @@ -65,13 +73,6 @@ test('wait (cleanup no errors)', async () => {
const fn1 = jest.fn()
const fn2 = jest.fn()

const mockKill = jest.fn()
execa.mockImplementation(async () => {
return {
kill: mockKill
}
})

process.exit.mockImplementation((code) => {
expect(code).toEqual(0) // ok
})
Expand Down Expand Up @@ -99,13 +100,6 @@ test('wait (cleanup has error)', async () => {
throw new Error('error')
})

const mockKill = jest.fn()
execa.mockImplementation(async () => {
return {
kill: mockKill
}
})

process.exit.mockImplementation((code) => {
expect(code).toEqual(1) // error
})
Expand Down

0 comments on commit 305b93f

Please sign in to comment.