From 2414bcf494657bc0eb0a0175810e6a486bb1652c Mon Sep 17 00:00:00 2001 From: Lev Chelyadinov Date: Sun, 16 Jun 2024 19:32:50 +0200 Subject: [PATCH] Start fixing tests on Windows --- packages/steiger-plugin-fsd/src/_lib/prepare-test.ts | 4 ++++ .../src/inconsistent-naming/index.spec.ts | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/steiger-plugin-fsd/src/_lib/prepare-test.ts b/packages/steiger-plugin-fsd/src/_lib/prepare-test.ts index 6a219ce..f7a5ea2 100644 --- a/packages/steiger-plugin-fsd/src/_lib/prepare-test.ts +++ b/packages/steiger-plugin-fsd/src/_lib/prepare-test.ts @@ -38,6 +38,10 @@ export function compareMessages(a: Diagnostic, b: Diagnostic): number { return a.message.localeCompare(b.message) } +export function joinFromRoot(...segments: Array) { + return join('/', ...segments) +} + if (import.meta.vitest) { const { test, expect } = import.meta.vitest diff --git a/packages/steiger-plugin-fsd/src/inconsistent-naming/index.spec.ts b/packages/steiger-plugin-fsd/src/inconsistent-naming/index.spec.ts index 3dc4c91..9fcf486 100644 --- a/packages/steiger-plugin-fsd/src/inconsistent-naming/index.spec.ts +++ b/packages/steiger-plugin-fsd/src/inconsistent-naming/index.spec.ts @@ -1,6 +1,6 @@ import { expect, it } from 'vitest' -import { compareMessages, parseIntoFsdRoot } from '../_lib/prepare-test.js' +import { compareMessages, parseIntoFsdRoot, joinFromRoot } from '../_lib/prepare-test.js' import inconsistentNaming from './index.js' it('reports no errors on slice names that are pluralized consistently', () => { @@ -35,7 +35,7 @@ it('reports an error on slice names that are not pluralized consistently', () => fixes: [ { type: 'rename', - path: '/entities/user', + path: joinFromRoot('entities', 'user'), newName: 'users', }, ], @@ -64,7 +64,7 @@ it('prefers the singular form when there are more singular slices', () => { fixes: [ { type: 'rename', - path: '/entities/comments', + path: joinFromRoot('entities', 'comments'), newName: 'comment', }, ],