Skip to content

Commit

Permalink
chore(tests): Fix TS errors in paths tests (#11883)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Jan 7, 2025
1 parent 73e241f commit 5e1ba7e
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions packages/project-config/src/__tests__/paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ describe('paths', () => {
(page) => page.importName === 'FatalErrorPage',
)
expect(fatalErrorPage).not.toBeUndefined()
expect(fatalErrorPage.importPath).toEqual(
expect(fatalErrorPage?.importPath).toEqual(
importStatementPath(
path.join(pagesDir, 'FatalErrorPage/FatalErrorPage'),
),
Expand All @@ -197,14 +197,15 @@ describe('paths', () => {
(page) => page.importName === 'NotFoundPage',
)
expect(notFoundPage).not.toBeUndefined()
expect(notFoundPage.importPath).toEqual(
expect(notFoundPage?.importPath).toEqual(
importStatementPath(path.join(pagesDir, 'NotFoundPage/NotFoundPage')),
)
})
})

test('resolveFile', () => {
const p = resolveFile(path.join(FIXTURE_BASEDIR, 'web', 'src', 'App'))
const p =
resolveFile(path.join(FIXTURE_BASEDIR, 'web', 'src', 'App')) || ''
expect(path.extname(p)).toEqual('.tsx')

const q = resolveFile(
Expand Down Expand Up @@ -325,53 +326,53 @@ describe('paths', () => {
(page) => page.importName === 'adminEditUserPage',
)
expect(adminEditUserPage).not.toBeUndefined()
expect(adminEditUserPage.importPath).toEqual(
expect(adminEditUserPage?.importPath).toEqual(
importStatementPath(
path.join(pagesDir, 'admin/EditUserPage/EditUserPage'),
),
)

const barPage = pages.find((page) => page.importName === 'BarPage')
expect(barPage).not.toBeUndefined()
expect(barPage.importPath).toEqual(
expect(barPage?.importPath).toEqual(
importStatementPath(path.join(pagesDir, 'BarPage/BarPage')),
)

const fatalErrorPage = pages.find(
(page) => page.importName === 'FatalErrorPage',
)
expect(fatalErrorPage).not.toBeUndefined()
expect(fatalErrorPage.importPath).toEqual(
expect(fatalErrorPage?.importPath).toEqual(
importStatementPath(
path.join(pagesDir, 'FatalErrorPage/FatalErrorPage'),
),
)

const fooPage = pages.find((page) => page.importName === 'FooPage')
expect(fooPage).not.toBeUndefined()
expect(fooPage.importPath).toEqual(
expect(fooPage?.importPath).toEqual(
importStatementPath(path.join(pagesDir, 'FooPage/FooPage')),
)

const homePage = pages.find((page) => page.importName === 'HomePage')
expect(homePage).not.toBeUndefined()
expect(homePage.importPath).toEqual(
expect(homePage?.importPath).toEqual(
importStatementPath(path.join(pagesDir, 'HomePage/HomePage')),
)

const notFoundPage = pages.find(
(page) => page.importName === 'NotFoundPage',
)
expect(notFoundPage).not.toBeUndefined()
expect(notFoundPage.importPath).toEqual(
expect(notFoundPage?.importPath).toEqual(
importStatementPath(path.join(pagesDir, 'NotFoundPage/NotFoundPage')),
)

const typeScriptPage = pages.find(
(page) => page.importName === 'TypeScriptPage',
)
expect(typeScriptPage).not.toBeUndefined()
expect(typeScriptPage.importPath).toEqual(
expect(typeScriptPage?.importPath).toEqual(
importStatementPath(
path.join(pagesDir, 'TypeScriptPage/TypeScriptPage'),
),
Expand All @@ -381,14 +382,15 @@ describe('paths', () => {
(page) => page.importName === 'PrivatePage',
)
expect(privatePage).not.toBeUndefined()
expect(privatePage.importPath).toEqual(
expect(privatePage?.importPath).toEqual(
importStatementPath(path.join(pagesDir, 'PrivatePage/PrivatePage')),
)
})
})

test('resolveFile', () => {
const p = resolveFile(path.join(FIXTURE_BASEDIR, 'web', 'src', 'App'))
const p =
resolveFile(path.join(FIXTURE_BASEDIR, 'web', 'src', 'App')) || ''
expect(path.extname(p)).toEqual('.js')

const q = resolveFile(
Expand Down Expand Up @@ -510,30 +512,31 @@ describe('paths', () => {
(page) => page.importName === 'FatalErrorPage',
)
expect(fatalErrorPage).not.toBeUndefined()
expect(fatalErrorPage.importPath).toEqual(
expect(fatalErrorPage?.importPath).toEqual(
importStatementPath(
path.join(pagesDir, 'FatalErrorPage/FatalErrorPage'),
),
)

const homePage = pages.find((page) => page.importName === 'HomePage')
expect(homePage).not.toBeUndefined()
expect(homePage.importPath).toEqual(
expect(homePage?.importPath).toEqual(
importStatementPath(path.join(pagesDir, 'HomePage/HomePage')),
)

const notFoundPage = pages.find(
(page) => page.importName === 'NotFoundPage',
)
expect(notFoundPage).not.toBeUndefined()
expect(notFoundPage.importPath).toEqual(
expect(notFoundPage?.importPath).toEqual(
importStatementPath(path.join(pagesDir, 'NotFoundPage/NotFoundPage')),
)
})
})

test('resolveFile', () => {
const p = resolveFile(path.join(FIXTURE_BASEDIR, 'web', 'src', 'index'))
const p =
resolveFile(path.join(FIXTURE_BASEDIR, 'web', 'src', 'index')) || ''
expect(path.extname(p)).toEqual('.js')

const q = resolveFile(
Expand Down Expand Up @@ -666,7 +669,7 @@ describe('paths', () => {
pageNames.forEach((pageName) => {
const thisPage = pages.find((page) => page.importName === pageName)
expect(thisPage).not.toBeUndefined()
expect(thisPage.importPath).toEqual(
expect(thisPage?.importPath).toEqual(
importStatementPath(path.join(pagesDir, `${pageName}/${pageName}`)),
)
})
Expand All @@ -678,7 +681,7 @@ describe('paths', () => {
(page) => page.importName === `${pageName}Edit${pageName}Page`,
)
expect(page).not.toBeUndefined()
expect(page.importPath).toEqual(
expect(page?.importPath).toEqual(
importStatementPath(
path.join(
pagesDir,
Expand All @@ -691,7 +694,7 @@ describe('paths', () => {
(page) => page.importName === `${pageName}New${pageName}Page`,
)
expect(page).not.toBeUndefined()
expect(page.importPath).toEqual(
expect(page?.importPath).toEqual(
importStatementPath(
path.join(
pagesDir,
Expand All @@ -704,7 +707,7 @@ describe('paths', () => {
(page) => page.importName === `${pageName}${pageName}Page`,
)
expect(page).not.toBeUndefined()
expect(page.importPath).toEqual(
expect(page?.importPath).toEqual(
importStatementPath(
path.join(
pagesDir,
Expand All @@ -717,7 +720,7 @@ describe('paths', () => {
(page) => page.importName === `${pageName}${pageName}sPage`,
)
expect(page).not.toBeUndefined()
expect(page.importPath).toEqual(
expect(page?.importPath).toEqual(
importStatementPath(
path.join(
pagesDir,
Expand All @@ -730,7 +733,8 @@ describe('paths', () => {
})

test('resolveFile', () => {
const p = resolveFile(path.join(FIXTURE_BASEDIR, 'web', 'src', 'Routes'))
const p =
resolveFile(path.join(FIXTURE_BASEDIR, 'web', 'src', 'Routes')) || ''
expect(path.extname(p)).toEqual('.tsx')

const q = resolveFile(
Expand Down

0 comments on commit 5e1ba7e

Please sign in to comment.