File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -1779,6 +1779,39 @@ describe('beforeSave hooks', () => {
1779
1779
const myObject = new MyObject ( ) ;
1780
1780
myObject . save ( ) . then ( ( ) => done ( ) ) ;
1781
1781
} ) ;
1782
+
1783
+ it ( 'should respect custom object ids (#6733)' , async ( ) => {
1784
+ Parse . Cloud . beforeSave ( 'TestObject' , req => {
1785
+ expect ( req . object . id ) . toEqual ( 'test_6733' ) ;
1786
+ } ) ;
1787
+
1788
+ await reconfigureServer ( { allowCustomObjectId : true } ) ;
1789
+
1790
+ const req = request ( {
1791
+ // Parse JS SDK does not currently support custom object ids (see #1097), so we do a REST request
1792
+ method : 'POST' ,
1793
+ url : 'http://localhost:8378/1/classes/TestObject' ,
1794
+ headers : {
1795
+ 'X-Parse-Application-Id' : 'test' ,
1796
+ 'X-Parse-REST-API-Key' : 'rest' ,
1797
+ } ,
1798
+ body : {
1799
+ objectId : 'test_6733' ,
1800
+ foo : 'bar' ,
1801
+ } ,
1802
+ } ) ;
1803
+
1804
+ {
1805
+ const res = await req ;
1806
+ expect ( res . data . objectId ) . toEqual ( 'test_6733' ) ;
1807
+ }
1808
+
1809
+ const query = new Parse . Query ( 'TestObject' ) ;
1810
+ query . equalTo ( 'objectId' , 'test_6733' ) ;
1811
+ const res = await query . find ( ) ;
1812
+ expect ( res . length ) . toEqual ( 1 ) ;
1813
+ expect ( res [ 0 ] . get ( 'foo' ) ) . toEqual ( 'bar' ) ;
1814
+ } ) ;
1782
1815
} ) ;
1783
1816
1784
1817
describe ( 'afterSave hooks' , ( ) => {
You can’t perform that action at this time.
0 commit comments