@eturnity/eturnity_reusable_components 7.45.5-EPDM-10609.7 → 7.45.5-EPDM-10609.8
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
@@ -8,11 +8,16 @@
|
|
8
8
|
@mouseenter="openTrigger == 'onHover' ? toggleShowInfo() : ''"
|
9
9
|
@mouseleave="openTrigger == 'onHover' ? toggleShowInfo() : ''"
|
10
10
|
>
|
11
|
-
<Dot
|
11
|
+
<Dot
|
12
|
+
v-if="type === 'dot'"
|
13
|
+
:color="dotColor"
|
14
|
+
data-test-id="infoText_dot"
|
15
|
+
/>
|
12
16
|
<IconComponent
|
13
17
|
v-else
|
14
18
|
:color="iconColor"
|
15
19
|
cursor="pointer"
|
20
|
+
data-test-id="infoText_info"
|
16
21
|
name="info"
|
17
22
|
:size="size"
|
18
23
|
/>
|
@@ -21,6 +26,7 @@
|
|
21
26
|
<TextOverlay
|
22
27
|
v-if="showInfo"
|
23
28
|
:align-arrow="alignArrow"
|
29
|
+
data-test-id="info_text_wrapper"
|
24
30
|
:half-computed-text-info-width="halfComputedTextInfoWidth"
|
25
31
|
:icon-size="size"
|
26
32
|
:info-position="infoPosition"
|
@@ -170,30 +176,26 @@
|
|
170
176
|
type: String,
|
171
177
|
required: false,
|
172
178
|
default: '14px',
|
173
|
-
type: String,
|
174
179
|
},
|
175
180
|
infoPosition: {
|
176
181
|
required: false,
|
177
|
-
default: 'bottom',
|
182
|
+
default: 'bottom', // top, bottom
|
178
183
|
type: String,
|
179
184
|
},
|
180
185
|
alignArrow: {
|
181
186
|
type: String,
|
182
187
|
required: false,
|
183
|
-
default: 'center',
|
184
|
-
type: String,
|
188
|
+
default: 'center', // left, center, right
|
185
189
|
},
|
186
190
|
openTrigger: {
|
187
191
|
type: String,
|
188
192
|
required: false,
|
189
193
|
default: 'onHover', // onHover, onClick
|
190
|
-
type: String,
|
191
194
|
},
|
192
195
|
width: {
|
193
196
|
type: String,
|
194
197
|
required: false,
|
195
198
|
default: '165px',
|
196
|
-
type: String,
|
197
199
|
},
|
198
200
|
maxWidth: {
|
199
201
|
default: '400px',
|
@@ -0,0 +1,62 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
import { mount } from '@vue/test-utils'
|
3
|
+
import InfoText from '@/components/infoText'
|
4
|
+
import theme from '@/assets/theme'
|
5
|
+
|
6
|
+
jest.mock('@/components/icon/iconCache.mjs', () => ({
|
7
|
+
// need to mock this due to how jest handles import.meta
|
8
|
+
fetchIcon: jest.fn(() => Promise.resolve('close_for_modals,_tool_tips.svg')),
|
9
|
+
}))
|
10
|
+
|
11
|
+
describe('InfoText Component', () => {
|
12
|
+
let wrapper
|
13
|
+
|
14
|
+
beforeEach(() => {
|
15
|
+
wrapper = mount(InfoText, {
|
16
|
+
props: {
|
17
|
+
text: 'default text',
|
18
|
+
size: '14px',
|
19
|
+
infoPosition: 'bottom',
|
20
|
+
alignArrow: 'center',
|
21
|
+
openTrigger: 'onHover',
|
22
|
+
width: '165px',
|
23
|
+
maxWidth: '165px',
|
24
|
+
shouldUseTeleport: false,
|
25
|
+
dotColor: '#00009f',
|
26
|
+
type: 'info',
|
27
|
+
},
|
28
|
+
global: {
|
29
|
+
provide: {
|
30
|
+
theme,
|
31
|
+
},
|
32
|
+
},
|
33
|
+
})
|
34
|
+
})
|
35
|
+
|
36
|
+
test('renders InfoText component with default props', () => {
|
37
|
+
expect(wrapper.find('[data-test-id="infoText_info"]').exists()).toBe(true)
|
38
|
+
expect(wrapper.vm.text).toContain('default text')
|
39
|
+
expect(wrapper.vm.size).toContain('14px')
|
40
|
+
expect(wrapper.vm.infoPosition).toContain('bottom')
|
41
|
+
expect(wrapper.vm.alignArrow).toContain('center')
|
42
|
+
})
|
43
|
+
|
44
|
+
test('openTrigger prop is set to onClick', async () => {
|
45
|
+
await wrapper.setProps({ openTrigger: 'onClick' })
|
46
|
+
|
47
|
+
//should not see text upon hover
|
48
|
+
expect(wrapper.find('[data-test-id="info_text_wrapper"]').exists()).toBe(
|
49
|
+
false
|
50
|
+
)
|
51
|
+
//should see text upon click
|
52
|
+
await wrapper.find('[data-test-id="infoText_trigger"]').trigger('click')
|
53
|
+
expect(wrapper.find('[data-test-id="info_text_wrapper"]').exists()).toBe(
|
54
|
+
true
|
55
|
+
)
|
56
|
+
})
|
57
|
+
|
58
|
+
test('position type is dot', async () => {
|
59
|
+
await wrapper.setProps({ type: 'dot' })
|
60
|
+
expect(wrapper.find('[data-test-id="infoText_dot"]').exists()).toBe(true)
|
61
|
+
})
|
62
|
+
})
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import InfoText from './index.vue'
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: 'infoText',
|
5
|
+
component: InfoText,
|
6
|
+
tags: ['autodocs'],
|
7
|
+
parameters: {
|
8
|
+
layout: 'centered',
|
9
|
+
},
|
10
|
+
}
|
11
|
+
|
12
|
+
// import InfoText from "@eturnity/eturnity_reusable_components/src/components/infoText"
|
13
|
+
//To use:
|
14
|
+
// <info-text
|
15
|
+
// text="Veritatis et quasi architecto beatae vitae"
|
16
|
+
// size="20px"
|
17
|
+
// alignArrow="right" // which side the arrow should be on
|
18
|
+
// />
|
19
|
+
|
20
|
+
export const Default = {
|
21
|
+
args: {
|
22
|
+
text: 'default text',
|
23
|
+
size: '14px',
|
24
|
+
infoPosition: 'bottom',
|
25
|
+
alignArrow: 'center',
|
26
|
+
openTrigger: 'onHover',
|
27
|
+
width: '165px',
|
28
|
+
maxWidth: '165px',
|
29
|
+
shouldUseTeleport: false,
|
30
|
+
dotColor: '#00009f',
|
31
|
+
type: 'info',
|
32
|
+
},
|
33
|
+
}
|
34
|
+
|
35
|
+
export const Dot = {
|
36
|
+
args: {
|
37
|
+
...Default.args,
|
38
|
+
type: 'dot',
|
39
|
+
},
|
40
|
+
}
|
41
|
+
|
42
|
+
//will only show the info text on click
|
43
|
+
export const OnClick = {
|
44
|
+
args: {
|
45
|
+
...Default.args,
|
46
|
+
openTrigger: 'onClick',
|
47
|
+
},
|
48
|
+
}
|