forked from swiftlang/swift-docc-render
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButtonLink.spec.js
66 lines (56 loc) · 1.75 KB
/
ButtonLink.spec.js
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
/**
* This source file is part of the Swift.org open source project
*
* Copyright (c) 2021 Apple Inc. and the Swift project authors
* Licensed under Apache License v2.0 with Runtime Library Exception
*
* See https://swift.org/LICENSE.txt for license information
* See https://swift.org/CONTRIBUTORS.txt for Swift project authors
*/
import { shallowMount } from '@vue/test-utils';
import ButtonLink from 'docc-render/components/ButtonLink.vue';
const { Reference } = ButtonLink.components;
describe('ButtonLink', () => {
const propsData = {
url: 'foo.com',
};
const propsDataWithoutUrl = {
title: 'Foo',
};
const slotValue = 'SlotFoo';
it('renders a `Reference` with "button-cta" classes if there is url on props', () => {
const wrapper = shallowMount(ButtonLink, {
propsData,
slots: {
default: slotValue,
},
});
const ref = wrapper.find(Reference);
expect(ref.exists()).toBe(true);
expect(ref.props('url')).toBe(propsData.url);
expect(ref.classes('button-cta')).toBe(true);
expect(ref.classes('is-dark')).toBe(false);
expect(ref.text()).toBe(slotValue);
});
it('renders a button with "button-cta" classes if there is url on props', () => {
const wrapper = shallowMount(ButtonLink, {
propsData: propsDataWithoutUrl,
slots: {
default: slotValue,
},
});
const button = wrapper.find('button');
expect(button.exists()).toBe(true);
expect(button.classes('button-cta')).toBe(true);
expect(button.text()).toBe(slotValue);
});
it('renders a dark button', () => {
const wrapper = shallowMount(ButtonLink, {
propsData: {
...propsData,
isDark: true,
},
});
expect(wrapper.classes()).toContain('is-dark');
});
});