securityos/node_modules/multiformats/test/test-bytes.spec.js

27 lines
842 B
JavaScript
Raw Permalink Normal View History

2024-09-06 15:32:35 +00:00
/* globals describe, it */
import * as bytes from '../src/bytes.js'
import { assert } from 'aegir/chai'
describe('bytes', () => {
it('isBinary', () => {
assert.deepStrictEqual(bytes.isBinary(new ArrayBuffer(0)), true)
assert.deepStrictEqual(bytes.isBinary(new DataView(new ArrayBuffer(0))), true)
})
it('coerce', () => {
const fixture = bytes.fromString('test')
assert.deepStrictEqual(bytes.coerce(fixture.buffer), fixture)
assert.deepStrictEqual(bytes.coerce(new DataView(fixture.buffer)), fixture)
})
it('equals', () => {
const fixture = bytes.fromString('test')
assert.deepStrictEqual(bytes.equals(fixture, bytes.fromString('asdfadf')), false)
})
it('toString()', () => {
const fixture = 'hello world'
assert.deepStrictEqual(bytes.toString(bytes.fromString(fixture)), fixture)
})
})