@@ -31,13 +31,6 @@ describe("PluginConfiguration", () => {
3131 expect ( pluginConfiguration . all ( ) ) . toEqual ( { defaultKey : "defaultValue" } ) ;
3232 } ) ;
3333
34- it ( "should merge the given value" , ( ) => {
35- pluginConfiguration . set ( "key" , "value" ) ;
36- pluginConfiguration . merge ( { some : "value" } ) ;
37-
38- expect ( pluginConfiguration . all ( ) ) . toEqual ( { some : "value" , key : "value" } ) ;
39- } ) ;
40-
4134 it ( "should set and get the given value" , ( ) => {
4235 pluginConfiguration . set ( "key" , "value" ) ;
4336
@@ -59,4 +52,48 @@ describe("PluginConfiguration", () => {
5952 it ( "should throw when using deprecated get default value argument" , ( ) => {
6053 expect ( ( ) => pluginConfiguration . get ( "key" , "default value" ) ) . toThrow ( ) ;
6154 } ) ;
55+
56+ describe ( "merge" , ( ) => {
57+ it ( "should merge the given value" , ( ) => {
58+ pluginConfiguration . set ( "key" , "value" ) ;
59+ pluginConfiguration . merge ( { some : "value" } ) ;
60+
61+ expect ( pluginConfiguration . all ( ) ) . toEqual ( { some : "value" , key : "value" } ) ;
62+ } ) ;
63+
64+ it ( "should merge nested object" , ( ) => {
65+ pluginConfiguration . set ( "key" , {
66+ "1" : {
67+ "1.1" : "test" ,
68+ } ,
69+ } ) ;
70+ pluginConfiguration . merge ( {
71+ key : {
72+ "1" : {
73+ "1.2" : "test" ,
74+ } ,
75+ } ,
76+ } ) ;
77+
78+ expect ( pluginConfiguration . all ( ) ) . toEqual ( {
79+ key : {
80+ "1" : {
81+ "1.1" : "test" ,
82+ "1.2" : "test" ,
83+ } ,
84+ } ,
85+ } ) ;
86+ } ) ;
87+
88+ it ( "should override array" , ( ) => {
89+ pluginConfiguration . set ( "key" , [ 1 , 2 , 3 ] ) ;
90+ pluginConfiguration . merge ( {
91+ key : [ 3 , 4 , 5 ] ,
92+ } ) ;
93+
94+ expect ( pluginConfiguration . all ( ) ) . toEqual ( {
95+ key : [ 3 , 4 , 5 ] ,
96+ } ) ;
97+ } ) ;
98+ } ) ;
6299} ) ;
0 commit comments