@@ -12,15 +12,16 @@ const combineSchema = yaml.DEFAULT_SCHEMA.extend([combineType, esseType]);
1212
1313describe ( "YAML tag: !combine" , ( ) => {
1414 let yamlFixture ;
15+ let parsed ;
1516
1617 // eslint-disable-next-line func-names
1718 before ( function ( ) {
1819 this . timeout ( 5000 ) ;
1920 yamlFixture = fs . readFileSync ( YAML_COMBINE_FILE , "utf8" ) ;
21+ parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
2022 } ) ;
2123
2224 it ( "should correctly parse a custom !combine tag with forEach and config keys" , ( ) => {
23- const parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
2425 const expectedResult = [
2526 { name : "mytest" , a : 1 , b : 3 , c : 5 } ,
2627 { name : "mytest" , a : 1 , b : 4 , c : 5 } ,
@@ -32,72 +33,57 @@ describe("YAML tag: !combine", () => {
3233 } ) ;
3334
3435 it ( "should correctly parse a custom !combine tag with only a name key" , ( ) => {
35- const parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
3636 const expectedResult = [ { name : "mytest" } ] ;
37-
3837 expect ( parsed . case2 ) . to . have . deep . members ( expectedResult ) ;
3938 } ) ;
4039
4140 it ( "should correctly parse a custom !combine tag with forEach key and no values" , ( ) => {
42- const parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
4341 const expectedResult = [ { name : "mytest" } ] ;
44-
4542 expect ( parsed . case3 ) . to . have . deep . members ( expectedResult ) ;
4643 } ) ;
4744
4845 it ( "should correctly parse a custom !combine tag with an empty forEach key and a config key" , ( ) => {
49- const parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
5046 const expectedResult = [ { name : "mytest" , c : 5 } ] ;
51-
5247 expect ( parsed . case4 ) . to . have . deep . members ( expectedResult ) ;
5348 } ) ;
5449
5550 it ( "should correctly generate name based on template" , ( ) => {
56- const parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
5751 const expectedResult = [
5852 { name : "A1 with B2 and C5" , a : 1 , b : "two" , c : 5 } ,
5953 { name : "A1 with B4 and C5" , a : 1 , b : "four" , c : 5 } ,
6054 ] ;
61-
6255 expect ( parsed . case5 ) . to . have . deep . members ( expectedResult ) ;
6356 } ) ;
6457
6558 it ( "should correctly parse a custom !combine tag with additional property" , ( ) => {
66- const parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
6759 const expectedResult = [
6860 { name : "mytest" , a : 1 , b : 3 } ,
6961 { name : "mytest" , a : 1 , b : 4 } ,
7062 { name : "additional property" , x : 7 } ,
7163 ] ;
72-
7364 expect ( parsed . case6 ) . to . have . deep . members ( expectedResult ) ;
7465 } ) ;
7566
7667 it ( "should correctly parse a custom !combine tag with additional property from !combine tag" , ( ) => {
77- const parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
7868 const expectedResult = [
7969 { name : "mytest" , a : 1 , b : 3 } ,
8070 { name : "mytest" , a : 1 , b : 4 } ,
8171 { name : "additional property" , x : 7 , y : 9 } ,
8272 { name : "additional property" , x : 8 , y : 9 } ,
8373 ] ;
84-
8574 expect ( parsed . case7 ) . to . have . deep . members ( expectedResult ) ;
8675 } ) ;
8776
8877 it ( "should create an additional config when falsy parameter is provided" , ( ) => {
89- const parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
9078 const expectedResult = [
9179 { name : "A1 with B2" , a : 1 , b : "two" } ,
9280 { name : "A1 with B4" , a : 1 , b : "four" } ,
9381 { name : "A1" , a : 1 } ,
9482 ] ;
95-
9683 expect ( parsed . case8 ) . to . have . deep . members ( expectedResult ) ;
9784 } ) ;
9885
9986 it ( "should create all combinations of n optional parameters" , ( ) => {
100- const parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
10187 const expectedResult = [
10288 { name : "optional params" , a : 1 } ,
10389 { name : "optional params" , a : 1 , b : 2 } ,
@@ -106,19 +92,15 @@ describe("YAML tag: !combine", () => {
10692 { name : "optional params" , a : 1 , b : 2 , c : 4 } ,
10793 { name : "optional params" , a : 1 , b : 3 , c : 4 } ,
10894 ] ;
109-
11095 expect ( parsed . case9 ) . to . have . deep . members ( expectedResult ) ;
11196 } ) ;
11297
11398 it ( "should allow to exclude certain parameter-specified combinations" , ( ) => {
114- const parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
11599 const expectedResult = [ { name : "ignore test" , a : { c : 3 } , d : 4 } ] ;
116-
117100 expect ( parsed . case10 ) . to . have . deep . members ( expectedResult ) ;
118101 } ) ;
119102
120103 it ( "should use the push action to add value to an array parameter" , ( ) => {
121- const parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
122104 const expectedResult = [
123105 { name : "push test" , units : [ { a : 1 } , { b : 4 } ] } ,
124106 { name : "push test" , units : [ { a : 2 } , { b : 4 } ] } ,
@@ -136,7 +118,6 @@ describe("YAML tag: !combine", () => {
136118 } ) ;
137119
138120 it ( "should use cloned objects when pushing to array" , ( ) => {
139- const parsed = yaml . load ( yamlFixture , { schema : combineSchema } ) ;
140121 const [ config1 , config2 ] = parsed . case12 ;
141122
142123 // deleting property in one should not affect the other
0 commit comments