From 541cd01b228dd01c353a3bb4bcac95fea4adb6e3 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 23 Mar 2020 17:30:42 +0100 Subject: [PATCH] Add test for single alias (#11296) --- 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 0000000000000..49c8de26f6c50 --- /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 3b6323e2e50f0..d49f9334123b7 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 0000000000000..df2031b90ae62 --- /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 308df6366bcb8..d7fd31aa92f86 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 0000000000000..49c8de26f6c50 --- /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 0000000000000..df2031b90ae62 --- /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 308df6366bcb8..d7fd31aa92f86 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 29c96623ecbaa..f224849f25ad0 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",