From c0bc0004101c92d18462f461c11dbdf0e3c95d22 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Mon, 26 Aug 2024 23:40:37 +0900 Subject: [PATCH] Migrate `test/e2e/__tests__/stylelint-resolution.ts` --- test/e2e/__tests__/stylelint-resolution.ts | 63 +++++++++++++++------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/test/e2e/__tests__/stylelint-resolution.ts b/test/e2e/__tests__/stylelint-resolution.ts index e4f5820b..020e0fc6 100644 --- a/test/e2e/__tests__/stylelint-resolution.ts +++ b/test/e2e/__tests__/stylelint-resolution.ts @@ -1,38 +1,65 @@ -import path from 'path'; -import { normalizeDiagnostic } from '../utils'; +import { openDocument, waitForDiagnostics, assertDiagnostics, closeAllEditors } from '../utils'; describe('Stylelint resolution', () => { + afterEach(async () => { + await closeAllEditors(); + }); + it('should resolve Stylelint using local node_modules', async () => { - const { document } = await openDocument( - path.resolve(workspaceDir, 'defaults/local-stylelint/test.css'), - ); + const document = await openDocument('defaults/local-stylelint/test.css'); const diagnostics = await waitForDiagnostics(document); - expect(diagnostics.map(normalizeDiagnostic)).toMatchSnapshot(); + assertDiagnostics(diagnostics, [ + { + code: 'fake', + message: 'Fake result from resolve-local', + range: [0, 0, 0, 1], + severity: 'error', + }, + ]); }); - it('should resolve Stylelint using "stylelint.stylelintPath"', async () => { - const { document } = await openDocument(path.resolve(workspaceDir, 'stylelint-path/test.css')); - const diagnostics = await waitForDiagnostics(document); + describe('when using "stylelint.stylelintPath"', () => { + it('should resolve Stylelint', async () => { + const document = await openDocument('stylelint-path/test.css'); + const diagnostics = await waitForDiagnostics(document); - expect(diagnostics.map(normalizeDiagnostic)).toMatchSnapshot(); + assertDiagnostics(diagnostics, [ + { + code: 'fake', + message: 'Fake result', + range: [0, 0, 0, 1], + severity: 'error', + }, + ]); + }); }); it('should resolve Stylelint using PnP', async () => { - const { document } = await openDocument( - path.resolve(workspaceDir, 'defaults/yarn-pnp/test.css'), - ); + const document = await openDocument('defaults/yarn-pnp/test.css'); const diagnostics = await waitForDiagnostics(document); - expect(diagnostics.map(normalizeDiagnostic)).toMatchSnapshot(); + assertDiagnostics(diagnostics, [ + { + code: 'fake', + message: 'Fake result from yarn-pnp', + range: [0, 0, 0, 1], + severity: 'error', + }, + ]); }); it('should resolve Stylelint using Yarn 2.x PnP', async () => { - const { document } = await openDocument( - path.resolve(workspaceDir, 'defaults/yarn-2-pnp/test.css'), - ); + const document = await openDocument('defaults/yarn-2-pnp/test.css'); const diagnostics = await waitForDiagnostics(document); - expect(diagnostics.map(normalizeDiagnostic)).toMatchSnapshot(); + assertDiagnostics(diagnostics, [ + { + code: 'fake', + message: 'Fake result from yarn-2-pnp', + range: [0, 0, 0, 1], + severity: 'error', + }, + ]); }); });