Skip to content

Commit

Permalink
Fix warnings in CLI destroy tests (#6455)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Choudhury <[email protected]>
  • Loading branch information
Josh-Walker-GM and dac09 authored Sep 27, 2022
1 parent 45759fe commit fbfd467
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
31 changes: 14 additions & 17 deletions packages/cli/src/commands/destroy/cell/__tests__/cell.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ import '../../../../lib/test'
import { files } from '../../../generate/cell/cell'
import { tasks } from '../cell'

beforeEach(() => {
fs.__setMockFiles(files({ name: 'User' }))
})

afterEach(() => {
fs.__setMockFiles({})
jest.spyOn(fs, 'unlinkSync').mockClear()
})

test('destroys cell files', async () => {
fs.__setMockFiles(await files({ name: 'User' }))
const unlinkSpy = jest.spyOn(fs, 'unlinkSync')
const t = tasks({
componentName: 'cell',
Expand All @@ -41,15 +38,15 @@ test('destroys cell files', async () => {
})
t.setRenderer('silent')

return t.run().then(() => {
const generatedFiles = Object.keys(files({ name: 'User' }))
expect(generatedFiles.length).toEqual(unlinkSpy.mock.calls.length)
generatedFiles.forEach((f) => expect(unlinkSpy).toHaveBeenCalledWith(f))
})
await t.run()

const generatedFiles = Object.keys(await files({ name: 'User' }))
expect(generatedFiles.length).toEqual(unlinkSpy.mock.calls.length)
generatedFiles.forEach((f) => expect(unlinkSpy).toHaveBeenCalledWith(f))
})

test('destroys cell files with stories and tests', async () => {
fs.__setMockFiles(files({ name: 'User', stories: true, tests: true }))
fs.__setMockFiles(await files({ name: 'User', stories: true, tests: true }))
const unlinkSpy = jest.spyOn(fs, 'unlinkSync')
const t = tasks({
componentName: 'cell',
Expand All @@ -60,11 +57,11 @@ test('destroys cell files with stories and tests', async () => {
})
t.setRenderer('silent')

return t.run().then(() => {
const generatedFiles = Object.keys(
files({ name: 'User', stories: true, tests: true })
)
expect(generatedFiles.length).toEqual(unlinkSpy.mock.calls.length)
generatedFiles.forEach((f) => expect(unlinkSpy).toHaveBeenCalledWith(f))
})
await t.run()

const generatedFiles = Object.keys(
await files({ name: 'User', stories: true, tests: true })
)
expect(generatedFiles.length).toEqual(unlinkSpy.mock.calls.length)
generatedFiles.forEach((f) => expect(unlinkSpy).toHaveBeenCalledWith(f))
})
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { files } from '../../../generate/function/function'
import { tasks } from '../function'

beforeEach(async () => {
fs.__setMockFiles(await files({ name: 'sendMail' }))
fs.__setMockFiles(files({ name: 'sendMail' }))
})

afterEach(() => {
Expand All @@ -33,7 +33,7 @@ test('destroys service files', async () => {
t.setRenderer('silent')

return t.run().then(async () => {
const generatedFiles = Object.keys(await files({ name: 'sendMail' }))
const generatedFiles = Object.keys(files({ name: 'sendMail' }))
expect(generatedFiles.length).toEqual(unlinkSpy.mock.calls.length)
generatedFiles.forEach((f) => expect(unlinkSpy).toHaveBeenCalledWith(f))
})
Expand Down

0 comments on commit fbfd467

Please sign in to comment.