Files
boc/landvex-admin-v2/node_modules/restructure/test/Enum.js
T
Bernt 6989a98d75 feat: Passwordless cross-device authentication
- Arkitektur: docs/auth/passwordless-architecture.md
- Backend: iom/quixzoom-auth-service/ (FastAPI + Redis)
- Webb: quixzoom-market-pages/se/login/ (QR-kod + polling)
- App: iom/quixzoom-app/src/features/auth/ (push + deep links)

Flöde: QR-kod → app-godkännande → webb-inloggad
2026-07-07 07:11:50 +00:00

25 lines
831 B
JavaScript

import assert from 'assert';
import {Enum, uint8, DecodeStream, EncodeStream} from 'restructure';
describe('Enum', function() {
const e = new Enum(uint8, ['foo', 'bar', 'baz']);
it('should have the right size', () => assert.equal(e.size(), 1));
it('should decode', function() {
const stream = new DecodeStream(new Uint8Array([1, 2, 0]));
assert.equal(e.decode(stream), 'bar');
assert.equal(e.decode(stream), 'baz');
assert.equal(e.decode(stream), 'foo');
});
it('should encode', function() {
assert.deepEqual(e.toBuffer('bar'), new Uint8Array([1]));
assert.deepEqual(e.toBuffer('baz'), new Uint8Array([2]));
assert.deepEqual(e.toBuffer('foo'), new Uint8Array([0]));
});
it('should throw on unknown option', function() {
return assert.throws(() => e.toBuffer('unknown'));
});
});