Skip to content

Commit edb33e1

Browse files
committed
test(client): pin notifications.registerDevice / unregisterDevice on the wire (red)
Claude-Session: https://claude.ai/code/session_01ADHkmRD9KKqvTU3THnute6 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3c0d5be commit edb33e1

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎packages/client/src/client.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,28 @@ describe('Notifications namespace', () => {
937937
expect(url).toContain('/api/v1/notifications/read/all');
938938
expect(opts.method).toBe('POST');
939939
});
940+
941+
it('registers a push device with POST /notifications/devices (ADR-0012 §6)', async () => {
942+
const { client, fetchMock } = createMockClient({
943+
success: true,
944+
data: { deviceId: 'install-1', success: true }
945+
});
946+
const result = await client.notifications.registerDevice({ token: 'tok', platform: 'ios', deviceId: 'install-1', locale: 'zh-CN' });
947+
expect(result).toEqual({ deviceId: 'install-1', success: true });
948+
const [url, opts] = fetchMock.mock.calls[0];
949+
expect(url).toBe('http://localhost:3000/api/v1/notifications/devices');
950+
expect(opts.method).toBe('POST');
951+
expect(JSON.parse(opts.body)).toEqual({ token: 'tok', platform: 'ios', deviceId: 'install-1', locale: 'zh-CN' });
952+
});
953+
954+
it('unregisters a push device with DELETE /notifications/devices/:deviceId, the id encoded', async () => {
955+
const { client, fetchMock } = createMockClient({ success: true, data: { success: true } });
956+
const result = await client.notifications.unregisterDevice('install/1');
957+
expect(result).toEqual({ success: true });
958+
const [url, opts] = fetchMock.mock.calls[0];
959+
expect(url).toBe('http://localhost:3000/api/v1/notifications/devices/install%2F1');
960+
expect(opts.method).toBe('DELETE');
961+
});
940962
});
941963

942964
describe('AI namespace (#3718)', () => {

0 commit comments

Comments
 (0)