-
Notifications
You must be signed in to change notification settings - Fork 296
/
BalStack.spec.ts
83 lines (74 loc) · 2.75 KB
/
BalStack.spec.ts
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { render } from '@testing-library/vue';
import BalStack from './BalStack.vue';
describe.only('BalStack', () => {
describe('When using BalStack', () => {
it('should render items', () => {
const { getByText } = render(BalStack, {
slots: {
default: '<div>First</div><div>Second</div><div>Third</div>'
}
});
// check that elements are actually rendered as children
expect(getByText('First')).toBeVisible();
expect(getByText('Second')).toBeVisible();
expect(getByText('Third')).toBeVisible();
});
it('should render items horizontally when the horizontal prop is supplied', () => {
const { getByText } = render(BalStack, {
slots: {
default: '<div>First</div><div>Second</div><div>Third</div>'
},
props: {
horizontal: true
}
});
// its fine to make this assumption here as we render the children without any wrappers
const stackEl = getByText('First').parentElement;
expect(stackEl).toHaveClass('flex-row');
});
it('should render items verticlly if vertical prop is supplied', () => {
const { getByText } = render(BalStack, {
slots: {
default: '<div>First</div><div>Second</div><div>Third</div>'
},
props: {
vertical: true
}
});
// its fine to make this assumption here as we render the children without any wrappers
const stackEl = getByText('First').parentElement;
expect(stackEl).toHaveClass('flex-col');
});
it('should render items with space between them', () => {
const { getByText } = render(BalStack, {
slots: {
default: '<div>First</div><div>Second</div><div>Third</div>'
},
props: {
vertical: true
}
});
// the default spacing unit (tailwind) is 4. So can be either mb-4 or mr-4
expect(getByText('First')).toHaveClass('mb-4');
expect(getByText('Second')).toHaveClass('mb-4');
// last el shouldn't have a spacing class
expect(getByText('Third')).not.toHaveClass('mb-4');
});
it('should render items with a border between them if withBorder prop is supplied', () => {
const { getByText } = render(BalStack, {
slots: {
default: '<div>First</div><div>Second</div><div>Third</div>'
},
props: {
vertical: true,
withBorder: true
}
});
// the default spacing unit (tailwind) is 4. So can be either mb-4 or mr-4
expect(getByText('First')).toHaveClass('mb-4 border-b');
expect(getByText('Second')).toHaveClass('mb-4 border-b');
// last el shouldn't have a spacing class
expect(getByText('Third')).not.toHaveClass('mb-4 border-b');
});
});
});