Skip to content

Commit

Permalink
Add test for single alias (#11296)
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Mar 23, 2020
1 parent c68de94 commit 541cd01
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 2 deletions.
5 changes: 5 additions & 0 deletions test/integration/jsconfig-paths/components/hello.js
@@ -0,0 +1,5 @@
import React from 'react'

export function Hello() {
return <>Hello</>
}
3 changes: 2 additions & 1 deletion test/integration/jsconfig-paths/jsconfig.json
Expand Up @@ -3,7 +3,8 @@
"baseUrl": ".",
"paths": {
"@c/*": ["components/*"],
"@lib/*": ["lib/a/*", "lib/b/*"]
"@lib/*": ["lib/a/*", "lib/b/*"],
"@mycomponent": ["components/hello.js"]
}
}
}
9 changes: 9 additions & 0 deletions test/integration/jsconfig-paths/pages/single-alias.js
@@ -0,0 +1,9 @@
import { Hello } from '@mycomponent'

export default function SingleAlias() {
return (
<div>
<Hello />
</div>
)
}
5 changes: 5 additions & 0 deletions test/integration/jsconfig-paths/test/index.test.js
Expand Up @@ -37,5 +37,10 @@ describe('TypeScript Features', () => {
const $ = await get$('/resolve-fallback')
expect($('body').text()).toMatch(/Hello from only b/)
})

it('should resolve a single matching alias', async () => {
const $ = await get$('/single-alias')
expect($('body').text()).toMatch(/Hello/)
})
})
})
5 changes: 5 additions & 0 deletions test/integration/typescript-paths/components/hello.tsx
@@ -0,0 +1,5 @@
import React from 'react'

export function Hello() {
return <>Hello</>
}
9 changes: 9 additions & 0 deletions test/integration/typescript-paths/pages/single-alias.tsx
@@ -0,0 +1,9 @@
import { Hello } from '@mycomponent'

export default function SingleAlias() {
return (
<div>
<Hello />
</div>
)
}
5 changes: 5 additions & 0 deletions test/integration/typescript-paths/test/index.test.js
Expand Up @@ -37,5 +37,10 @@ describe('TypeScript Features', () => {
const $ = await get$('/resolve-fallback')
expect($('body').text()).toMatch(/Hello from only b/)
})

it('should resolve a single matching alias', async () => {
const $ = await get$('/single-alias')
expect($('body').text()).toMatch(/Hello/)
})
})
})
3 changes: 2 additions & 1 deletion test/integration/typescript-paths/tsconfig.json
Expand Up @@ -3,7 +3,8 @@
"baseUrl": ".",
"paths": {
"@c/*": ["components/*"],
"@lib/*": ["lib/a/*", "lib/b/*"]
"@lib/*": ["lib/a/*", "lib/b/*"],
"@mycomponent": ["components/hello.tsx"]
},
"esModuleInterop": true,
"module": "esnext",
Expand Down

0 comments on commit 541cd01

Please sign in to comment.