Skip to content

Commit

Permalink
test: vite-node normalizeRequestId
Browse files Browse the repository at this point in the history
  • Loading branch information
syi0808 committed Jul 12, 2024
1 parent b76bf23 commit b6a34fa
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/vite-node/test/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { expect, test, vi } from 'vitest'

test.each([
{ platform: 'win32', id: 'file:///C:/Users/user/workspace/file.js', path: 'C:/Users/user/workspace/file.js' },
{ platform: 'darwin', id: 'file:///Users/user/workspace/file.js', path: '/Users/user/workspace/file.js' },
{ platform: 'linux', id: 'file:///Users/user/workspace/file.js', path: '/Users/user/workspace/file.js' },
] as { platform: NodeJS.Platform; id: string; path: string }[])(
'normalizeRequestId should be normarlize file protocol path correctly in $platform',
async ({
platform,
id,
path,
}) => {
const mockPlatform = vi.spyOn(process, 'platform', 'get')

mockPlatform.mockReturnValue(platform)

const { normalizeRequestId } = await import('vite-node/utils')

expect(normalizeRequestId(id)).toBe(path)

Check failure on line 20 in test/vite-node/test/utils.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 18)

test/utils.test.ts > normalizeRequestId should be normarlize file protocol path correctly in 'darwin'

AssertionError: expected 'Users/user/workspace/file.js' to be '/Users/user/workspace/file.js' // Object.is equality - Expected + Received - /Users/user/workspace/file.js + Users/user/workspace/file.js ❯ test/utils.test.ts:20:36

Check failure on line 20 in test/vite-node/test/utils.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 18)

test/utils.test.ts > normalizeRequestId should be normarlize file protocol path correctly in 'linux'

AssertionError: expected 'Users/user/workspace/file.js' to be '/Users/user/workspace/file.js' // Object.is equality - Expected + Received - /Users/user/workspace/file.js + Users/user/workspace/file.js ❯ test/utils.test.ts:20:36

Check failure on line 20 in test/vite-node/test/utils.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20.14)

test/utils.test.ts > normalizeRequestId should be normarlize file protocol path correctly in 'darwin'

AssertionError: expected 'Users/user/workspace/file.js' to be '/Users/user/workspace/file.js' // Object.is equality - Expected + Received - /Users/user/workspace/file.js + Users/user/workspace/file.js ❯ test/utils.test.ts:20:36

Check failure on line 20 in test/vite-node/test/utils.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20.14)

test/utils.test.ts > normalizeRequestId should be normarlize file protocol path correctly in 'linux'

AssertionError: expected 'Users/user/workspace/file.js' to be '/Users/user/workspace/file.js' // Object.is equality - Expected + Received - /Users/user/workspace/file.js + Users/user/workspace/file.js ❯ test/utils.test.ts:20:36

Check failure on line 20 in test/vite-node/test/utils.test.ts

View workflow job for this annotation

GitHub Actions / test (macos-14, 20.14)

test/utils.test.ts > normalizeRequestId should be normarlize file protocol path correctly in 'darwin'

AssertionError: expected 'Users/user/workspace/file.js' to be '/Users/user/workspace/file.js' // Object.is equality - Expected + Received - /Users/user/workspace/file.js + Users/user/workspace/file.js ❯ test/utils.test.ts:20:36

Check failure on line 20 in test/vite-node/test/utils.test.ts

View workflow job for this annotation

GitHub Actions / test (macos-14, 20.14)

test/utils.test.ts > normalizeRequestId should be normarlize file protocol path correctly in 'linux'

AssertionError: expected 'Users/user/workspace/file.js' to be '/Users/user/workspace/file.js' // Object.is equality - Expected + Received - /Users/user/workspace/file.js + Users/user/workspace/file.js ❯ test/utils.test.ts:20:36

Check failure on line 20 in test/vite-node/test/utils.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 20.14)

test/utils.test.ts > normalizeRequestId should be normarlize file protocol path correctly in 'darwin'

AssertionError: expected 'Users/user/workspace/file.js' to be '/Users/user/workspace/file.js' // Object.is equality - Expected + Received - /Users/user/workspace/file.js + Users/user/workspace/file.js ❯ test/utils.test.ts:20:36

Check failure on line 20 in test/vite-node/test/utils.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 20.14)

test/utils.test.ts > normalizeRequestId should be normarlize file protocol path correctly in 'linux'

AssertionError: expected 'Users/user/workspace/file.js' to be '/Users/user/workspace/file.js' // Object.is equality - Expected + Received - /Users/user/workspace/file.js + Users/user/workspace/file.js ❯ test/utils.test.ts:20:36

mockPlatform.mockClear()
},
)

0 comments on commit b6a34fa

Please sign in to comment.