@@ -29,14 +29,14 @@ describe('Render Main Component', () => {
2929 } ;
3030
3131 wrapper = shallow (
32- < Main
33- classes = { classes }
34- model = { model }
35- configuration = { configuration }
36- onModelChanged = { onChange }
37- imageSupport = { { } }
38- uploadSoundSupport = { { } }
39- /> ,
32+ < Main
33+ classes = { classes }
34+ model = { model }
35+ configuration = { configuration }
36+ onModelChanged = { onChange }
37+ imageSupport = { { } }
38+ uploadSoundSupport = { { } }
39+ /> ,
4040 ) ;
4141
4242 instance = wrapper . instance ( ) ;
@@ -50,99 +50,89 @@ describe('Render Main Component', () => {
5050 it ( 'changeTeacherInstructions calls onModelChanged' , ( ) => {
5151 const updatedModel = {
5252 ...model ,
53- passages : [
54- { ...model . passages [ 0 ] , teacherInstructions : 'Teacher Instructions' }
55- ]
53+ passages : [ { ...model . passages [ 0 ] , teacherInstructions : 'Teacher Instructions' } ] ,
5654 } ;
57- instance . handleChange ( 'teacherInstructions' , 'Teacher Instructions' , 0 ) ;
55+ instance . handleChange ( 'teacherInstructions' , 'Teacher Instructions' , 0 ) ;
5856 expect ( onChange ) . toBeCalledWith ( updatedModel ) ;
5957 } ) ;
6058
6159 it ( 'changeTitle calls onModelChanged' , ( ) => {
6260 const updatedModel = {
6361 ...model ,
64- passages : [
65- { ...model . passages [ 0 ] , title : 'New Title' }
66- ]
62+ passages : [ { ...model . passages [ 0 ] , title : 'New Title' } ] ,
6763 } ;
68- instance . handleChange ( 'title' , 'New Title' , 0 ) ;
64+ instance . handleChange ( 'title' , 'New Title' , 0 ) ;
6965 expect ( onChange ) . toBeCalledWith ( updatedModel ) ;
7066 } ) ;
7167
7268 it ( 'changeSubtitle calls onModelChanged' , ( ) => {
7369 const updatedModel = {
7470 ...model ,
75- passages : [
76- { ...model . passages [ 0 ] , subtitle : 'New Subtitle' }
77- ]
71+ passages : [ { ...model . passages [ 0 ] , subtitle : 'New Subtitle' } ] ,
7872 } ;
79- instance . handleChange ( 'subtitle' , 'New Subtitle' , 0 ) ;
73+ instance . handleChange ( 'subtitle' , 'New Subtitle' , 0 ) ;
8074 expect ( onChange ) . toBeCalledWith ( updatedModel ) ;
8175 } ) ;
8276
8377 it ( 'changeAuthor calls onModelChanged' , ( ) => {
8478 const updatedModel = {
8579 ...model ,
86- passages : [
87- { ...model . passages [ 0 ] , author : 'New Author' }
88- ]
80+ passages : [ { ...model . passages [ 0 ] , author : 'New Author' } ] ,
8981 } ;
90- instance . handleChange ( 'author' , 'New Author' , 0 ) ;
82+ instance . handleChange ( 'author' , 'New Author' , 0 ) ;
9183 expect ( onChange ) . toBeCalledWith ( updatedModel ) ;
9284 } ) ;
9385
9486 it ( 'changeText calls onModelChanged' , ( ) => {
9587 const updatedModel = {
9688 ...model ,
97- passages : [
98- { ...model . passages [ 0 ] , text : 'New Text' }
99- ]
89+ passages : [ { ...model . passages [ 0 ] , text : 'New Text' } ] ,
10090 } ;
101- instance . handleChange ( 'text' , 'New Text' , 0 ) ;
91+ instance . handleChange ( 'text' , 'New Text' , 0 ) ;
10292 expect ( onChange ) . toBeCalledWith ( updatedModel ) ;
10393 } ) ;
10494 } ) ;
10595
10696 describe ( 'UI Rendering' , ( ) => {
97+ it ( 'renders teacher instructions input when enabled' , ( ) => {
98+ wrapper . setProps ( {
99+ model : { ...model , teacherInstructionsEnabled : true } ,
100+ configuration : {
101+ ...configuration ,
102+ teacherInstructions : { label : 'Teacher Instructions' } ,
103+ } ,
104+ } ) ;
105+ expect ( wrapper . find ( InputContainer ) . at ( 0 ) . prop ( 'label' ) ) . toEqual ( 'Teacher Instructions' ) ;
106+ } ) ;
107+
107108 it ( 'renders title input when enabled' , ( ) => {
108109 wrapper . setProps ( {
109110 model : { ...model , titleEnabled : true } ,
110- configuration : { ...configuration , title : { label : 'Title' } }
111+ configuration : { ...configuration , title : { label : 'Title' } } ,
111112 } ) ;
112- expect ( wrapper . find ( InputContainer ) . at ( 0 ) . prop ( 'label' ) ) . toEqual ( 'Title' ) ;
113+ expect ( wrapper . find ( InputContainer ) . at ( 1 ) . prop ( 'label' ) ) . toEqual ( 'Title' ) ;
113114 } ) ;
114115
115116 it ( 'renders subtitle input when enabled' , ( ) => {
116117 wrapper . setProps ( {
117118 model : { ...model , subtitleEnabled : true } ,
118- configuration : { ...configuration , subtitle : { label : 'Subtitle' } }
119+ configuration : { ...configuration , subtitle : { label : 'Subtitle' } } ,
119120 } ) ;
120- expect ( wrapper . find ( InputContainer ) . at ( 1 ) . prop ( 'label' ) ) . toEqual ( 'Subtitle' ) ;
121+ expect ( wrapper . find ( InputContainer ) . at ( 2 ) . prop ( 'label' ) ) . toEqual ( 'Subtitle' ) ;
121122 } ) ;
122123
123124 it ( 'renders author input when enabled' , ( ) => {
124125 wrapper . setProps ( {
125126 model : { ...model , authorEnabled : true } ,
126- configuration : { ...configuration , author : { label : 'Author' } }
127+ configuration : { ...configuration , author : { label : 'Author' } } ,
127128 } ) ;
128- expect ( wrapper . find ( InputContainer ) . at ( 2 ) . prop ( 'label' ) ) . toEqual ( 'Author' ) ;
129- } ) ;
130-
131- it ( 'renders teacher instructions input when enabled' , ( ) => {
132- wrapper . setProps ( {
133- model : { ...model , teacherInstructionsEnabled : true } ,
134- configuration : {
135- ...configuration ,
136- teacherInstructions : { label : 'Teacher Instructions' }
137- }
138- } ) ;
139- expect ( wrapper . find ( InputContainer ) . at ( 3 ) . prop ( 'label' ) ) . toEqual ( 'Teacher Instructions' ) ;
129+ expect ( wrapper . find ( InputContainer ) . at ( 3 ) . prop ( 'label' ) ) . toEqual ( 'Author' ) ;
140130 } ) ;
141131
142132 it ( 'renders text input when enabled' , ( ) => {
143133 wrapper . setProps ( {
144134 model : { ...model , textEnabled : true } ,
145- configuration : { ...configuration , text : { label : 'Text' } }
135+ configuration : { ...configuration , text : { label : 'Text' } } ,
146136 } ) ;
147137 expect ( wrapper . find ( InputContainer ) . at ( 4 ) . prop ( 'label' ) ) . toEqual ( 'Text' ) ;
148138 } ) ;
@@ -153,13 +143,17 @@ describe('Render Main Component', () => {
153143 wrapper . setProps ( {
154144 model : {
155145 ...model ,
156- errors : { teacherInstructions : 'Teacher Instructions is required' } ,
157- teacherInstructionsEnabled : true
146+ errors : {
147+ passages : {
148+ 0 : { teacherInstructions : 'Teacher Instructions is required' } ,
149+ } ,
150+ } ,
151+ teacherInstructionsEnabled : true ,
158152 } ,
159153 configuration : {
160154 ...configuration ,
161- teacherInstructions : { label : 'Teacher Instructions' }
162- }
155+ teacherInstructions : { label : 'Teacher Instructions' } ,
156+ } ,
163157 } ) ;
164158 expect ( wrapper . find ( '.mockErrorText' ) . text ( ) ) . toEqual ( 'Teacher Instructions is required' ) ;
165159 } ) ;
@@ -168,46 +162,62 @@ describe('Render Main Component', () => {
168162 wrapper . setProps ( {
169163 model : {
170164 ...model ,
171- errors : { title : 'Title is required' } ,
172- titleEnabled : true
165+ errors : {
166+ passages : {
167+ 0 : { title : 'Title is required' } ,
168+ } ,
169+ } ,
170+ titleEnabled : true ,
173171 } ,
174- configuration : { ...configuration , title : { label : 'Title' } }
172+ configuration : { ...configuration , title : { label : 'Title' } } ,
175173 } ) ;
176- expect ( wrapper . find ( '.mockErrorText' ) . at ( 0 ) . text ( ) ) . toEqual ( 'Title is required' ) ;
174+ expect ( wrapper . find ( '.mockErrorText' ) . text ( ) ) . toEqual ( 'Title is required' ) ;
177175 } ) ;
178176
179177 it ( 'displays subtitle error when provided' , ( ) => {
180178 wrapper . setProps ( {
181179 model : {
182180 ...model ,
183- errors : { subtitle : 'Subtitle is required' } ,
184- subtitleEnabled : true
181+ errors : {
182+ passages : {
183+ 0 : { subtitle : 'Subtitle is required' } ,
184+ } ,
185+ } ,
186+ subtitleEnabled : true ,
185187 } ,
186- configuration : { ...configuration , subtitle : { label : 'Subtitle' } }
188+ configuration : { ...configuration , subtitle : { label : 'Subtitle' } } ,
187189 } ) ;
188- expect ( wrapper . find ( '.mockErrorText' ) . at ( 0 ) . text ( ) ) . toEqual ( 'Subtitle is required' ) ;
190+ expect ( wrapper . find ( '.mockErrorText' ) . text ( ) ) . toEqual ( 'Subtitle is required' ) ;
189191 } ) ;
190192
191193 it ( 'displays author error when provided' , ( ) => {
192194 wrapper . setProps ( {
193195 model : {
194196 ...model ,
195- errors : { author : 'Author is required' } ,
196- authorEnabled : true
197+ errors : {
198+ passages : {
199+ 0 : { author : 'Author is required' } ,
200+ } ,
201+ } ,
202+ authorEnabled : true ,
197203 } ,
198- configuration : { ...configuration , author : { label : 'Author' } }
204+ configuration : { ...configuration , author : { label : 'Author' } } ,
199205 } ) ;
200- expect ( wrapper . find ( '.mockErrorText' ) . at ( 0 ) . text ( ) ) . toEqual ( 'Author is required' ) ;
206+ expect ( wrapper . find ( '.mockErrorText' ) . text ( ) ) . toEqual ( 'Author is required' ) ;
201207 } ) ;
202208
203209 it ( 'displays text error when provided' , ( ) => {
204210 wrapper . setProps ( {
205211 model : {
206212 ...model ,
207- errors : { text : 'Text is required' } ,
208- textEnabled : true
213+ errors : {
214+ passages : {
215+ 0 : { text : 'Text is required' } ,
216+ } ,
217+ } ,
218+ textEnabled : true ,
209219 } ,
210- configuration : { ...configuration , text : { label : 'Text' } }
220+ configuration : { ...configuration , text : { label : 'Text' } } ,
211221 } ) ;
212222 expect ( wrapper . find ( '.mockErrorText' ) . at ( 0 ) . text ( ) ) . toEqual ( 'Text is required' ) ;
213223 } ) ;
0 commit comments