@instructure/ui-tag 10.19.2-snapshot-2 → 10.19.2-snapshot-4

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,127 +0,0 @@
1
- var _Tag, _Tag2;
2
- /*
3
- * The MIT License (MIT)
4
- *
5
- * Copyright (c) 2015 - present Instructure, Inc.
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
24
- */
25
-
26
- import { render, screen, waitFor } from '@testing-library/react';
27
- import { userEvent } from '@testing-library/user-event';
28
- import '@testing-library/jest-dom';
29
- import { vi } from 'vitest';
30
- import { Tag } from '../index';
31
- import { runAxeCheck } from '@instructure/ui-axe-check';
32
- import { View } from '@instructure/ui-view';
33
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
34
- const originalOmitViewProps = View.omitViewProps;
35
- describe('<Tag />', async () => {
36
- beforeAll(() => {
37
- // View component read Component.name instead of Component.displayName
38
- // causing [undefined] in error messages
39
-
40
- View.omitViewProps = (props, Component) => {
41
- const ModifiedComponent = {
42
- ...Component,
43
- name: 'Tag'
44
- };
45
- return originalOmitViewProps(props, ModifiedComponent);
46
- };
47
- });
48
- afterAll(() => {
49
- View.omitViewProps = originalOmitViewProps;
50
- });
51
- it('should display text', async () => {
52
- render(_Tag || (_Tag = _jsx(Tag, {
53
- text: "Summer"
54
- })));
55
- const tag = screen.getByText('Summer');
56
- expect(tag).toBeInTheDocument();
57
- });
58
- it('should render as a button and respond to onClick event', async () => {
59
- const onClick = vi.fn();
60
- render(_jsx(Tag, {
61
- "data-testid": "summer-button",
62
- text: "Summer",
63
- onClick: onClick
64
- }));
65
- const button = screen.getByTestId('summer-button');
66
- userEvent.click(button);
67
- await waitFor(() => {
68
- expect(onClick).toHaveBeenCalledTimes(1);
69
- expect(button.tagName).toBe('BUTTON');
70
- });
71
- });
72
- it('should render a close icon when it is dismissible and clickable', async () => {
73
- const onClick = vi.fn();
74
- const _render = render(_jsx(Tag, {
75
- text: "Summer",
76
- onClick: onClick,
77
- dismissible: true
78
- })),
79
- container = _render.container;
80
- const icon = container.querySelector('svg');
81
- expect(icon).toHaveAttribute('name', 'IconX');
82
- });
83
- it('should meet a11y standards', async () => {
84
- const _render2 = render(_Tag2 || (_Tag2 = _jsx(Tag, {
85
- text: "Summer"
86
- }))),
87
- container = _render2.container;
88
- const axeCheck = await runAxeCheck(container);
89
- expect(axeCheck).toBe(true);
90
- });
91
- describe('when passing down props to View', async () => {
92
- const allowedProps = {
93
- margin: 'small',
94
- elementRef: () => {}
95
- };
96
- View.allowedProps.filter(prop => prop !== 'children').forEach(prop => {
97
- if (Object.keys(allowedProps).indexOf(prop) < 0) {
98
- it(`should NOT allow the '${prop}' prop`, async () => {
99
- const props = {
100
- [prop]: 'foo'
101
- };
102
- const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {});
103
- render(_jsx(Tag, {
104
- text: "Summer",
105
- ...props
106
- }));
107
- const warning = `Warning: [Tag] prop '${prop}' is not allowed.`;
108
- expect(consoleError.mock.calls[0][0]).toBe(warning);
109
- consoleError.mockRestore();
110
- });
111
- } else {
112
- it(`should allow the '${prop}' prop`, async () => {
113
- const props = {
114
- [prop]: allowedProps[prop]
115
- };
116
- const consoleError = vi.spyOn(console, 'error');
117
- render(_jsx(Tag, {
118
- text: "Summer",
119
- ...props
120
- }));
121
- expect(consoleError).not.toHaveBeenCalled();
122
- consoleError.mockRestore();
123
- });
124
- }
125
- });
126
- });
127
- });
@@ -1,128 +0,0 @@
1
- "use strict";
2
-
3
- var _react = require("@testing-library/react");
4
- var _userEvent = require("@testing-library/user-event");
5
- require("@testing-library/jest-dom");
6
- var _vitest = require("vitest");
7
- var _index = require("../index");
8
- var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
9
- var _View = require("@instructure/ui-view/lib/View");
10
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
11
- var _Tag, _Tag2;
12
- /*
13
- * The MIT License (MIT)
14
- *
15
- * Copyright (c) 2015 - present Instructure, Inc.
16
- *
17
- * Permission is hereby granted, free of charge, to any person obtaining a copy
18
- * of this software and associated documentation files (the "Software"), to deal
19
- * in the Software without restriction, including without limitation the rights
20
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
- * copies of the Software, and to permit persons to whom the Software is
22
- * furnished to do so, subject to the following conditions:
23
- *
24
- * The above copyright notice and this permission notice shall be included in all
25
- * copies or substantial portions of the Software.
26
- *
27
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
- * SOFTWARE.
34
- */
35
- const originalOmitViewProps = _View.View.omitViewProps;
36
- describe('<Tag />', async () => {
37
- beforeAll(() => {
38
- // View component read Component.name instead of Component.displayName
39
- // causing [undefined] in error messages
40
-
41
- _View.View.omitViewProps = (props, Component) => {
42
- const ModifiedComponent = {
43
- ...Component,
44
- name: 'Tag'
45
- };
46
- return originalOmitViewProps(props, ModifiedComponent);
47
- };
48
- });
49
- afterAll(() => {
50
- _View.View.omitViewProps = originalOmitViewProps;
51
- });
52
- it('should display text', async () => {
53
- (0, _react.render)(_Tag || (_Tag = (0, _jsxRuntime.jsx)(_index.Tag, {
54
- text: "Summer"
55
- })));
56
- const tag = _react.screen.getByText('Summer');
57
- expect(tag).toBeInTheDocument();
58
- });
59
- it('should render as a button and respond to onClick event', async () => {
60
- const onClick = _vitest.vi.fn();
61
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Tag, {
62
- "data-testid": "summer-button",
63
- text: "Summer",
64
- onClick: onClick
65
- }));
66
- const button = _react.screen.getByTestId('summer-button');
67
- _userEvent.userEvent.click(button);
68
- await (0, _react.waitFor)(() => {
69
- expect(onClick).toHaveBeenCalledTimes(1);
70
- expect(button.tagName).toBe('BUTTON');
71
- });
72
- });
73
- it('should render a close icon when it is dismissible and clickable', async () => {
74
- const onClick = _vitest.vi.fn();
75
- const _render = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Tag, {
76
- text: "Summer",
77
- onClick: onClick,
78
- dismissible: true
79
- })),
80
- container = _render.container;
81
- const icon = container.querySelector('svg');
82
- expect(icon).toHaveAttribute('name', 'IconX');
83
- });
84
- it('should meet a11y standards', async () => {
85
- const _render2 = (0, _react.render)(_Tag2 || (_Tag2 = (0, _jsxRuntime.jsx)(_index.Tag, {
86
- text: "Summer"
87
- }))),
88
- container = _render2.container;
89
- const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
90
- expect(axeCheck).toBe(true);
91
- });
92
- describe('when passing down props to View', async () => {
93
- const allowedProps = {
94
- margin: 'small',
95
- elementRef: () => {}
96
- };
97
- _View.View.allowedProps.filter(prop => prop !== 'children').forEach(prop => {
98
- if (Object.keys(allowedProps).indexOf(prop) < 0) {
99
- it(`should NOT allow the '${prop}' prop`, async () => {
100
- const props = {
101
- [prop]: 'foo'
102
- };
103
- const consoleError = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
104
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Tag, {
105
- text: "Summer",
106
- ...props
107
- }));
108
- const warning = `Warning: [Tag] prop '${prop}' is not allowed.`;
109
- expect(consoleError.mock.calls[0][0]).toBe(warning);
110
- consoleError.mockRestore();
111
- });
112
- } else {
113
- it(`should allow the '${prop}' prop`, async () => {
114
- const props = {
115
- [prop]: allowedProps[prop]
116
- };
117
- const consoleError = _vitest.vi.spyOn(console, 'error');
118
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Tag, {
119
- text: "Summer",
120
- ...props
121
- }));
122
- expect(consoleError).not.toHaveBeenCalled();
123
- consoleError.mockRestore();
124
- });
125
- }
126
- });
127
- });
128
- });
@@ -1,132 +0,0 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- import { ComponentType } from 'react'
26
- import { render, screen, waitFor } from '@testing-library/react'
27
- import { userEvent } from '@testing-library/user-event'
28
- import '@testing-library/jest-dom'
29
- import { vi } from 'vitest'
30
-
31
- import { Tag } from '../index'
32
- import { runAxeCheck } from '@instructure/ui-axe-check'
33
- import type { ViewProps } from '@instructure/ui-view'
34
- import { View } from '@instructure/ui-view'
35
-
36
- const originalOmitViewProps = View.omitViewProps
37
-
38
- describe('<Tag />', async () => {
39
- beforeAll(() => {
40
- // View component read Component.name instead of Component.displayName
41
- // causing [undefined] in error messages
42
- type TagComponentType = ComponentType & {
43
- name: 'Tag'
44
- }
45
-
46
- View.omitViewProps = (props, Component) => {
47
- const ModifiedComponent = {
48
- ...Component,
49
- name: 'Tag'
50
- } as TagComponentType
51
- return originalOmitViewProps(props, ModifiedComponent)
52
- }
53
- })
54
- afterAll(() => {
55
- View.omitViewProps = originalOmitViewProps
56
- })
57
-
58
- it('should display text', async () => {
59
- render(<Tag text="Summer" />)
60
- const tag = screen.getByText('Summer')
61
-
62
- expect(tag).toBeInTheDocument()
63
- })
64
-
65
- it('should render as a button and respond to onClick event', async () => {
66
- const onClick = vi.fn()
67
- render(<Tag data-testid="summer-button" text="Summer" onClick={onClick} />)
68
-
69
- const button = screen.getByTestId('summer-button')
70
-
71
- userEvent.click(button)
72
-
73
- await waitFor(() => {
74
- expect(onClick).toHaveBeenCalledTimes(1)
75
- expect(button.tagName).toBe('BUTTON')
76
- })
77
- })
78
-
79
- it('should render a close icon when it is dismissible and clickable', async () => {
80
- const onClick = vi.fn()
81
- const { container } = render(
82
- <Tag text="Summer" onClick={onClick} dismissible={true} />
83
- )
84
- const icon = container.querySelector('svg')
85
-
86
- expect(icon).toHaveAttribute('name', 'IconX')
87
- })
88
-
89
- it('should meet a11y standards', async () => {
90
- const { container } = render(<Tag text="Summer" />)
91
- const axeCheck = await runAxeCheck(container)
92
-
93
- expect(axeCheck).toBe(true)
94
- })
95
-
96
- describe('when passing down props to View', async () => {
97
- const allowedProps: Partial<ViewProps> = {
98
- margin: 'small',
99
- elementRef: () => {}
100
- }
101
- View.allowedProps
102
- .filter((prop) => prop !== 'children')
103
- .forEach((prop) => {
104
- if (Object.keys(allowedProps).indexOf(prop) < 0) {
105
- it(`should NOT allow the '${prop}' prop`, async () => {
106
- const props = {
107
- [prop]: 'foo'
108
- }
109
- const consoleError = vi
110
- .spyOn(console, 'error')
111
- .mockImplementation(() => {})
112
-
113
- render(<Tag text="Summer" {...props} />)
114
- const warning = `Warning: [Tag] prop '${prop}' is not allowed.`
115
-
116
- expect(consoleError.mock.calls[0][0]).toBe(warning)
117
- consoleError.mockRestore()
118
- })
119
- } else {
120
- it(`should allow the '${prop}' prop`, async () => {
121
- const props = { [prop]: allowedProps[prop] }
122
- const consoleError = vi.spyOn(console, 'error')
123
-
124
- render(<Tag text="Summer" {...props} />)
125
-
126
- expect(consoleError).not.toHaveBeenCalled()
127
- consoleError.mockRestore()
128
- })
129
- }
130
- })
131
- })
132
- })
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=Tag.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tag.test.d.ts","sourceRoot":"","sources":["../../../src/Tag/__new-tests__/Tag.test.tsx"],"names":[],"mappings":"AA2BA,OAAO,2BAA2B,CAAA"}