Skip to content

Commit

Permalink
test: add trailing slash to base
Browse files Browse the repository at this point in the history
  • Loading branch information
candy-Tong committed Nov 22, 2022
1 parent c38a69f commit 1b8f757
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/vite/src/node/__tests__/utils.spec.ts
@@ -1,4 +1,5 @@
import fs from 'node:fs'
import path from 'node:path'
import { describe, expect, test } from 'vitest'
import {
asyncFlatten,
Expand All @@ -9,6 +10,7 @@ import {
isFileReadable,
isWindows,
posToNumber,
processSrcSetSync,
resolveHostname,
shouldServe
} from '../utils'
Expand Down Expand Up @@ -270,3 +272,15 @@ describe('isFileReadable', () => {
})
}
})

describe('processSrcSetSync', () => {
test('replace srcset with base url /base/', async () => {
const devBase = '/base/'
expect(
processSrcSetSync(
'./nested/asset.png 1x, ./nested/asset.png 2x',
({ url }) => path.posix.join(devBase, url)
)
).toBe('/base/nested/asset.png 1x, /base/nested/asset.png 2x')
})
})

0 comments on commit 1b8f757

Please sign in to comment.