platform.test.ts25 lines · main
| 1 | import assert from 'node:assert/strict'; |
| 2 | import { describe, it } from 'node:test'; |
| 3 | |
| 4 | import { normalizeMe } from './platform.js'; |
| 5 | |
| 6 | describe('normalizeMe', () => { |
| 7 | it('accepts flat /v1/me profile', () => { |
| 8 | assert.deepEqual(normalizeMe({ id: 'u_1', email: 'a@b.co', name: 'A' }), { |
| 9 | id: 'u_1', |
| 10 | email: 'a@b.co', |
| 11 | }); |
| 12 | }); |
| 13 | |
| 14 | it('accepts nested { user } shape', () => { |
| 15 | assert.deepEqual(normalizeMe({ user: { id: 'u_2', email: 'c@d.co' } }), { |
| 16 | id: 'u_2', |
| 17 | email: 'c@d.co', |
| 18 | }); |
| 19 | }); |
| 20 | |
| 21 | it('throws on garbage', () => { |
| 22 | assert.throws(() => normalizeMe({}), /unexpected/); |
| 23 | assert.throws(() => normalizeMe(null), /unexpected/); |
| 24 | }); |
| 25 | }); |