forked from swiftlang/swift-docc-render
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCardCover.spec.js
68 lines (62 loc) · 1.79 KB
/
CardCover.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
67
68
/**
* This source file is part of the Swift.org open source project
*
* Copyright (c) 2022 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 CardCover from 'docc-render/components/CardCover.vue';
import ImageAsset from 'docc-render/components/ImageAsset.vue';
const lightVariant = {
url: 'https://image.light',
size: { width: 42, height: 42 },
traits: ['1x', '2x', 'light'],
};
const darkVariant = {
url: 'https://image.dark',
size: { width: 42, height: 42 },
traits: ['1x', '2x', 'dark'],
};
const variants = [lightVariant, darkVariant];
const defaultProps = {
variants,
alt: 'alt text',
};
const mountCover = ({ propsData, ...rest } = {}) => {
const config = {
propsData: {
...defaultProps,
...propsData,
},
...rest,
};
return shallowMount(CardCover, config);
};
describe('CardCover', () => {
it('renders an `<ImageAsset>`', () => {
const wrapper = mountCover();
const asset = wrapper.find(ImageAsset);
expect(asset.classes()).toContain('card-cover');
expect(asset.props('variants')).toEqual(defaultProps.variants);
expect(asset.props('alt')).toEqual(defaultProps.alt);
});
it('exposes a default slot', () => {
let slotProps = null;
const wrapper = mountCover({
scopedSlots: {
default: (props) => {
slotProps = props;
return 'Slot Content';
},
},
});
expect(wrapper.find('.card-cover').exists()).toBe(false);
expect(slotProps).toEqual({
classes: 'card-cover',
});
expect(wrapper.text()).toBe('Slot Content');
});
});