@eturnity/eturnity_reusable_components 7.51.4 → 7.51.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -3,24 +3,14 @@ import IconCollection from './iconCollection.vue'
|
|
3
3
|
export default {
|
4
4
|
title: 'icon',
|
5
5
|
component: IconCollection,
|
6
|
-
// argTypes: {},
|
7
6
|
}
|
8
7
|
|
9
|
-
const Template = (args
|
10
|
-
// Components used in your story `template` are defined in the `components` object
|
8
|
+
const Template = (args) => ({
|
11
9
|
components: { IconCollection },
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
// import Icon from "@eturnity/eturnity_reusable_components/src/components/icon"
|
17
|
-
// How to use:
|
18
|
-
//<icon
|
19
|
-
// name="House" //required. a svg file named [name].svg should be present in /assets/svgIcons
|
20
|
-
// color="red"
|
21
|
-
// hoveredColor="blue"
|
22
|
-
// size="60px" by default, this is 30px
|
23
|
-
// />
|
10
|
+
setup() {
|
11
|
+
return { args }
|
12
|
+
},
|
13
|
+
template: '<IconCollection v-bind="args" />',
|
24
14
|
})
|
25
15
|
|
26
16
|
export const Default = Template.bind({})
|
@@ -28,14 +18,14 @@ Default.args = {
|
|
28
18
|
size: '30px',
|
29
19
|
}
|
30
20
|
|
31
|
-
export const
|
32
|
-
|
21
|
+
export const WithColor = Template.bind({})
|
22
|
+
WithColor.args = {
|
33
23
|
size: '30px',
|
34
24
|
color: 'red',
|
35
25
|
hoveredColor: 'crimson',
|
36
26
|
}
|
37
27
|
|
38
|
-
export const
|
39
|
-
|
28
|
+
export const Large = Template.bind({})
|
29
|
+
Large.args = {
|
40
30
|
size: '60px',
|
41
31
|
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { mount } from '@vue/test-utils'
|
2
|
+
import RCIcon from '@/components/icon'
|
3
|
+
import theme from '@/assets/theme'
|
4
|
+
import 'jest-styled-components'
|
5
|
+
jest.mock('@/components/icon/iconCache.mjs', () => ({
|
6
|
+
fetchIcon: jest.fn(() => Promise.resolve('mocked-icon-url.svg')),
|
7
|
+
}))
|
8
|
+
|
9
|
+
describe('RCIcon.vue', () => {
|
10
|
+
it('renders icon with default props', async () => {
|
11
|
+
const wrapper = mount(RCIcon, {
|
12
|
+
props: { name: 'House' },
|
13
|
+
global: {
|
14
|
+
provide: {
|
15
|
+
theme,
|
16
|
+
},
|
17
|
+
},
|
18
|
+
})
|
19
|
+
|
20
|
+
const iconWrapper = wrapper.find('[data-test-id="icon_wrapper"]')
|
21
|
+
const iconImage = wrapper.find('[data-test-id="icon_image"]')
|
22
|
+
|
23
|
+
expect(iconWrapper.exists()).toBe(true)
|
24
|
+
expect(iconImage.exists()).toBe(true)
|
25
|
+
expect(wrapper.props('size')).toBe('30px')
|
26
|
+
})
|
27
|
+
|
28
|
+
it('renders striked line when isStriked is true', async () => {
|
29
|
+
const wrapper = mount(RCIcon, {
|
30
|
+
props: {
|
31
|
+
name: 'House',
|
32
|
+
isStriked: true,
|
33
|
+
color: 'red',
|
34
|
+
},
|
35
|
+
global: {
|
36
|
+
provide: {
|
37
|
+
theme,
|
38
|
+
},
|
39
|
+
},
|
40
|
+
})
|
41
|
+
|
42
|
+
const strikedLine = wrapper.find('[data-test-id="icon_striked_line"]')
|
43
|
+
expect(strikedLine.exists()).toBe(true)
|
44
|
+
})
|
45
|
+
|
46
|
+
it('applies correct styling based on props', async () => {
|
47
|
+
const wrapper = mount(RCIcon, {
|
48
|
+
props: {
|
49
|
+
name: 'House',
|
50
|
+
size: '60px',
|
51
|
+
color: 'red',
|
52
|
+
hoveredColor: 'blue',
|
53
|
+
backgroundColor: 'yellow',
|
54
|
+
},
|
55
|
+
global: {
|
56
|
+
provide: {
|
57
|
+
theme,
|
58
|
+
},
|
59
|
+
},
|
60
|
+
})
|
61
|
+
|
62
|
+
const iconImage = wrapper.find('[data-test-id="icon_image"]')
|
63
|
+
expect(iconImage.exists()).toBe(true)
|
64
|
+
// Add assertions for styling if needed
|
65
|
+
})
|
66
|
+
})
|
@@ -2,6 +2,7 @@
|
|
2
2
|
<Wrapper>
|
3
3
|
<IconWrapper v-for="iconItem in iconList" :key="iconItem.name">
|
4
4
|
<div>
|
5
|
+
color:{{ color }}
|
5
6
|
<RCIcon
|
6
7
|
:color="color"
|
7
8
|
:hovered-color="hoveredColor"
|
@@ -39,9 +40,9 @@
|
|
39
40
|
name: 'CollectionComponent',
|
40
41
|
components: { RCIcon, IconWrapper, Wrapper },
|
41
42
|
props: {
|
42
|
-
size: { required: false },
|
43
|
-
color: { required: false },
|
44
|
-
hoveredColor: { required: false },
|
43
|
+
size: { required: false, type: String, default: '30px' },
|
44
|
+
color: { required: false, type: String, default: 'white' },
|
45
|
+
hoveredColor: { required: false, type: String, default: 'grey' },
|
45
46
|
},
|
46
47
|
data() {
|
47
48
|
return {
|
@@ -1,14 +1,24 @@
|
|
1
1
|
<template>
|
2
|
-
<Wrapper
|
2
|
+
<Wrapper
|
3
|
+
:cursor="cursor"
|
4
|
+
data-test-id="icon_wrapper"
|
5
|
+
:disabled="disabled"
|
6
|
+
:size="size"
|
7
|
+
>
|
3
8
|
<IconImage
|
4
9
|
:animation="animation"
|
5
10
|
:background-color="backgroundColor"
|
6
11
|
:color="color"
|
12
|
+
data-test-id="icon_image"
|
7
13
|
:hovered-color="hoveredColor"
|
8
14
|
>
|
9
|
-
<i v-html="icon.html"></i>
|
15
|
+
<i data-test-id="icon_svg" v-html="icon.html"></i>
|
10
16
|
</IconImage>
|
11
|
-
<StrikedLine
|
17
|
+
<StrikedLine
|
18
|
+
v-if="isStriked"
|
19
|
+
:color="color"
|
20
|
+
data-test-id="icon_striked_line"
|
21
|
+
/>
|
12
22
|
</Wrapper>
|
13
23
|
</template>
|
14
24
|
|