Commit 592a5273 authored by Phil Hughes's avatar Phil Hughes Committed by Bob Van Landuyt

Updated frontend specs

parent 09639474
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Design management upload form component hides button if cant upload 1`] = `
<header
class="row-content-block border-top-0 p-2 d-flex"
>
<div>
<!---->
<input
accept="image/*"
class="hide"
multiple="multiple"
name="design_file"
type="file"
/>
</div>
</header>
`;
exports[`Design management upload form component renders loading icon 1`] = `
<header
class="row-content-block border-top-0 p-2 d-flex"
......
......@@ -4,10 +4,11 @@ import UploadForm from 'ee/design_management/components/upload/form.vue';
describe('Design management upload form component', () => {
let vm;
function createComponent(isSaving = false) {
function createComponent(isSaving = false, canUploadDesign = true) {
vm = shallowMount(UploadForm, {
propsData: {
isSaving,
canUploadDesign,
},
});
}
......@@ -24,6 +25,12 @@ describe('Design management upload form component', () => {
expect(vm.element).toMatchSnapshot();
});
it('hides button if cant upload', () => {
createComponent(false, false);
expect(vm.element).toMatchSnapshot();
});
describe('onFileUploadChange', () => {
it('emits upload event', () => {
createComponent();
......
......@@ -2,7 +2,9 @@
exports[`Design management index page designs renders designs list 1`] = `
<div>
<uploadform-stub />
<uploadform-stub
canuploaddesign="true"
/>
<div
class="mt-4"
......@@ -18,7 +20,9 @@ exports[`Design management index page designs renders designs list 1`] = `
exports[`Design management index page designs renders empty text 1`] = `
<div>
<uploadform-stub />
<uploadform-stub
canuploaddesign="true"
/>
<div
class="mt-4"
......@@ -34,7 +38,9 @@ exports[`Design management index page designs renders empty text 1`] = `
exports[`Design management index page designs renders error 1`] = `
<div>
<uploadform-stub />
<uploadform-stub
canuploaddesign="true"
/>
<div
class="mt-4"
......@@ -54,7 +60,9 @@ exports[`Design management index page designs renders error 1`] = `
exports[`Design management index page designs renders loading icon 1`] = `
<div>
<uploadform-stub />
<uploadform-stub
canuploaddesign="true"
/>
<div
class="mt-4"
......
......@@ -3,15 +3,19 @@ import Index from 'ee/design_management/pages/index.vue';
import uploadDesignQuery from 'ee/design_management/queries/uploadDesign.graphql';
describe('Design management index page', () => {
const mutate = jest.fn(() => Promise.resolve());
let mutate;
let vm;
function createComponent(loading = false) {
mutate = jest.fn(() => Promise.resolve());
const $apollo = {
queries: {
designs: {
loading,
},
permissions: {
loading,
},
},
mutate,
};
......@@ -20,6 +24,12 @@ describe('Design management index page', () => {
mocks: { $apollo },
stubs: ['router-view'],
});
vm.setData({
permissions: {
createDesign: true,
},
});
}
describe('designs', () => {
......@@ -86,6 +96,20 @@ describe('Design management index page', () => {
});
});
it('does not call apollo mutate if createDesign is false', () => {
createComponent();
vm.setData({
permissions: {
createDesign: false,
},
});
vm.vm.onUploadDesign([]);
expect(mutate).not.toHaveBeenCalled();
});
it('sets isSaving', () => {
createComponent();
......
......@@ -24,7 +24,11 @@ describe('Design management router', () => {
router,
mocks: {
$apollo: {
queries: { designs: { loading: true }, design: { loading: true } },
queries: {
designs: { loading: true },
design: { loading: true },
permissions: { loading: true },
},
},
},
});
......
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