Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterp committed Aug 31, 2020
1 parent 6a87cd2 commit f882d15
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,20 @@ describe('babel plugin redwood import dir', () => {
})

afterAll(() => {
expect(mockWriteFileSync.mock.calls[0]).toMatchInlineSnapshot(`
Array [
/fake/project/node_modules/@types/@redwoodjs/generated/import-dir-services.d.ts,
// @ts-expect-error
declare module 'src/__fixtures__/**/*.{js,ts}';
,
]
`)
expect(mockWriteFileSync.mock.calls[0][1]).toContain(
`/fake/project/node_modules/@types/@redwoodjs/generated/import-dir-services.d.ts`
)

expect(mockWriteFileSync.mock.calls[1]).toMatchInlineSnapshot(`
Array [
/fake/project/node_modules/@types/@redwoodjs/index.d.ts,
/// <reference path="./generated/import-dir-services.d.ts" />
/// <reference path="./generated/import-dir-graphql.d.ts" />,
]
`)
expect(mockWriteFileSync.mock.calls[0][1]).toContain(
`declare module 'src/__fixtures__/**/*.{js,ts}'`
)

expect(mockWriteFileSync.mock.calls[1][0]).toContain(
`/fake/project/node_modules/@types/@redwoodjs/index.d.ts`
)
expect(mockWriteFileSync.mock.calls[1][1]).toContain(
`/// <reference path="./types/import-dir-services.d.ts" />`
)

jest.clearAllMocks()
})
Expand Down
11 changes: 9 additions & 2 deletions packages/core/src/babelPlugins/__tests__/generateTypes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@ jest.mock('@redwoodjs/structure', () => {
})

test('generates index.d.ts file correctly', () => {
const oldDate = global.Date
global.Date = class {
toISOString = () => '2020-03-08'
}
generateTypeDefIndex()

expect(mockWriteFileSync.mock.calls[0][0]).toMatchInlineSnapshot(
`"/fake/project/node_modules/@types/@redwoodjs/index.d.ts"`
)
expect(mockWriteFileSync.mock.calls[0][1]).toMatchInlineSnapshot(`
"/// <reference path=\\"./generated/import-dir-service.d.ts\\" />
/// <reference path=\\"./generated/import-dir-graphql.d.ts\\" />"
"// 2020-03-08
/// <reference path=\\"./types/import-dir-service.d.ts\\" />
/// <reference path=\\"./types/import-dir-graphql.d.ts\\" />"
`)

global.Date = oldDate
})

0 comments on commit f882d15

Please sign in to comment.