mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-04-05 19:42:07 +08:00
19 lines
608 B
TypeScript
19 lines
608 B
TypeScript
import { arrayBufferToBase64Image } from '../../src/utils/basic'
|
|
|
|
describe('arrayBufferToBase64Image', () => {
|
|
const arrayBuffer = new ArrayBuffer(8)
|
|
const base64ImagePrefix = 'data:image/png;base64,'
|
|
|
|
it('should convert array buffer to base64 image', () => {
|
|
const base64Image = arrayBufferToBase64Image(arrayBuffer)
|
|
|
|
expect(base64Image).toBe(`${base64ImagePrefix}AAAAAAAAAAA=`)
|
|
})
|
|
|
|
it('should convert array buffer to base64 image with prefix', () => {
|
|
const base64Image = arrayBufferToBase64Image(arrayBuffer)
|
|
|
|
expect(base64Image.startsWith(base64ImagePrefix)).toBe(true)
|
|
})
|
|
})
|