@eturnity/eturnity_reusable_components 7.37.4 → 7.37.5

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "7.37.4",
3
+ "version": "7.37.5",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -0,0 +1,95 @@
1
+ import PageTitle from './index.vue'
2
+ import theme from '@/assets/theme'
3
+
4
+ export default {
5
+ title: 'PageTitle',
6
+ component: PageTitle,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ color: {
10
+ control: {
11
+ type: 'color',
12
+ presetColors: [theme.colors.primary],
13
+ },
14
+ },
15
+ uppercase: {
16
+ control: {
17
+ type: 'boolean',
18
+ },
19
+ },
20
+ infoText: {
21
+ description: 'Text for tooltip',
22
+ },
23
+ infoAlign: {
24
+ description: 'Tooltip alignment',
25
+ control: 'multi-select',
26
+ options: ['center', 'right', 'left'],
27
+ },
28
+ },
29
+ tags: ['autodocs'],
30
+ }
31
+
32
+ // To use:
33
+ // <PageTitle
34
+ // text="My Page Title"
35
+ // color="red"
36
+ // font-size="13px"
37
+ // uppercase="true"
38
+ // info-text="My info text"
39
+ // info-align="center"
40
+ // />
41
+
42
+ export const Default = {
43
+ args: {
44
+ text: 'My Page Title',
45
+ color: theme.colors.black,
46
+ uppercase: true,
47
+ infoText: '',
48
+ infoAlign: 'center',
49
+ },
50
+ }
51
+
52
+ export const TitleColor = {
53
+ args: {
54
+ ...Default.args,
55
+ color: theme.colors.primary,
56
+ },
57
+ }
58
+
59
+ export const TitleFontSize = {
60
+ args: {
61
+ ...Default.args,
62
+ fontSize: '13px',
63
+ },
64
+ }
65
+
66
+ export const TitleNotUppercase = {
67
+ args: {
68
+ ...Default.args,
69
+ uppercase: false,
70
+ },
71
+ }
72
+
73
+ export const TitleTooltip = {
74
+ name: 'Title Tooltip Default Alignment',
75
+ args: {
76
+ ...Default.args,
77
+ infoText: 'My tooltip info',
78
+ },
79
+ }
80
+
81
+ export const TitleTooltipRightAlignment = {
82
+ args: {
83
+ ...TitleTooltip.args,
84
+ infoText: 'My tooltip info',
85
+ infoAlign: 'right',
86
+ },
87
+ }
88
+
89
+ export const TitleTooltipLeftAlignment = {
90
+ args: {
91
+ ...TitleTooltip.args,
92
+ infoText: 'My tooltip info',
93
+ infoAlign: 'left',
94
+ },
95
+ }
@@ -1,18 +1,32 @@
1
1
  <template>
2
- <TitleWrap :has-info-text="!!infoText">
3
- <TitleText :color="color" :font-size="fontSize" :uppercase="uppercase">
2
+ <TitleWrap data-test-id="page_wrapper" :has-info-text="!!infoText">
3
+ <TitleText
4
+ data-test-id="page_title_text"
5
+ :color="color"
6
+ :font-size="fontSize"
7
+ :uppercase="uppercase"
8
+ >
4
9
  {{ text }}
5
10
  </TitleText>
6
- <InfoText v-if="!!infoText" :align-arrow="infoAlign" :text="infoText" />
11
+ <InfoText
12
+ v-if="!!infoText"
13
+ data-test-id="page_title_tooltip"
14
+ :align-arrow="infoAlign"
15
+ :text="infoText"
16
+ />
7
17
  </TitleWrap>
8
18
  </template>
9
19
 
10
20
  <script>
11
21
  // import PageTitle from "@eturnity/eturnity_reusable_components/src/components/pageTitle"
12
22
  // To use:
13
- // <page-title
23
+ // <PageTitle
14
24
  // text="My Page Title"
15
25
  // color="red"
26
+ // font-size="13px"
27
+ // uppercase="true"
28
+ // info-text="My info text"
29
+ // info-align="center"
16
30
  // />
17
31
  import styled from 'vue3-styled-components'
18
32
  import InfoText from '../infoText'
@@ -45,23 +59,32 @@
45
59
  props: {
46
60
  text: {
47
61
  required: true,
62
+ type: String,
48
63
  },
49
64
  color: {
50
65
  required: false,
66
+ type: String,
67
+ default: '',
51
68
  },
52
69
  fontSize: {
53
70
  required: false,
71
+ type: String,
72
+ default: '',
54
73
  },
55
74
  uppercase: {
56
75
  required: false,
76
+ type: Boolean,
57
77
  default: true,
58
78
  },
59
79
  infoText: {
60
80
  required: false,
61
- default: null,
81
+ type: String,
82
+ default: '',
62
83
  },
63
84
  infoAlign: {
64
85
  required: false,
86
+ type: String,
87
+ default: 'center',
65
88
  },
66
89
  },
67
90
  }
@@ -0,0 +1,46 @@
1
+ /* eslint-disable */
2
+ import { mount } from '@vue/test-utils'
3
+ import RCPageTitle from '@/components/pageTitle'
4
+ import RCInfoText from '@/components/infoText'
5
+ import theme from '@/assets/theme'
6
+
7
+ jest.mock('@/components/icon/iconCache.mjs', () => ({
8
+ // need to mock this due to how jest handles import.meta
9
+ fetchIcon: jest.fn(() => Promise.resolve('mocked-icon-url.svg')),
10
+ }))
11
+
12
+ const titleText = 'Test Page Title'
13
+ const infoText = 'Test Tooltip Text'
14
+
15
+ describe('RCPageTitle.vue', () => {
16
+ it('page title is rendered with correct text', async () => {
17
+ const wrapper = mount(RCPageTitle, {
18
+ props: { text: titleText },
19
+ global: {
20
+ provide: {
21
+ theme,
22
+ },
23
+ },
24
+ })
25
+
26
+ const pageTitleText = wrapper.find('[data-test-id="page_title_text"]')
27
+
28
+ expect(pageTitleText.exists()).toBe(true)
29
+ expect(pageTitleText.text()).toContain(titleText)
30
+ }),
31
+ it('page title tooltip is rendered with correct text prop content', async () => {
32
+ const wrapper = mount(RCPageTitle, {
33
+ props: { text: titleText, infoText: infoText },
34
+ global: {
35
+ provide: {
36
+ theme,
37
+ },
38
+ },
39
+ })
40
+
41
+ const toltipComponent = wrapper.findComponent(RCInfoText)
42
+
43
+ expect(toltipComponent.exists()).toBe(true)
44
+ expect(toltipComponent.vm.text).toContain(infoText)
45
+ })
46
+ })