diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-26 12:07:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-26 12:07:52 +0300 |
commit | 7e019504f5ac6decde690565857238e7e59aa034 (patch) | |
tree | fab8832b40e25fc9bc1ae54b9303b95ea146b5d5 /spec/frontend/vue_shared | |
parent | 116d4e56e83a1f408afe710ce070e699ba206475 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_shared')
-rw-r--r-- | spec/frontend/vue_shared/components/ordered_layout_spec.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/ordered_layout_spec.js b/spec/frontend/vue_shared/components/ordered_layout_spec.js new file mode 100644 index 00000000000..e8667d9ee4a --- /dev/null +++ b/spec/frontend/vue_shared/components/ordered_layout_spec.js @@ -0,0 +1,63 @@ +import { mount } from '@vue/test-utils'; +import orderedLayout from '~/vue_shared/components/ordered_layout.vue'; + +const children = ` + <template v-slot:header> + <header></header> + </template> + <template v-slot:footer> + <footer></footer> + </template> + `; + +const TestComponent = { + components: { orderedLayout }, + template: ` + <div> + <ordered-layout v-bind="$attrs"> + ${children} + </ordered-layout> + </div> + `, +}; + +const regularSlotOrder = ['header', 'footer']; + +describe('Ordered Layout', () => { + let wrapper; + + const verifyOrder = () => + wrapper.findAll('footer,header').wrappers.map(x => (x.is('footer') ? 'footer' : 'header')); + + const createComponent = (props = {}) => { + wrapper = mount(TestComponent, { + propsData: props, + }); + }; + + afterEach(() => { + wrapper.destroy(); + }); + + describe('when slotKeys are in initial slot order', () => { + beforeEach(() => { + createComponent({ slotKeys: regularSlotOrder }); + }); + + it('confirms order of the component is reflective of slotKeys', () => { + expect(verifyOrder()).toEqual(regularSlotOrder); + }); + }); + + describe('when slotKeys reverse the order of the props', () => { + const reversedSlotOrder = regularSlotOrder.reverse(); + + beforeEach(() => { + createComponent({ slotKeys: reversedSlotOrder }); + }); + + it('confirms order of the component is reflective of slotKeys', () => { + expect(verifyOrder()).toEqual(reversedSlotOrder); + }); + }); +}); |