This repository was archived by the owner on Mar 28, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,45 @@ describe("settings api", () => {
3838 } ) ;
3939
4040 describe ( "patch" , ( ) => {
41+ describe ( "when changing an unexistant option" , ( ) => {
42+ it ( "should response with a bad request containing errors" , async ( ) => {
43+ expect . assertions ( 2 ) ;
44+ const settingsResponse = await request ( "/admin/settings" , {
45+ method : "PATCH" ,
46+ body : {
47+ foo : "foo-value" ,
48+ anotherFoo : 45 ,
49+ third : {
50+ foo : "foo"
51+ }
52+ } ,
53+ resolveWithFullResponse : true ,
54+ simple : false
55+ } ) ;
56+ expect ( settingsResponse . statusCode ) . toEqual ( 400 ) ;
57+ expect ( settingsResponse . body . message ) . toEqual (
58+ 'Invalid option name "foo". Invalid option name "anotherFoo". Invalid option name "third"'
59+ ) ;
60+ } ) ;
61+
62+ it ( "should not apply any change if request contains any error" , async ( ) => {
63+ expect . assertions ( 3 ) ;
64+ const settingsUpdateResponse = await request ( "/admin/settings" , {
65+ method : "PATCH" ,
66+ body : {
67+ foo : "foo-value" ,
68+ delay : 1000
69+ } ,
70+ resolveWithFullResponse : true ,
71+ simple : false
72+ } ) ;
73+ const settingsResponse = await request ( "/admin/settings" ) ;
74+ expect ( settingsUpdateResponse . statusCode ) . toEqual ( 400 ) ;
75+ expect ( settingsUpdateResponse . body . message ) . toEqual ( 'Invalid option name "foo"' ) ;
76+ expect ( settingsResponse . delay ) . toEqual ( 0 ) ;
77+ } ) ;
78+ } ) ;
79+
4180 describe ( "when changing delay option" , ( ) => {
4281 it ( "should respond with no delay" , async ( ) => {
4382 const timeCounter = new TimeCounter ( ) ;
You can’t perform that action at this time.
0 commit comments