@@ -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
942964describe ( 'AI namespace (#3718)' , ( ) => {
0 commit comments