Commit 1da27551 authored by derek-knox's avatar derek-knox

Apply 3rd round of feedback

parent f048f4d3
...@@ -41,7 +41,7 @@ export default { ...@@ -41,7 +41,7 @@ export default {
:disabled="savingChanges" :disabled="savingChanges"
@click="$emit('editSettings')" @click="$emit('editSettings')"
> >
<span>{{ __('Settings') }}</span> {{ __('Settings') }}
</gl-button> </gl-button>
<gl-button <gl-button
ref="submit" ref="submit"
...@@ -50,7 +50,7 @@ export default { ...@@ -50,7 +50,7 @@ export default {
:loading="savingChanges" :loading="savingChanges"
@click="$emit('submit')" @click="$emit('submit')"
> >
<span>{{ __('Submit changes') }}</span> {{ __('Submit changes') }}
</gl-button> </gl-button>
</div> </div>
</div> </div>
......
...@@ -12,6 +12,7 @@ import UnsavedChangesConfirmDialog from '~/static_site_editor/components/unsaved ...@@ -12,6 +12,7 @@ import UnsavedChangesConfirmDialog from '~/static_site_editor/components/unsaved
import { import {
sourceContentTitle as title, sourceContentTitle as title,
sourceContentYAML as content, sourceContentYAML as content,
sourceContentHeaderObjYAML as headerSettings,
sourceContentBody as body, sourceContentBody as body,
returnUrl, returnUrl,
} from '../mock_data'; } from '../mock_data';
...@@ -170,25 +171,28 @@ describe('~/static_site_editor/components/edit_area.vue', () => { ...@@ -170,25 +171,28 @@ describe('~/static_site_editor/components/edit_area.vue', () => {
}); });
it('closes the edit drawer', () => { it('closes the edit drawer', () => {
buildWrapper({ isDrawerOpen: true });
findEditDrawer().vm.$emit('close'); findEditDrawer().vm.$emit('close');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.vm.isDrawerOpen).toBe(false);
expect(findEditDrawer().props('isOpen')).toBe(false); expect(findEditDrawer().props('isOpen')).toBe(false);
}); });
}); });
it('forwards the matter settings', () => { it('forwards the matter settings when the drawer is open', () => {
expect(findEditDrawer().props('settings')).toBe(wrapper.vm.editableMatter); findPublishToolbar().vm.$emit('editSettings');
jest.spyOn(wrapper.vm.parsedSource, 'matter').mockReturnValueOnce(headerSettings);
return wrapper.vm.$nextTick().then(() => {
expect(findEditDrawer().props('settings')).toEqual(headerSettings);
});
}); });
it('enables toolbar submit button', () => { it('enables toolbar submit button', () => {
expect(findPublishToolbar().props('hasSettings')).toBe(true); expect(findPublishToolbar().props('hasSettings')).toBe(true);
}); });
it('syncs matter changes', () => { it('syncs matter changes regardless of edit mode', () => {
const newSettings = { title: 'test' }; const newSettings = { title: 'test' };
const spySyncParsedSource = jest.spyOn(wrapper.vm.parsedSource, 'syncMatter'); const spySyncParsedSource = jest.spyOn(wrapper.vm.parsedSource, 'syncMatter');
...@@ -196,6 +200,18 @@ describe('~/static_site_editor/components/edit_area.vue', () => { ...@@ -196,6 +200,18 @@ describe('~/static_site_editor/components/edit_area.vue', () => {
expect(spySyncParsedSource).toHaveBeenCalledWith(newSettings); expect(spySyncParsedSource).toHaveBeenCalledWith(newSettings);
}); });
it('syncs matter changes to content in markdown mode', () => {
wrapper.setData({ editorMode: EDITOR_TYPES.markdown });
const newSettings = { title: 'test' };
findEditDrawer().vm.$emit('updateSettings', newSettings);
return wrapper.vm.$nextTick().then(() => {
expect(findRichContentEditor().props('content')).toContain('title: test');
});
});
}); });
describe('when content lacks front matter', () => { describe('when content lacks front matter', () => {
...@@ -221,6 +237,7 @@ describe('~/static_site_editor/components/edit_area.vue', () => { ...@@ -221,6 +237,7 @@ describe('~/static_site_editor/components/edit_area.vue', () => {
findPublishToolbar().vm.$emit('submit', content); findPublishToolbar().vm.$emit('submit', content);
expect(wrapper.emitted('submit')[0][0].content).toBe(`${content} format-pass format-pass`); expect(wrapper.emitted('submit')[0][0].content).toBe(`${content} format-pass format-pass`);
expect(wrapper.emitted('submit').length).toBe(1);
}); });
}); });
}); });
...@@ -61,7 +61,8 @@ describe('~/static_site_editor/components/edit_drawer.vue', () => { ...@@ -61,7 +61,8 @@ describe('~/static_site_editor/components/edit_drawer.vue', () => {
({ event, payload, finderFn }) => { ({ event, payload, finderFn }) => {
finderFn().vm.$emit(event, payload); finderFn().vm.$emit(event, payload);
expect(wrapper.emitted()[event][0][0]).toBe(payload); expect(wrapper.emitted(event)[0][0]).toBe(payload);
expect(wrapper.emitted(event).length).toBe(1);
}, },
); );
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment