subvehicleConversionImageUrl.test.mjs
742 Bytes
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { ensureHttpsUrl } from '../subvehicleConversion/utils/imageUrl.js'
describe('ensureHttpsUrl', () => {
it('converts http to https', () => {
const url = 'http://qcimg01.glsx.com.cn:7060/group1/M00/04/CE/test.png'
assert.equal(
ensureHttpsUrl(url),
'https://qcimg01.glsx.com.cn:7060/group1/M00/04/CE/test.png'
)
})
it('keeps https unchanged', () => {
const url = 'https://img02.glsx.com.cn/weapp/test.png'
assert.equal(ensureHttpsUrl(url), url)
})
it('returns empty string for falsy input', () => {
assert.equal(ensureHttpsUrl(''), '')
assert.equal(ensureHttpsUrl(null), '')
assert.equal(ensureHttpsUrl(undefined), '')
})
})