10
10
/* eslint-disable no-undef */
11
11
import * as constants from '../constants/wizard-constants' ;
12
12
import * as actions from './wizard-actions' ;
13
- import { addCategoryToYamlObject , handleIndentationDependency , insert } from './wizard-actions' ;
13
+ import { addCategoryToYamlObject , handleArrayIndentation , handleIndentationDependency , insert } from './wizard-actions' ;
14
14
15
15
describe ( '>>> Wizard actions tests' , ( ) => {
16
16
it ( 'should get next category' , ( ) => {
@@ -106,7 +106,7 @@ describe('>>> Wizard actions tests', () => {
106
106
const inputData = [
107
107
{
108
108
text : 'Category 1' ,
109
- content : { test : { value : '' , question : 'Why' , } , } ,
109
+ content : [ { test : { value : '' , question : 'Why' , } , } ] ,
110
110
} ,
111
111
{
112
112
text : 'Category 2' ,
@@ -121,31 +121,14 @@ describe('>>> Wizard actions tests', () => {
121
121
const result = handleIndentationDependency ( inputData , indentationDepenedency , indentation ) ;
122
122
expect ( result ) . toEqual ( 'indent/val' ) ;
123
123
} )
124
- it ( 'should handle indentation dependencies when content is not an array' , ( ) => {
125
- const inputData = [
126
- {
127
- text : 'Category 1' ,
128
- content : { test : { value : '' , question : 'Why' , } , } ,
129
- } ,
130
- {
131
- text : 'Category 2' ,
132
- content : {
133
- test2 : { value : 'val' , question : 'Why not?' , } ,
134
- } ,
135
- } ,
136
- ] ;
137
- const indentation = 'indent' ;
138
- const indentationDepenedency = 'test2' ;
139
- const result = handleIndentationDependency ( inputData , indentationDepenedency , indentation ) ;
140
- expect ( result ) . toEqual ( 'indent/val' ) ;
141
- } )
142
124
it ( 'should add categories to the YAML object and handle indentation' , ( ) => {
143
125
const category = {
144
126
text : 'Category 1' ,
145
127
content : [ { test : { value : 'yaml' } } ] ,
146
- multiple : false ,
128
+ multiple : true ,
147
129
indentation : 'category1' ,
148
130
indentationDependency : 'test2' ,
131
+ arrIndent : 'indent' ,
149
132
} ;
150
133
const inputData = [
151
134
{
@@ -155,7 +138,7 @@ describe('>>> Wizard actions tests', () => {
155
138
] ;
156
139
let result = { test3 : 'test 3' } ;
157
140
result = addCategoryToYamlObject ( category , result , inputData ) ;
158
- expect ( result ) . toEqual ( { category1 : { val : { test : 'yaml' } } , test3 : 'test 3' } ) ;
141
+ expect ( result ) . toEqual ( { category1 : { val : [ { indent : { test : 'yaml' } } ] } , test3 : 'test 3' } ) ;
159
142
} ) ;
160
143
it ( 'should add categories to the YAML object and handle empty indentation' , ( ) => {
161
144
const category = {
@@ -173,28 +156,13 @@ describe('>>> Wizard actions tests', () => {
173
156
it ( 'should not add categories to the YAML object if they are not shown' , ( ) => {
174
157
const category = {
175
158
text : 'Category 1' ,
176
- content : [ {
177
- test : { value : 'yaml' , show : false }
178
- } ] ,
159
+ content : [ { test : { value : 'yaml' , show : false } } ] ,
179
160
multiple : false ,
180
161
indentation : '/' ,
181
162
} ;
182
163
let result = { test2 : 'test 2' } ;
183
164
result = addCategoryToYamlObject ( category , result ) ;
184
165
expect ( result ) . toEqual ( { test2 : 'test 2' } ) ; } ) ;
185
- it ( 'should not add categories to the YAML object if they are not shown' , ( ) => {
186
- const category = {
187
- text : 'Category 1' ,
188
- content : [ {
189
- test : { value : 'yaml' , show : false }
190
- } ] ,
191
- multiple : false ,
192
- indentation : '/' ,
193
- } ;
194
- let result = { test2 : 'test 2' } ;
195
- result = addCategoryToYamlObject ( category , result ) ;
196
- expect ( result ) . toEqual ( { test2 : 'test 2' } ) ;
197
- } ) ;
198
166
it ( 'should change the category' , ( ) => {
199
167
const expectedAction = {
200
168
type : constants . CHANGE_CATEGORY ,
@@ -243,5 +211,10 @@ describe('>>> Wizard actions tests', () => {
243
211
} ;
244
212
expect ( actions . validateInput ( 'Nav' , true ) ) . toEqual ( expectedAction ) ;
245
213
} ) ;
246
-
214
+ it ( 'should add indentation before wrapping in an array' , ( ) => {
215
+ const content = [ { test : '' } ] ;
216
+ const arrIndent = 'indent' ;
217
+ const result = handleArrayIndentation ( arrIndent , content ) ;
218
+ expect ( result ) . toEqual ( [ { indent : { test : '' } } ] ) ;
219
+ } )
247
220
} ) ;
0 commit comments