From 8a5cd3dbe88c2d9c436c52d831b97392637005f8 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 23 Mar 2020 17:08:10 +0100 Subject: [PATCH] Add test for single alias --- test/integration/jsconfig-paths/components/hello.js | 5 +++++ test/integration/jsconfig-paths/jsconfig.json | 3 ++- test/integration/jsconfig-paths/pages/single-alias.js | 9 +++++++++ test/integration/jsconfig-paths/test/index.test.js | 5 +++++ test/integration/typescript-paths/components/hello.tsx | 5 +++++ test/integration/typescript-paths/pages/single-alias.tsx | 9 +++++++++ test/integration/typescript-paths/test/index.test.js | 5 +++++ test/integration/typescript-paths/tsconfig.json | 3 ++- 8 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 test/integration/jsconfig-paths/components/hello.js create mode 100644 test/integration/jsconfig-paths/pages/single-alias.js create mode 100644 test/integration/typescript-paths/components/hello.tsx create mode 100644 test/integration/typescript-paths/pages/single-alias.tsx diff --git a/test/integration/jsconfig-paths/components/hello.js b/test/integration/jsconfig-paths/components/hello.js new file mode 100644 index 000000000000000..49c8de26f6c5045 --- /dev/null +++ b/test/integration/jsconfig-paths/components/hello.js @@ -0,0 +1,5 @@ +import React from 'react' + +export function Hello() { + return <>Hello +} diff --git a/test/integration/jsconfig-paths/jsconfig.json b/test/integration/jsconfig-paths/jsconfig.json index 3b6323e2e50f013..d49f9334123b7b2 100644 --- a/test/integration/jsconfig-paths/jsconfig.json +++ b/test/integration/jsconfig-paths/jsconfig.json @@ -3,7 +3,8 @@ "baseUrl": ".", "paths": { "@c/*": ["components/*"], - "@lib/*": ["lib/a/*", "lib/b/*"] + "@lib/*": ["lib/a/*", "lib/b/*"], + "@mycomponent": ["components/hello.js"] } } } diff --git a/test/integration/jsconfig-paths/pages/single-alias.js b/test/integration/jsconfig-paths/pages/single-alias.js new file mode 100644 index 000000000000000..df2031b90ae62a9 --- /dev/null +++ b/test/integration/jsconfig-paths/pages/single-alias.js @@ -0,0 +1,9 @@ +import { Hello } from '@mycomponent' + +export default function SingleAlias() { + return ( +
+ +
+ ) +} diff --git a/test/integration/jsconfig-paths/test/index.test.js b/test/integration/jsconfig-paths/test/index.test.js index 308df6366bcb8ea..d7fd31aa92f8658 100644 --- a/test/integration/jsconfig-paths/test/index.test.js +++ b/test/integration/jsconfig-paths/test/index.test.js @@ -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/) + }) }) }) diff --git a/test/integration/typescript-paths/components/hello.tsx b/test/integration/typescript-paths/components/hello.tsx new file mode 100644 index 000000000000000..49c8de26f6c5045 --- /dev/null +++ b/test/integration/typescript-paths/components/hello.tsx @@ -0,0 +1,5 @@ +import React from 'react' + +export function Hello() { + return <>Hello +} diff --git a/test/integration/typescript-paths/pages/single-alias.tsx b/test/integration/typescript-paths/pages/single-alias.tsx new file mode 100644 index 000000000000000..df2031b90ae62a9 --- /dev/null +++ b/test/integration/typescript-paths/pages/single-alias.tsx @@ -0,0 +1,9 @@ +import { Hello } from '@mycomponent' + +export default function SingleAlias() { + return ( +
+ +
+ ) +} diff --git a/test/integration/typescript-paths/test/index.test.js b/test/integration/typescript-paths/test/index.test.js index 308df6366bcb8ea..d7fd31aa92f8658 100644 --- a/test/integration/typescript-paths/test/index.test.js +++ b/test/integration/typescript-paths/test/index.test.js @@ -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/) + }) }) }) diff --git a/test/integration/typescript-paths/tsconfig.json b/test/integration/typescript-paths/tsconfig.json index 29c96623ecbaafb..f224849f25ad0a8 100644 --- a/test/integration/typescript-paths/tsconfig.json +++ b/test/integration/typescript-paths/tsconfig.json @@ -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",