@eturnity/eturnity_reusable_components 7.35.0 → 7.35.1-EPDM-11196.0

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "7.35.0",
3
+ "version": "7.35.1-EPDM-11196.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -9,8 +9,10 @@ jest.mock('@/components/icon/iconCache.mjs', () => ({
9
9
  }))
10
10
 
11
11
  describe('MainButton.vue', () => {
12
- it('button is rendered', async () => {
13
- const wrapper = mount(MainButton, {
12
+ let wrapper
13
+
14
+ beforeEach(() => {
15
+ wrapper = mount(MainButton, {
14
16
  props: {
15
17
  type: 'primary',
16
18
  text: 'Click me',
@@ -23,10 +25,11 @@ describe('MainButton.vue', () => {
23
25
  },
24
26
  },
25
27
  })
28
+ })
29
+
30
+ it('button is rendered with correct props', async () => {
26
31
  await wrapper.vm.$nextTick()
27
32
  const buttonWrapper = wrapper.find('[data-id="button_wrapper"]')
28
-
29
- // check that the element exists
30
33
  expect(buttonWrapper.exists()).toBe(true)
31
34
  })
32
35
  })
@@ -1,6 +1,10 @@
1
1
  <template>
2
- <InfoContainer>
3
- <RCIcon name="info" size="24px" :color="color" />
2
+ <InfoContainer
3
+ background-color="backgrounColor"
4
+ :border-color="borderColor"
5
+ :has-dashed-border="hasDashedBorder"
6
+ >
7
+ <RCIcon :color="color" name="info" size="24px" />
4
8
  <TextContainer>
5
9
  <slot></slot>
6
10
  </TextContainer>
@@ -10,12 +14,24 @@
10
14
  <script>
11
15
  import styled from 'vue3-styled-components'
12
16
  import RCIcon from '../icon'
13
-
14
- const InfoContainer = styled.div`
17
+ const propsContainer = {
18
+ backgroundColor: String,
19
+ hasDashedBorder: Boolean,
20
+ borderColor: String,
21
+ }
22
+ const InfoContainer = styled('div', propsContainer)`
15
23
  display: flex;
16
24
  gap: 15px;
17
- padding: 20px;
18
- border: 1px dashed ${(props) => props.theme.colors.grey4};
25
+ padding: 15px;
26
+ border: 1px ${(props) => (props.hasDashedBorder ? 'dashed' : 'solid')}
27
+ ${(props) =>
28
+ props.theme.colors[props.borderColor]
29
+ ? props.theme.colors[props.borderColor]
30
+ : props.borderColor};
31
+ background-color: ${(props) =>
32
+ props.theme.colors[props.backgroundColor]
33
+ ? props.theme.colors[props.backgroundColor]
34
+ : props.backgroundColor};
19
35
  border-radius: 4px;
20
36
  `
21
37
 
@@ -33,8 +49,19 @@
33
49
  },
34
50
  props: {
35
51
  color: {
36
- required: false
37
- }
38
- }
52
+ required: false,
53
+ },
54
+ backgrounColor: {
55
+ required: false,
56
+ },
57
+ hasDashedBorder: {
58
+ required: false,
59
+ default: true,
60
+ },
61
+ borderColor: {
62
+ required: false,
63
+ default: 'grey4',
64
+ },
65
+ },
39
66
  }
40
67
  </script>
@@ -3,55 +3,61 @@ import Checkbox from './index.vue'
3
3
  export default {
4
4
  title: 'Checkbox',
5
5
  component: Checkbox,
6
- // argTypes: {},
6
+ tags: ['autodocs'],
7
7
  }
8
8
 
9
- const Template = (args, { argTypes }) => ({
10
- // Components used in your story `template` are defined in the `components` object
11
- components: { Checkbox },
12
- // The story's `args` need to be mapped into the template through the `setup()` method
13
- props: Object.keys(argTypes),
14
- template: '<checkbox v-bind="$props" />',
15
-
16
- // import Checkbox from "@eturnity/eturnity_reusable_components/src/components/inputs/checkbox"
17
- //To use:
18
- // <checkbox
19
- // label="Do you accept the Terms?"
20
- // :isChecked="isChecked" //required
21
- // @on-event-handler="onInputChange($event)" //required
22
- // checkColor="blue"
23
- // size="small"
24
- // backgroundColor="red"
25
- // :isDisabled="true"
26
- // />
27
- })
28
-
29
- export const Default = Template.bind({})
30
- Default.args = {
31
- isChecked: true,
32
- size: 'medium', // "small" or "medium"
33
- isDisabled: false,
9
+ // <checkbox
10
+ // label="Do you accept the Terms?"
11
+ // :isChecked="isChecked" //required
12
+ // @on-event-handler="onInputChange($event)" //required
13
+ // checkColor="blue"
14
+ // size="small"
15
+ // backgroundColor="red"
16
+ // :isDisabled="true"
17
+ // cursorType="default"
18
+ // />
19
+
20
+ export const DefaultCheckbox = {
21
+ args: {
22
+ isChecked: 'false',
23
+ },
24
+ }
25
+
26
+ export const IsChecked = {
27
+ args: {
28
+ isChecked: 'true',
29
+ },
30
+ }
31
+
32
+ export const CheckboxLabel = {
33
+ args: {
34
+ isChecked: 'false',
35
+ label: 'Click me',
36
+ },
34
37
  }
35
38
 
36
- export const Small = Template.bind({})
37
- Small.args = {
38
- isChecked: true,
39
- size: 'small', // "small" or "medium"
40
- isDisabled: false,
39
+ export const SmallCheckbox = {
40
+ args: {
41
+ isChecked: 'false',
42
+ label: 'Click me',
43
+ size: 'small',
44
+ },
41
45
  }
42
46
 
43
- export const CustomColor = Template.bind({})
44
- CustomColor.args = {
45
- isChecked: true,
46
- size: 'medium', // "small" or "medium"
47
- checkColor: 'blue',
48
- backgroundColor: 'red',
49
- isDisabled: false,
47
+ export const DisabledCheckbox = {
48
+ args: {
49
+ isChecked: false,
50
+ label: 'Click me',
51
+ size: 'small',
52
+ isDisabled: 'true',
53
+ },
50
54
  }
51
55
 
52
- export const Disabled = Template.bind({})
53
- Disabled.args = {
54
- isChecked: false,
55
- size: 'medium', // "small" or "medium"
56
- isDisabled: true,
56
+ export const CustomColor = {
57
+ args: {
58
+ isChecked: 'false',
59
+ size: 'medium',
60
+ checkColor: 'blue',
61
+ backgroundColor: 'yellow',
62
+ },
57
63
  }
@@ -0,0 +1,109 @@
1
+ /* eslint-disable */
2
+ import { mount } from '@vue/test-utils'
3
+ import Checkbox from '@/components/inputs/checkbox'
4
+ import theme from '@/assets/theme'
5
+
6
+ describe('Checkbox Component', () => {
7
+ let wrapper
8
+
9
+ beforeEach(() => {
10
+ wrapper = mount(Checkbox, {
11
+ props: {
12
+ isChecked: false,
13
+ label: 'Click me',
14
+ isDisabled: false,
15
+ dataId: 'checkbox_wrapper',
16
+ },
17
+ global: {
18
+ provide: {
19
+ theme,
20
+ },
21
+ },
22
+ })
23
+ })
24
+ it('checkbox is rendered and emits correct payload on change', async () => {
25
+ const checkboxWrapper = wrapper.find('[data-test-id="checkbox_wrapper"]')
26
+
27
+ // check that the element exists with correct props
28
+ expect(checkboxWrapper.exists()).toBe(true)
29
+ expect(wrapper.vm.isChecked).toBe(false)
30
+ expect(wrapper.vm.label).toBe('Click me')
31
+ expect(wrapper.vm.size).toBe('medium')
32
+ expect(wrapper.vm.isDisabled).toBe(false)
33
+
34
+ // Test the change
35
+ const inputCheckbox = checkboxWrapper.find('input[type="checkbox"]')
36
+ await inputCheckbox.trigger('change')
37
+ expect(wrapper.emitted('on-event-handler')).toBeTruthy()
38
+ const emittedEvent = wrapper.emitted('on-event-handler')
39
+ // To inspect emitted events:
40
+ expect(emittedEvent).toHaveLength(1) // Check if the event was emitted exactly once
41
+ // Check the payload of the event
42
+ expect(emittedEvent[0]).toEqual([true])
43
+ })
44
+ it('disabled should not emit anything', async () => {
45
+ const checkboxWrapper = wrapper.find('[data-test-id="checkbox_wrapper"]')
46
+ await wrapper.setProps({ isDisabled: true })
47
+
48
+ // check that the element exists with correct props
49
+ expect(checkboxWrapper.exists()).toBe(true)
50
+ expect(wrapper.vm.isDisabled).toBe(true)
51
+
52
+ // Test the change
53
+ const inputCheckbox = checkboxWrapper.find('input[type="checkbox"]')
54
+ await inputCheckbox.trigger('change')
55
+ // expect(wrapper.emitted('on-event-handler')).toBeTruthy()
56
+ const emittedEvents = wrapper.emitted('on-event-handler')
57
+ // To inspect emitted events:
58
+ expect(emittedEvents).toBeUndefined() // No event should be emitted
59
+ })
60
+ it('checkbox can handle multiple clicks', async () => {
61
+ const checkboxWrapper = wrapper.find('[data-test-id="checkbox_wrapper"]')
62
+
63
+ // check that the element exists with correct props
64
+ expect(checkboxWrapper.exists()).toBe(true)
65
+ expect(wrapper.vm.isChecked).toBe(false)
66
+
67
+ // Test the change
68
+ const inputCheckbox = checkboxWrapper.find('input[type="checkbox"]')
69
+ await inputCheckbox.trigger('change')
70
+ expect(wrapper.emitted('on-event-handler')).toBeTruthy()
71
+ const emittedEvent = wrapper.emitted('on-event-handler')
72
+ expect(emittedEvent).toHaveLength(1) // Check if the event was emitted exactly once
73
+ // Check the payload of the event
74
+ expect(emittedEvent[0]).toEqual([true])
75
+ await wrapper.setProps({ isChecked: true }) // manually update the props
76
+
77
+ // test the 2nd click
78
+ await inputCheckbox.trigger('change')
79
+ expect(wrapper.emitted('on-event-handler')).toBeTruthy()
80
+ expect(emittedEvent).toHaveLength(2) // Check if the event was emitted exactly once
81
+ // Check the payload of the event
82
+ expect(emittedEvent[1]).toEqual([false])
83
+ await wrapper.setProps({ isChecked: false }) // manually update the props
84
+
85
+ // test the 3rd click
86
+ await inputCheckbox.trigger('change')
87
+ expect(wrapper.emitted('on-event-handler')).toBeTruthy()
88
+ expect(emittedEvent).toHaveLength(3) // Check if the event was emitted exactly once
89
+ // Check the payload of the event
90
+ expect(emittedEvent[2]).toEqual([true])
91
+ await wrapper.setProps({ isChecked: true }) // manually update the props
92
+ })
93
+ it('should have a custom background color', async () => {
94
+ const checkboxWrapper = wrapper.find('[data-test-id="checkbox_wrapper"]')
95
+ await wrapper.setProps({ backgroundColor: theme.colors.red })
96
+
97
+ // check that the element exists with correct props
98
+ expect(checkboxWrapper.exists()).toBe(true)
99
+ expect(wrapper.vm.backgroundColor).toBe(theme.colors.red)
100
+ })
101
+ it('should have a custom checkbox color', async () => {
102
+ const checkboxWrapper = wrapper.find('[data-test-id="checkbox_wrapper"]')
103
+ await wrapper.setProps({ checkColor: theme.colors.brightBlue })
104
+
105
+ // check that the element exists with correct props
106
+ expect(checkboxWrapper.exists()).toBe(true)
107
+ expect(wrapper.vm.checkColor).toBe(theme.colors.brightBlue)
108
+ })
109
+ })
@@ -4,6 +4,7 @@
4
4
  :background-color="backgroundColor"
5
5
  :check-color="checkColor"
6
6
  :cursor-type="cursorType"
7
+ :data-test-id="dataId"
7
8
  :has-label="hasLabel"
8
9
  :is-checked="isChecked"
9
10
  :is-disabled="isDisabled"
@@ -9,7 +9,7 @@ jest.mock('@/components/icon/iconCache.mjs', () => ({
9
9
  }))
10
10
 
11
11
  describe('RCToggle.vue', () => {
12
- it('checkbox is rendered and emits correct payload on change', async () => {
12
+ it('toggle is rendered and emits correct payload on change', async () => {
13
13
  const wrapper = mount(RCToggle, {
14
14
  props: { isChecked: true, label: 'Test label', disabled: false },
15
15
  global: {
@@ -42,7 +42,7 @@ describe('RCToggle.vue', () => {
42
42
  // Check the payload of the event
43
43
  expect(emittedEvent[0]).toEqual([false])
44
44
  }),
45
- it('checkbox disabled does not emit anything', async () => {
45
+ it('toggle disabled does not emit anything', async () => {
46
46
  const wrapper = mount(RCToggle, {
47
47
  props: { isChecked: false, disabled: true },
48
48
  global: {