File size: 1,400 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import {
formatFrameSourceFile,
isWebpackInternalResource,
} from './webpack-module-path'
describe('webpack-module-path', () => {
describe('isWebpackInternalResource', () => {
it('should return true for webpack-internal paths', () => {
expect(
isWebpackInternalResource('webpack-internal:///./src/hello.tsx')
).toBe(true)
expect(isWebpackInternalResource('webpack://_N_E/./src/hello.tsx')).toBe(
true
)
expect(isWebpackInternalResource('webpack://./src/hello.tsx')).toBe(true)
expect(isWebpackInternalResource('webpack:///./src/hello.tsx')).toBe(true)
})
it('should return false for non-webpack-internal paths', () => {
expect(isWebpackInternalResource('<anonymous>')).toBe(false)
expect(isWebpackInternalResource('file:///src/hello.tsx')).toBe(false)
})
})
describe('formatFrameSourceFile', () => {
it('should return the original file path', () => {
expect(formatFrameSourceFile('webpack-internal:///./src/hello.tsx')).toBe(
'./src/hello.tsx'
)
expect(formatFrameSourceFile('webpack://_N_E/./src/hello.tsx')).toBe(
'./src/hello.tsx'
)
expect(formatFrameSourceFile('webpack://./src/hello.tsx')).toBe(
'./src/hello.tsx'
)
expect(formatFrameSourceFile('webpack:///./src/hello.tsx')).toBe(
'./src/hello.tsx'
)
})
})
})
|