archy/apps/web5-dwn/node_modules/multiformats/test/test-multicodec.spec.js
Dorian 0d073fa89e Add comprehensive installation and setup documentation
- Add GETTING_STARTED.md with quick start guide and development modes
- Add INSTALL.sh automated installation script
- Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md
- Add QUICK_REFERENCE.md for common commands
- Add SETUP_GUIDE.md with detailed setup instructions
- Update README.md with improved project overview
- Add did-wallet app dependencies and node_modules
2026-01-27 17:18:21 +00:00

25 lines
916 B
JavaScript

/* globals describe, it */
import * as bytes from '../src/bytes.js'
import * as raw from '../src/codecs/raw.js'
import * as json from '../src/codecs/json.js'
import { assert } from 'aegir/chai'
describe('multicodec', () => {
it('encode/decode raw', () => {
const buff = raw.encode(bytes.fromString('test'))
assert.deepStrictEqual(buff, bytes.fromString('test'))
assert.deepStrictEqual(raw.decode(buff), bytes.fromString('test'))
})
it('encode/decode json', () => {
const buff = json.encode({ hello: 'world' })
assert.deepStrictEqual(buff, bytes.fromString(JSON.stringify({ hello: 'world' })))
assert.deepStrictEqual(json.decode(buff), { hello: 'world' })
})
it('raw cannot encode string', async () => {
// @ts-expect-error - 'string' is not assignable to parameter of type 'Uint8Array'
assert.throws(() => raw.encode('asdf'), 'Unknown type, must be binary type')
})
})