@instructure/ui-spinner 10.10.1-snapshot-14 → 10.11.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/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [10.10.1-snapshot-14](https://github.com/instructure/instructure-ui/compare/v10.10.0...v10.10.1-snapshot-14) (2025-02-03)
6
+ # [10.11.0](https://github.com/instructure/instructure-ui/compare/v10.10.0...v10.11.0) (2025-02-03)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-spinner
9
9
 
@@ -1,4 +1,4 @@
1
- var _Spinner;
1
+ var _Spinner, _Spinner2, _Spinner3, _Spinner4;
2
2
  /*
3
3
  * The MIT License (MIT)
4
4
  *
@@ -24,12 +24,95 @@ var _Spinner;
24
24
  */
25
25
  import React from 'react';
26
26
  import { render, waitFor, screen } from '@testing-library/react';
27
+ import { runAxeCheck } from '@instructure/ui-axe-check';
28
+ import { vi, expect } from 'vitest';
27
29
  import '@testing-library/jest-dom';
30
+ import { View } from '@instructure/ui-view';
28
31
  import Spinner from '../index';
29
32
  describe('<Spinner />', () => {
33
+ let consoleErrorMock;
34
+ beforeEach(() => {
35
+ // Mocking console to prevent test output pollution and expect for messages
36
+ consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
37
+ });
38
+ afterEach(() => {
39
+ consoleErrorMock.mockRestore();
40
+ });
41
+ it('should render', async () => {
42
+ const _render = render(_Spinner || (_Spinner = /*#__PURE__*/React.createElement(Spinner, {
43
+ renderTitle: "Loading",
44
+ size: "small"
45
+ }))),
46
+ container = _render.container;
47
+ const spinner = container.querySelector('div[class$="-spinner"]');
48
+ expect(spinner).toBeInTheDocument();
49
+ });
50
+ it('should render the title prop text in the SVG element title', async () => {
51
+ const _render2 = render(_Spinner2 || (_Spinner2 = /*#__PURE__*/React.createElement(Spinner, {
52
+ renderTitle: "Loading",
53
+ size: "large"
54
+ }))),
55
+ container = _render2.container;
56
+ const spinner = container.querySelector('div[class$="-spinner"]');
57
+ expect(spinner).toHaveTextContent('Loading');
58
+ });
59
+ it('should meet a11y standards', async () => {
60
+ const _render3 = render(_Spinner3 || (_Spinner3 = /*#__PURE__*/React.createElement(Spinner, {
61
+ renderTitle: "Loading",
62
+ size: "small"
63
+ }))),
64
+ container = _render3.container;
65
+ const axeCheck = await runAxeCheck(container);
66
+ expect(axeCheck).toBe(true);
67
+ });
68
+ it('should render the contents of a component used in renderTitle', async () => {
69
+ const Translation = ({
70
+ children
71
+ }) => /*#__PURE__*/React.createElement("span", null, "I have translated ", children, ".");
72
+ const _render4 = render(/*#__PURE__*/React.createElement(Spinner, {
73
+ renderTitle: /*#__PURE__*/React.createElement(Translation, null, "Loading"),
74
+ size: "small"
75
+ })),
76
+ container = _render4.container;
77
+ const spinner = container.querySelector('div[class$="-spinner"]');
78
+ const axeCheck = await runAxeCheck(container);
79
+ expect(axeCheck).toBe(true);
80
+ expect(spinner).toHaveTextContent('I have translated Loading');
81
+ });
82
+ describe('when passing down props to View', () => {
83
+ const allowedProps = {
84
+ margin: 'small',
85
+ elementRef: () => {},
86
+ as: 'div'
87
+ };
88
+ View.allowedProps.filter(prop => prop !== 'children').forEach(prop => {
89
+ if (Object.keys(allowedProps).indexOf(prop) < 0) {
90
+ it(`should NOT allow the '${prop}' prop`, async () => {
91
+ const props = {
92
+ [prop]: 'foo'
93
+ };
94
+ const expectedErrorMessage = `prop '${prop}' is not allowed.`;
95
+ render(/*#__PURE__*/React.createElement(Spinner, Object.assign({
96
+ renderTitle: "Loading"
97
+ }, props)));
98
+ expect(consoleErrorMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
99
+ });
100
+ } else {
101
+ it(`should allow the '${prop}' prop`, async () => {
102
+ const props = {
103
+ [prop]: allowedProps[prop]
104
+ };
105
+ render(/*#__PURE__*/React.createElement(Spinner, Object.assign({
106
+ renderTitle: "Loading"
107
+ }, props)));
108
+ expect(consoleErrorMock).not.toHaveBeenCalled();
109
+ });
110
+ }
111
+ });
112
+ });
30
113
  describe('with the delay prop', () => {
31
114
  it('should delay rendering', async () => {
32
- render(_Spinner || (_Spinner = /*#__PURE__*/React.createElement(Spinner, {
115
+ render(_Spinner4 || (_Spinner4 = /*#__PURE__*/React.createElement(Spinner, {
33
116
  renderTitle: "Loading",
34
117
  delay: 300
35
118
  })));
@@ -3,9 +3,12 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  var _react = _interopRequireDefault(require("react"));
5
5
  var _react2 = require("@testing-library/react");
6
+ var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
7
+ var _vitest = require("vitest");
6
8
  require("@testing-library/jest-dom");
9
+ var _View = require("@instructure/ui-view/lib/View");
7
10
  var _index = _interopRequireDefault(require("../index"));
8
- var _Spinner;
11
+ var _Spinner, _Spinner2, _Spinner3, _Spinner4;
9
12
  /*
10
13
  * The MIT License (MIT)
11
14
  *
@@ -30,18 +33,98 @@ var _Spinner;
30
33
  * SOFTWARE.
31
34
  */
32
35
  describe('<Spinner />', () => {
36
+ let consoleErrorMock;
37
+ beforeEach(() => {
38
+ // Mocking console to prevent test output pollution and expect for messages
39
+ consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
40
+ });
41
+ afterEach(() => {
42
+ consoleErrorMock.mockRestore();
43
+ });
44
+ it('should render', async () => {
45
+ const _render = (0, _react2.render)(_Spinner || (_Spinner = /*#__PURE__*/_react.default.createElement(_index.default, {
46
+ renderTitle: "Loading",
47
+ size: "small"
48
+ }))),
49
+ container = _render.container;
50
+ const spinner = container.querySelector('div[class$="-spinner"]');
51
+ (0, _vitest.expect)(spinner).toBeInTheDocument();
52
+ });
53
+ it('should render the title prop text in the SVG element title', async () => {
54
+ const _render2 = (0, _react2.render)(_Spinner2 || (_Spinner2 = /*#__PURE__*/_react.default.createElement(_index.default, {
55
+ renderTitle: "Loading",
56
+ size: "large"
57
+ }))),
58
+ container = _render2.container;
59
+ const spinner = container.querySelector('div[class$="-spinner"]');
60
+ (0, _vitest.expect)(spinner).toHaveTextContent('Loading');
61
+ });
62
+ it('should meet a11y standards', async () => {
63
+ const _render3 = (0, _react2.render)(_Spinner3 || (_Spinner3 = /*#__PURE__*/_react.default.createElement(_index.default, {
64
+ renderTitle: "Loading",
65
+ size: "small"
66
+ }))),
67
+ container = _render3.container;
68
+ const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
69
+ (0, _vitest.expect)(axeCheck).toBe(true);
70
+ });
71
+ it('should render the contents of a component used in renderTitle', async () => {
72
+ const Translation = ({
73
+ children
74
+ }) => /*#__PURE__*/_react.default.createElement("span", null, "I have translated ", children, ".");
75
+ const _render4 = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, {
76
+ renderTitle: /*#__PURE__*/_react.default.createElement(Translation, null, "Loading"),
77
+ size: "small"
78
+ })),
79
+ container = _render4.container;
80
+ const spinner = container.querySelector('div[class$="-spinner"]');
81
+ const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
82
+ (0, _vitest.expect)(axeCheck).toBe(true);
83
+ (0, _vitest.expect)(spinner).toHaveTextContent('I have translated Loading');
84
+ });
85
+ describe('when passing down props to View', () => {
86
+ const allowedProps = {
87
+ margin: 'small',
88
+ elementRef: () => {},
89
+ as: 'div'
90
+ };
91
+ _View.View.allowedProps.filter(prop => prop !== 'children').forEach(prop => {
92
+ if (Object.keys(allowedProps).indexOf(prop) < 0) {
93
+ it(`should NOT allow the '${prop}' prop`, async () => {
94
+ const props = {
95
+ [prop]: 'foo'
96
+ };
97
+ const expectedErrorMessage = `prop '${prop}' is not allowed.`;
98
+ (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, Object.assign({
99
+ renderTitle: "Loading"
100
+ }, props)));
101
+ (0, _vitest.expect)(consoleErrorMock).toHaveBeenCalledWith(_vitest.expect.stringContaining(expectedErrorMessage), _vitest.expect.any(String));
102
+ });
103
+ } else {
104
+ it(`should allow the '${prop}' prop`, async () => {
105
+ const props = {
106
+ [prop]: allowedProps[prop]
107
+ };
108
+ (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, Object.assign({
109
+ renderTitle: "Loading"
110
+ }, props)));
111
+ (0, _vitest.expect)(consoleErrorMock).not.toHaveBeenCalled();
112
+ });
113
+ }
114
+ });
115
+ });
33
116
  describe('with the delay prop', () => {
34
117
  it('should delay rendering', async () => {
35
- (0, _react2.render)(_Spinner || (_Spinner = /*#__PURE__*/_react.default.createElement(_index.default, {
118
+ (0, _react2.render)(_Spinner4 || (_Spinner4 = /*#__PURE__*/_react.default.createElement(_index.default, {
36
119
  renderTitle: "Loading",
37
120
  delay: 300
38
121
  })));
39
- expect(_react2.screen.queryByText('Loading')).not.toBeInTheDocument();
122
+ (0, _vitest.expect)(_react2.screen.queryByText('Loading')).not.toBeInTheDocument();
40
123
  await (0, _react2.waitFor)(async () => {
41
124
  const title = await _react2.screen.findByText('Loading');
42
125
  const icon = await _react2.screen.findByRole('img');
43
- expect(title).toBeInTheDocument();
44
- expect(icon).toBeInTheDocument();
126
+ (0, _vitest.expect)(title).toBeInTheDocument();
127
+ (0, _vitest.expect)(icon).toBeInTheDocument();
45
128
  }, {
46
129
  timeout: 400
47
130
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-spinner",
3
- "version": "10.10.1-snapshot-14",
3
+ "version": "10.11.0",
4
4
  "description": "A spinner/loading component",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,22 +24,22 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.26.0",
27
- "@instructure/console": "10.10.1-snapshot-14",
28
- "@instructure/emotion": "10.10.1-snapshot-14",
29
- "@instructure/shared-types": "10.10.1-snapshot-14",
30
- "@instructure/ui-color-utils": "10.10.1-snapshot-14",
31
- "@instructure/ui-react-utils": "10.10.1-snapshot-14",
32
- "@instructure/ui-testable": "10.10.1-snapshot-14",
33
- "@instructure/ui-utils": "10.10.1-snapshot-14",
34
- "@instructure/ui-view": "10.10.1-snapshot-14",
35
- "@instructure/uid": "10.10.1-snapshot-14",
27
+ "@instructure/console": "10.11.0",
28
+ "@instructure/emotion": "10.11.0",
29
+ "@instructure/shared-types": "10.11.0",
30
+ "@instructure/ui-color-utils": "10.11.0",
31
+ "@instructure/ui-react-utils": "10.11.0",
32
+ "@instructure/ui-testable": "10.11.0",
33
+ "@instructure/ui-utils": "10.11.0",
34
+ "@instructure/ui-view": "10.11.0",
35
+ "@instructure/uid": "10.11.0",
36
36
  "prop-types": "^15.8.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@instructure/ui-babel-preset": "10.10.1-snapshot-14",
40
- "@instructure/ui-test-locator": "10.10.1-snapshot-14",
41
- "@instructure/ui-test-utils": "10.10.1-snapshot-14",
42
- "@instructure/ui-themes": "10.10.1-snapshot-14",
39
+ "@instructure/ui-axe-check": "10.11.0",
40
+ "@instructure/ui-babel-preset": "10.11.0",
41
+ "@instructure/ui-test-utils": "10.11.0",
42
+ "@instructure/ui-themes": "10.11.0",
43
43
  "@testing-library/jest-dom": "^6.6.3",
44
44
  "@testing-library/react": "^16.0.1",
45
45
  "vitest": "^2.1.8"
@@ -23,11 +23,100 @@
23
23
  */
24
24
  import React from 'react'
25
25
  import { render, waitFor, screen } from '@testing-library/react'
26
+ import { runAxeCheck } from '@instructure/ui-axe-check'
27
+ import { vi, expect } from 'vitest'
28
+ import type { MockInstance } from 'vitest'
26
29
 
27
30
  import '@testing-library/jest-dom'
31
+ import { View } from '@instructure/ui-view'
28
32
  import Spinner from '../index'
33
+ import type { SpinnerProps } from '../props'
29
34
 
30
35
  describe('<Spinner />', () => {
36
+ let consoleErrorMock: ReturnType<typeof vi.spyOn>
37
+
38
+ beforeEach(() => {
39
+ // Mocking console to prevent test output pollution and expect for messages
40
+ consoleErrorMock = vi
41
+ .spyOn(console, 'error')
42
+ .mockImplementation(() => {}) as MockInstance
43
+ })
44
+
45
+ afterEach(() => {
46
+ consoleErrorMock.mockRestore()
47
+ })
48
+
49
+ it('should render', async () => {
50
+ const { container } = render(<Spinner renderTitle="Loading" size="small" />)
51
+ const spinner = container.querySelector('div[class$="-spinner"]')
52
+
53
+ expect(spinner).toBeInTheDocument()
54
+ })
55
+
56
+ it('should render the title prop text in the SVG element title', async () => {
57
+ const { container } = render(<Spinner renderTitle="Loading" size="large" />)
58
+ const spinner = container.querySelector('div[class$="-spinner"]')
59
+
60
+ expect(spinner).toHaveTextContent('Loading')
61
+ })
62
+
63
+ it('should meet a11y standards', async () => {
64
+ const { container } = render(<Spinner renderTitle="Loading" size="small" />)
65
+ const axeCheck = await runAxeCheck(container)
66
+ expect(axeCheck).toBe(true)
67
+ })
68
+
69
+ it('should render the contents of a component used in renderTitle', async () => {
70
+ const Translation = ({ children }: SpinnerProps) => (
71
+ <span>I have translated {children}.</span>
72
+ )
73
+
74
+ const { container } = render(
75
+ <Spinner renderTitle={<Translation>Loading</Translation>} size="small" />
76
+ )
77
+
78
+ const spinner = container.querySelector('div[class$="-spinner"]')
79
+ const axeCheck = await runAxeCheck(container)
80
+
81
+ expect(axeCheck).toBe(true)
82
+ expect(spinner).toHaveTextContent('I have translated Loading')
83
+ })
84
+
85
+ describe('when passing down props to View', () => {
86
+ const allowedProps: { [key: string]: any } = {
87
+ margin: 'small',
88
+ elementRef: () => {},
89
+ as: 'div'
90
+ }
91
+
92
+ View.allowedProps
93
+ .filter((prop) => prop !== 'children')
94
+ .forEach((prop) => {
95
+ if (Object.keys(allowedProps).indexOf(prop) < 0) {
96
+ it(`should NOT allow the '${prop}' prop`, async () => {
97
+ const props = {
98
+ [prop]: 'foo'
99
+ }
100
+ const expectedErrorMessage = `prop '${prop}' is not allowed.`
101
+
102
+ render(<Spinner renderTitle="Loading" {...props} />)
103
+
104
+ expect(consoleErrorMock).toHaveBeenCalledWith(
105
+ expect.stringContaining(expectedErrorMessage),
106
+ expect.any(String)
107
+ )
108
+ })
109
+ } else {
110
+ it(`should allow the '${prop}' prop`, async () => {
111
+ const props = { [prop]: allowedProps[prop] }
112
+ render(<Spinner renderTitle="Loading" {...props} />)
113
+
114
+ expect(consoleErrorMock).not.toHaveBeenCalled()
115
+ })
116
+ }
117
+ })
118
+ })
119
+
31
120
  describe('with the delay prop', () => {
32
121
  it('should delay rendering', async () => {
33
122
  render(<Spinner renderTitle="Loading" delay={300} />)
@@ -7,6 +7,7 @@
7
7
  },
8
8
  "include": ["src"],
9
9
  "references": [
10
+ { "path": "../ui-axe-check/tsconfig.build.json" },
10
11
  { "path": "../console/tsconfig.build.json" },
11
12
  { "path": "../emotion/tsconfig.build.json" },
12
13
  { "path": "../shared-types/tsconfig.build.json" },
@@ -17,7 +18,6 @@
17
18
  { "path": "../ui-view/tsconfig.build.json" },
18
19
  { "path": "../uid/tsconfig.build.json" },
19
20
  { "path": "../ui-babel-preset/tsconfig.build.json" },
20
- { "path": "../ui-test-locator/tsconfig.build.json" },
21
21
  { "path": "../ui-test-utils/tsconfig.build.json" },
22
22
  { "path": "../ui-themes/tsconfig.build.json" }
23
23
  ]