Skip to content

Commit

Permalink
test(resolve): cover the codes that parse the fs path contained postf…
Browse files Browse the repository at this point in the history
…ix (#12436)
  • Loading branch information
sun0day authored Mar 16, 2023
1 parent ce047e3 commit 4b587b0
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion playground/resolve/__tests__/resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ test('resolve.conditions', async () => {

test('resolve package that contains # in path', async () => {
expect(await page.textContent('.path-contains-sharp-symbol')).toMatch(
'[success] true',
'[success] true #',
)
})

Expand Down
6 changes: 5 additions & 1 deletion playground/resolve/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,12 @@ <h2>resolve package that contains # in path</h2>

import es5Ext from 'es5-ext'
import contains from 'es5-ext/string/#/contains'
import { last } from '@vitejs/test-resolve-sharp-dir'

text('.path-contains-sharp-symbol', `[success] ${contains.call('#', '#')}`)
text(
'.path-contains-sharp-symbol',
`[success] ${contains.call('#', '#')} ${last.call('#')}`,
)
</script>

<style>
Expand Down
3 changes: 2 additions & 1 deletion playground/resolve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@vitejs/test-resolve-exports-path": "link:./exports-path",
"@vitejs/test-resolve-exports-with-module": "link:./exports-with-module",
"@vitejs/test-resolve-linked": "workspace:*",
"@vitejs/test-resolve-imports-pkg": "link:./imports-path/other-pkg"
"@vitejs/test-resolve-imports-pkg": "link:./imports-path/other-pkg",
"@vitejs/test-resolve-sharp-dir": "link:./sharp-dir"
}
}
3 changes: 3 additions & 0 deletions playground/resolve/sharp-dir/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
last: require('es5-ext/string/#/last.js'),
}
9 changes: 9 additions & 0 deletions playground/resolve/sharp-dir/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@vitejs/test-resolve-sharp-dir",
"private": true,
"version": "1.0.0",
"main": "./index.cjs",
"dependencies": {
"es5-ext": "0.10.62"
}
}
5 changes: 4 additions & 1 deletion playground/resolve/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ export default defineConfig({
},
],
optimizeDeps: {
include: ['@vitejs/test-require-pkg-with-module-field'],
include: [
'@vitejs/test-require-pkg-with-module-field',
'@vitejs/test-resolve-sharp-dir',
],
},
})
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4b587b0

Please sign in to comment.