File tree Expand file tree Collapse file tree
clerk-js/src/core/resources/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -745,18 +745,20 @@ describe('User', () => {
745745 } ) ;
746746 } ) ;
747747
748- it ( '.updateMetadata omits unsafe_metadata when not provided ' , async ( ) => {
748+ it ( '.updateMetadata sends an explicit null patch when a key is being removed ' , async ( ) => {
749749 // @ts -ignore
750750 BaseResource . _fetch = vi . fn ( ) . mockReturnValue ( Promise . resolve ( { response : { } } ) ) ;
751751
752752 const user = new User ( { } as unknown as UserJSON ) ;
753- await user . updateMetadata ( { } ) ;
753+ await user . updateMetadata ( { unsafeMetadata : { theme : null as unknown as undefined } } ) ;
754754
755755 // @ts -ignore
756756 expect ( BaseResource . _fetch ) . toHaveBeenCalledWith ( {
757757 method : 'PATCH' ,
758758 path : '/me/metadata' ,
759- body : { } ,
759+ body : {
760+ unsafeMetadata : JSON . stringify ( { theme : null } ) ,
761+ } ,
760762 } ) ;
761763 } ) ;
762764} ) ;
Original file line number Diff line number Diff line change @@ -190,12 +190,12 @@ export type UpdateUserParams = Partial<SnakeToCamel<UpdateUserJSON>>;
190190
191191/**
192192 * Parameters for {@link UserResource.updateMetadata}. Only `unsafeMetadata`
193- * is end-user-writable on the Frontend API. The submitted value is deep-merged
194- * with the existing `unsafeMetadata`; keys at any level whose value is `null`
195- * are removed.
193+ * is end-user-writable on the Frontend API and the field is required: the
194+ * submitted value is deep-merged with the existing `unsafeMetadata`, and keys
195+ * at any level whose value is `null` are removed.
196196 */
197197export type UpdateUserMetadataParams = {
198- unsafeMetadata ? : UserUnsafeMetadata ;
198+ unsafeMetadata : UserUnsafeMetadata ;
199199} ;
200200
201201export type UpdateUserPasswordParams = {
You can’t perform that action at this time.
0 commit comments