blob: 2bf9158628cb1cf4b659517537cbee6d86e7ee9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import GkeSubmitButton from '~/create_cluster/gke_cluster/components/gke_submit_button.vue';
Vue.use(Vuex);
describe('GkeSubmitButton', () => {
let wrapper;
let store;
let hasValidData;
const buildStore = () =>
new Vuex.Store({
getters: {
hasValidData,
},
});
const buildWrapper = () =>
shallowMount(GkeSubmitButton, {
store,
});
const bootstrap = () => {
store = buildStore();
wrapper = buildWrapper();
};
beforeEach(() => {
hasValidData = jest.fn();
});
afterEach(() => {
wrapper.destroy();
});
it('is disabled when hasValidData is false', () => {
hasValidData.mockReturnValueOnce(false);
bootstrap();
expect(wrapper.attributes('disabled')).toBe('disabled');
});
it('is not disabled when hasValidData is true', () => {
hasValidData.mockReturnValueOnce(true);
bootstrap();
expect(wrapper.attributes('disabled')).toBeFalsy();
});
});
|