Automerge backed Markdown editor for the Atmosphere
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849/** * Tests for arrayBufferToHex utility function. * * Obsidian API: `function arrayBufferToHex(data: ArrayBuffer): string` */import { describe, it, expect } from 'vitest'import { arrayBufferToHex } from '../obsidian-stubs'
describe('arrayBufferToHex', () => { it('returns empty string for empty ArrayBuffer', () => { const buffer = new ArrayBuffer(0) expect(arrayBufferToHex(buffer)).toBe('') })
it('converts single byte 0x00 to "00"', () => { const buffer = new Uint8Array([0x00]).buffer expect(arrayBufferToHex(buffer)).toBe('00') })
it('converts single byte 0xff to "ff"', () => { const buffer = new Uint8Array([0xff]).buffer expect(arrayBufferToHex(buffer)).toBe('ff') })
it('converts multi-byte array to hex string', () => { const buffer = new Uint8Array([0xde, 0xad, 0xbe, 0xef]).buffer expect(arrayBufferToHex(buffer)).toBe('deadbeef') })
it('returns lowercase hex characters', () => { const buffer = new Uint8Array([0xab, 0xcd, 0xef]).buffer const result = arrayBufferToHex(buffer) expect(result).toBe('abcdef') // Explicitly verify no uppercase expect(result).not.toMatch(/[A-F]/) })
it('pads single-digit hex values with leading zero', () => { // 0x0a should be "0a", not "a" const buffer = new Uint8Array([0x0a, 0x0b, 0x0c]).buffer expect(arrayBufferToHex(buffer)).toBe('0a0b0c') })
it('handles sequential byte values', () => { const buffer = new Uint8Array([0x00, 0x01, 0x02, 0x03]).buffer expect(arrayBufferToHex(buffer)).toBe('00010203') })})