Skip to content

Commit e25b3cd

Browse files
Merge pull request #2144 from pie-framework/develop
Merge
2 parents 7b5b0ce + e15db95 commit e25b3cd

File tree

7 files changed

+248
-197
lines changed

7 files changed

+248
-197
lines changed

packages/passage/configure/src/__tests__/__snapshots__/main.test.js.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ exports[`Render Main Component Match Snapshot 1`] = `
174174
>
175175
<InputContainer
176176
className="mockInputContainer"
177-
label="Title"
177+
label="Teacher Instructions"
178178
>
179179
<EditableHtml
180180
activePlugins={
@@ -219,13 +219,15 @@ exports[`Render Main Component Match Snapshot 1`] = `
219219
"mmlOutput": false,
220220
}
221221
}
222+
maxImageHeight={300}
223+
maxImageWidth={300}
222224
nonEmpty={false}
223225
onChange={[Function]}
224226
onDone={[Function]}
225227
pluginProps={
226228
Object {
227229
"audio": Object {
228-
"disabled": true,
230+
"disabled": false,
229231
},
230232
"blockquote": Object {
231233
"disabled": true,
@@ -234,18 +236,18 @@ exports[`Render Main Component Match Snapshot 1`] = `
234236
"disabled": true,
235237
},
236238
"image": Object {
237-
"disabled": true,
239+
"disabled": false,
238240
},
239241
"video": Object {
240-
"disabled": true,
242+
"disabled": false,
241243
},
242244
}
243245
}
244246
/>
245247
</InputContainer>
246248
<InputContainer
247249
className="mockInputContainer"
248-
label="Subtitle"
250+
label="Title"
249251
>
250252
<EditableHtml
251253
activePlugins={
@@ -316,7 +318,7 @@ exports[`Render Main Component Match Snapshot 1`] = `
316318
</InputContainer>
317319
<InputContainer
318320
className="mockInputContainer"
319-
label="Author"
321+
label="Subtitle"
320322
>
321323
<EditableHtml
322324
activePlugins={
@@ -387,7 +389,7 @@ exports[`Render Main Component Match Snapshot 1`] = `
387389
</InputContainer>
388390
<InputContainer
389391
className="mockInputContainer"
390-
label="Teacher Instructions"
392+
label="Author"
391393
>
392394
<EditableHtml
393395
activePlugins={
@@ -432,15 +434,13 @@ exports[`Render Main Component Match Snapshot 1`] = `
432434
"mmlOutput": false,
433435
}
434436
}
435-
maxImageHeight={300}
436-
maxImageWidth={300}
437437
nonEmpty={false}
438438
onChange={[Function]}
439439
onDone={[Function]}
440440
pluginProps={
441441
Object {
442442
"audio": Object {
443-
"disabled": false,
443+
"disabled": true,
444444
},
445445
"blockquote": Object {
446446
"disabled": true,
@@ -449,10 +449,10 @@ exports[`Render Main Component Match Snapshot 1`] = `
449449
"disabled": true,
450450
},
451451
"image": Object {
452-
"disabled": false,
452+
"disabled": true,
453453
},
454454
"video": Object {
455-
"disabled": false,
455+
"disabled": true,
456456
},
457457
}
458458
}

packages/passage/configure/src/__tests__/main.test.js

Lines changed: 75 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)