Skip to content

Commit

Permalink
test(resolve): add a test for resolving nested extension (#12473)
Browse files Browse the repository at this point in the history
  • Loading branch information
sun0day authored Mar 18, 2023
1 parent 79a5007 commit 07aa155
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions playground/resolve/__tests__/resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ test('implicit dir/index.js vs explicit file', async () => {
expect(await page.textContent('.dir-vs-file')).toMatch('[success]')
})

test('nested extension', async () => {
expect(await page.textContent('.nested-extension')).toMatch(
'[success] file.json.js',
)
})

test('exact extension vs. duplicated (.js.js)', async () => {
expect(await page.textContent('.exact-extension')).toMatch('[success]')
})
Expand Down
1 change: 1 addition & 0 deletions playground/resolve/exact-extension/file.json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const file = '[success] file.json.js'
9 changes: 8 additions & 1 deletion playground/resolve/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ <h2>Resolve dir and file of the same name (should prioritize file)</h2>
<h2>Resolve to non-duplicated file extension</h2>
<p class="exact-extension">fail</p>

<h2>Resolve nested file extension</h2>
<p class="nested-extension">fail</p>

<h2>Don't add extensions to directory names</h2>
<p class="dir-with-ext">fail</p>

Expand Down Expand Up @@ -232,10 +235,14 @@ <h2>resolve package that contains # in path</h2>
import { file } from './dir'
text('.dir-vs-file', file)

// // exact extension vs. duplicated (.js.js)
// exact extension vs. duplicated (.js.js)
import { file as exactExtMsg } from './exact-extension/file.js'
text('.exact-extension', exactExtMsg)

// nested extension
import { file as fileJsonMsg } from './exact-extension/file.json'
text('.nested-extension', fileJsonMsg)

// don't add extensions to dir name (./dir-with-ext.js/index.js)
import { file as dirWithExtMsg } from './dir-with-ext'
text('.dir-with-ext', dirWithExtMsg)
Expand Down

0 comments on commit 07aa155

Please sign in to comment.