componentsImageUrl.test.mjs 1.09 KB
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
import path from 'node:path'
import { setupWxMock } from '../packageEquity/tests/menuTestHelpers.mjs'

const require = createRequire(import.meta.url)
const rootDir = path.resolve(fileURLToPath(new URL('.', import.meta.url)), '..')

describe('componentsImageUrl', () => {
  it('componentsImageUrl builds the uploaded CDN path', () => {
    setupWxMock(globalThis)
    const { componentsImageUrl } = require(path.join(rootDir, 'utils/imageBase.js'))
    assert.equal(
      componentsImageUrl('close.png'),
      'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/components/images/close.png'
    )
  })

  it('CLOSE_ICON_URL uses the uploaded CDN image', () => {
    setupWxMock(globalThis)
    const { CLOSE_ICON_URL } = require(path.join(rootDir, 'utils/imageBase.js'))
    assert.equal(
      CLOSE_ICON_URL,
      'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/components/images/close.png'
    )
  })
})