@intility/bifrost-react-select 4.0.0-alpha.8 → 4.0.0-beta.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.
@@ -1,118 +1,118 @@
1
- import Select from './Select'
2
- import { render } from '@testing-library/react'
1
+ import Select from "./Select";
2
+ import { render } from "@testing-library/react";
3
3
 
4
- let getByTestId, getByText, queryByText, element, customInput, rerender
4
+ let getByTestId, getByText, queryByText, element, customInput, rerender;
5
5
 
6
6
  beforeEach(() => {
7
7
  const options = [
8
- { value: 'Norway', label: 'Norway' },
9
- { value: 'Sweden', label: 'Sweden' },
10
- { value: 'Denmark', label: 'Denmark' },
11
- { value: 'Germany', label: 'Germany' }
12
- ]
8
+ { value: "Norway", label: "Norway" },
9
+ { value: "Sweden", label: "Sweden" },
10
+ { value: "Denmark", label: "Denmark" },
11
+ { value: "Germany", label: "Germany" },
12
+ ];
13
13
 
14
14
  const select = render(
15
15
  <Select
16
- label='Select country'
17
- placeholder='Select country here'
16
+ label="Select country"
17
+ placeholder="Select country here"
18
18
  options={options}
19
- />
20
- )
21
-
22
- getByTestId = select.getByTestId
23
- getByText = select.getByText
24
- queryByText = select.queryByText
25
- element = getByTestId('bf-select-container')
26
- customInput = getByTestId('bf-select-input')
27
- rerender = select.rerender
19
+ />,
20
+ );
21
+
22
+ getByTestId = select.getByTestId;
23
+ getByText = select.getByText;
24
+ queryByText = select.queryByText;
25
+ element = getByTestId("bf-select-container");
26
+ customInput = getByTestId("bf-select-input");
27
+ rerender = select.rerender;
28
28
  // debug = select.debug
29
- })
30
-
31
- describe('select component', () => {
32
- it('renders select component', () => {
33
- expect(element)
34
- })
35
- })
36
-
37
- describe('select with required label prop', () => {
38
- it('renders label text', () => {
39
- expect(getByText('Select country'))
40
- })
41
- })
42
-
43
- describe('select with className and style', () => {
44
- it('renders with custom classname and custom styles', () => {
29
+ });
30
+
31
+ describe("select component", () => {
32
+ it("renders select component", () => {
33
+ expect(element);
34
+ });
35
+ });
36
+
37
+ describe("select with required label prop", () => {
38
+ it("renders label text", () => {
39
+ expect(getByText("Select country"));
40
+ });
41
+ });
42
+
43
+ describe("select with className and style", () => {
44
+ it("renders with custom classname and custom styles", () => {
45
45
  rerender(
46
46
  <Select
47
- label='Custom classname'
48
- className='custom-classname'
49
- style={{ width: '100%' }}
50
- />
51
- )
52
-
53
- expect(element).toHaveClass('custom-classname')
54
- expect(element).toHaveStyle('width: 100%')
55
- })
56
- })
57
-
58
- describe('select with description prop', () => {
59
- it('renders with text as description', () => {
47
+ label="Custom classname"
48
+ className="custom-classname"
49
+ style={{ width: "100%" }}
50
+ />,
51
+ );
52
+
53
+ expect(element).toHaveClass("custom-classname");
54
+ expect(element).toHaveStyle("width: 100%");
55
+ });
56
+ });
57
+
58
+ describe("select with description prop", () => {
59
+ it("renders with text as description", () => {
60
60
  rerender(
61
- <Select label='Select country' description='Please select one country' />
62
- )
61
+ <Select label="Select country" description="Please select one country" />,
62
+ );
63
63
 
64
- expect(getByText('Please select one country'))
65
- })
66
- })
64
+ expect(getByText("Please select one country"));
65
+ });
66
+ });
67
67
 
68
- describe('select with state and feedback props', () => {
69
- it('renders with alert state ', () => {
68
+ describe("select with state and feedback props", () => {
69
+ it("renders with alert state ", () => {
70
70
  rerender(
71
- <Select label='Select country' state='alert' feedback='Missing value ' />
72
- )
71
+ <Select label="Select country" state="alert" feedback="Missing value " />,
72
+ );
73
73
 
74
- expect(element).toHaveClass('bf-select-alert')
75
- })
74
+ expect(element).toHaveClass("bf-select-alert");
75
+ });
76
76
 
77
- it('renders with feedback text', () => {
77
+ it("renders with feedback text", () => {
78
78
  rerender(
79
- <Select label='Select country' state='alert' feedback='Missing value ' />
80
- )
81
- const feedback = getByText('Missing value')
82
-
83
- expect(feedback)
84
- expect(feedback).toHaveClass('bf-label-feedback')
85
- expect(feedback.tagName.toLowerCase()).toBe('div')
86
- })
87
- })
88
-
89
- describe('select disabled', () => {
90
- it('renders as disabled', () => {
91
- rerender(<Select label='Disabled' isDisabled />)
79
+ <Select label="Select country" state="alert" feedback="Missing value " />,
80
+ );
81
+ const feedback = getByText("Missing value");
82
+
83
+ expect(feedback);
84
+ expect(feedback).toHaveClass("bf-label-feedback");
85
+ expect(feedback.tagName.toLowerCase()).toBe("div");
86
+ });
87
+ });
88
+
89
+ describe("select disabled", () => {
90
+ it("renders as disabled", () => {
91
+ rerender(<Select label="Disabled" isDisabled />);
92
92
  // can only test classname, hence isDisabled is a prop for react-select
93
- expect(element).toHaveClass('bf-select-disabled')
94
- })
95
- })
93
+ expect(element).toHaveClass("bf-select-disabled");
94
+ });
95
+ });
96
96
 
97
- describe('select with required/optional props', () => {
98
- it('renders as required', () => {
99
- rerender(<Select label='This is required' required />)
97
+ describe("select with required/optional props", () => {
98
+ it("renders as required", () => {
99
+ rerender(<Select label="This is required" required />);
100
100
 
101
- expect(customInput).toBeRequired()
102
- expect(getByText('(required)'))
103
- })
101
+ expect(customInput).toBeRequired();
102
+ expect(getByText("(required)"));
103
+ });
104
104
 
105
- it('renders as required, but hiding the (required) text', () => {
106
- rerender(<Select label='This is required' requiredNoLabel />)
105
+ it("renders as required, but hiding the (required) text", () => {
106
+ rerender(<Select label="This is required" requiredNoLabel />);
107
107
 
108
- expect(customInput).toBeRequired()
109
- expect(queryByText('(required)')).toBeNull()
110
- })
108
+ expect(customInput).toBeRequired();
109
+ expect(queryByText("(required)")).toBeNull();
110
+ });
111
111
 
112
- it('renders as optional with (optional) text', () => {
113
- rerender(<Select label='This is optional' optional />)
112
+ it("renders as optional with (optional) text", () => {
113
+ rerender(<Select label="This is optional" optional />);
114
114
 
115
- expect(customInput).not.toBeRequired()
116
- expect(getByText('(optional)'))
117
- })
118
- })
115
+ expect(customInput).not.toBeRequired();
116
+ expect(getByText("(optional)"));
117
+ });
118
+ });