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
52
53
54
55
56
57
58
59
60
61
|
import { shallowMount } from '@vue/test-utils';
import { GlEmptyState, GlTable } from '@gitlab/ui';
import InstanceTable from '~/google_cloud/databases/cloudsql/instance_table.vue';
describe('google_cloud/databases/cloudsql/instance_table', () => {
let wrapper;
const findEmptyState = () => wrapper.findComponent(GlEmptyState);
const findTable = () => wrapper.findComponent(GlTable);
describe('when there are no instances', () => {
beforeEach(() => {
const propsData = {
cloudsqlInstances: [],
emptyIllustrationUrl: '#empty-illustration-url',
};
wrapper = shallowMount(InstanceTable, { propsData });
});
it('should depict empty state', () => {
const emptyState = findEmptyState();
expect(emptyState.exists()).toBe(true);
expect(emptyState.attributes('title')).toBe(InstanceTable.i18n.noInstancesTitle);
expect(emptyState.attributes('description')).toBe(InstanceTable.i18n.noInstancesDescription);
});
});
describe('when there are three instances', () => {
beforeEach(() => {
const propsData = {
cloudsqlInstances: [
{
ref: '*',
gcp_project: 'test-gcp-project',
instance_name: 'postgres-14-instance',
version: 'POSTGRES_14',
},
{
ref: 'production',
gcp_project: 'prod-gcp-project',
instance_name: 'postgres-14-instance',
version: 'POSTGRES_14',
},
{
ref: 'staging',
gcp_project: 'test-gcp-project',
instance_name: 'postgres-14-instance',
version: 'POSTGRES_14',
},
],
emptyIllustrationUrl: '#empty-illustration-url',
};
wrapper = shallowMount(InstanceTable, { propsData });
});
it('should contain a table', () => {
const table = findTable();
expect(table.exists()).toBe(true);
});
});
});
|