2023-11-04 17:18:20 +08:00
|
|
|
import { remoteAssets } from '../src/swagger/resource'
|
|
|
|
|
|
|
|
describe('remoteAssets', () => {
|
|
|
|
it('should return default assets when no version is provided', () => {
|
|
|
|
const assets = remoteAssets({})
|
2024-08-25 10:41:29 +08:00
|
|
|
expect(assets.css).toEqual(['https://cdn.jsdelivr.net/npm/swagger-ui-dist/swagger-ui.css'])
|
|
|
|
expect(assets.js).toEqual(['https://cdn.jsdelivr.net/npm/swagger-ui-dist/swagger-ui-bundle.js'])
|
2023-11-04 17:18:20 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
it('should return assets with version when version is provided', () => {
|
|
|
|
const version = '1.2.3'
|
|
|
|
const assets = remoteAssets({ version })
|
2024-08-25 10:41:29 +08:00
|
|
|
expect(assets.css).toEqual([
|
|
|
|
`https://cdn.jsdelivr.net/npm/swagger-ui-dist@${version}/swagger-ui.css`,
|
|
|
|
])
|
|
|
|
expect(assets.js).toEqual([
|
|
|
|
`https://cdn.jsdelivr.net/npm/swagger-ui-dist@${version}/swagger-ui-bundle.js`,
|
|
|
|
])
|
2023-11-04 17:18:20 +08:00
|
|
|
})
|
|
|
|
})
|