From 05808613a1a184513387108d8bfd1250d74de4b0 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Fri, 28 Jun 2024 15:44:17 +0200 Subject: [PATCH 1/2] test(nuxt): Add code snippet unit tests --- packages/nuxt/src/common/snippets.ts | 10 +-- packages/nuxt/test/common/snippets.test.ts | 75 ++++++++++++++++++++++ 2 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 packages/nuxt/test/common/snippets.test.ts diff --git a/packages/nuxt/src/common/snippets.ts b/packages/nuxt/src/common/snippets.ts index 9086172387a7..158ff44935e3 100644 --- a/packages/nuxt/src/common/snippets.ts +++ b/packages/nuxt/src/common/snippets.ts @@ -1,16 +1,18 @@ import * as fs from 'fs'; import * as path from 'path'; -// todo: tests /** Returns an import snippet */ export function buildSdkInitFileImportSnippet(filePath: string): string { const posixPath = filePath.split(path.sep).join(path.posix.sep); - return `import "${posixPath}";`; + // normalize to forward slashed for Windows-based systems + const normalizedPath = posixPath.replace(/\\/g, '/'); + + return `import '${normalizedPath}';`; } -// todo: tests -/** Adds an import statement right after