@pie-lib/render-ui 4.15.10-next.1 → 4.16.1-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.
Files changed (58) hide show
  1. package/CHANGELOG.md +20 -52
  2. package/NEXT.CHANGELOG.json +1 -0
  3. package/package.json +6 -4
  4. package/src/__tests__/__snapshots__/html-and-math.test.js.snap +11 -0
  5. package/src/__tests__/__snapshots__/preview-prompt.test.jsx.snap +37 -0
  6. package/src/__tests__/__snapshots__/purpose.test.jsx.snap +42 -0
  7. package/src/__tests__/__snapshots__/readable.test.jsx.snap +64 -0
  8. package/src/__tests__/__snapshots__/response-indicators.test.jsx.snap +95 -0
  9. package/src/__tests__/color.test.js +12 -0
  10. package/src/__tests__/has-media.test.js +20 -0
  11. package/src/__tests__/has-text.test.js +21 -0
  12. package/src/__tests__/html-and-math.test.js +46 -0
  13. package/src/__tests__/preview-prompt.test.jsx +56 -0
  14. package/src/__tests__/purpose.test.jsx +47 -0
  15. package/src/__tests__/readable.test.jsx +64 -0
  16. package/src/__tests__/response-indicators.test.jsx +16 -0
  17. package/src/__tests__/ui-layout.test.jsx +34 -0
  18. package/src/__tests__/withUndoReset.test.jsx +254 -0
  19. package/src/append-css-rules.js +51 -0
  20. package/src/assets/enableAudioAutoplayImage.js +1 -0
  21. package/src/collapsible/__tests__/__snapshots__/index.test.jsx.snap +18 -0
  22. package/src/collapsible/__tests__/index.test.jsx +13 -0
  23. package/src/collapsible/index.jsx +1 -0
  24. package/src/color.js +40 -0
  25. package/src/feedback.jsx +0 -1
  26. package/src/has-media.js +16 -0
  27. package/src/has-text.js +5 -1
  28. package/src/index.js +8 -0
  29. package/src/preview-layout.jsx +14 -3
  30. package/src/preview-prompt.jsx +150 -26
  31. package/src/ui-layout.jsx +66 -0
  32. package/README.md +0 -33
  33. package/lib/collapsible/index.js +0 -134
  34. package/lib/collapsible/index.js.map +0 -1
  35. package/lib/color.js +0 -157
  36. package/lib/color.js.map +0 -1
  37. package/lib/feedback.js +0 -151
  38. package/lib/feedback.js.map +0 -1
  39. package/lib/has-text.js +0 -24
  40. package/lib/has-text.js.map +0 -1
  41. package/lib/html-and-math.js +0 -90
  42. package/lib/html-and-math.js.map +0 -1
  43. package/lib/index.js +0 -104
  44. package/lib/index.js.map +0 -1
  45. package/lib/input-container.js +0 -60
  46. package/lib/input-container.js.map +0 -1
  47. package/lib/preview-layout.js +0 -133
  48. package/lib/preview-layout.js.map +0 -1
  49. package/lib/preview-prompt.js +0 -206
  50. package/lib/preview-prompt.js.map +0 -1
  51. package/lib/purpose.js +0 -28
  52. package/lib/purpose.js.map +0 -1
  53. package/lib/readable.js +0 -28
  54. package/lib/readable.js.map +0 -1
  55. package/lib/response-indicators.js +0 -151
  56. package/lib/response-indicators.js.map +0 -1
  57. package/lib/withUndoReset.js +0 -181
  58. package/lib/withUndoReset.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -3,18 +3,15 @@
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
- ## [4.15.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.8...@pie-lib/render-ui@4.15.9) (2023-10-03)
7
-
8
-
9
- ### Bug Fixes
6
+ ## [4.16.1-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.9...@pie-lib/render-ui@4.16.1-beta.0) (2025-07-20)
10
7
 
11
- * revert to pie-lib/math-rendering that what working ([25660ea](https://github.com/pie-framework/pie-lib/commit/25660ea6595e800a71c5494bd3bb9eecd3609a5a))
8
+ **Note:** Version bump only for package @pie-lib/render-ui
12
9
 
13
10
 
14
11
 
15
12
 
16
13
 
17
- ## [4.15.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.7...@pie-lib/render-ui@4.15.8) (2023-10-01)
14
+ # [4.16.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.9...@pie-lib/render-ui@4.16.0-beta.0) (2025-07-20)
18
15
 
19
16
  **Note:** Version bump only for package @pie-lib/render-ui
20
17
 
@@ -22,105 +19,76 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
22
19
 
23
20
 
24
21
 
25
- ## [4.15.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.6...@pie-lib/render-ui@4.15.7) (2023-09-27)
22
+ # [4.17.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.9...@pie-lib/render-ui@4.17.0-beta.0) (2025-07-15)
26
23
 
27
24
  **Note:** Version bump only for package @pie-lib/render-ui
28
25
 
26
+ # [4.16.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.9...@pie-lib/render-ui@4.16.0-beta.0) (2025-07-15)
29
27
 
28
+ **Note:** Version bump only for package @pie-lib/render-ui
30
29
 
30
+ ## [4.15.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.8...@pie-lib/render-ui@4.15.9) (2023-10-03)
31
31
 
32
+ ### Bug Fixes
32
33
 
33
- ## [4.15.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.5...@pie-lib/render-ui@4.15.6) (2023-09-27)
34
+ - revert to pie-lib/math-rendering that what working ([25660ea](https://github.com/pie-framework/pie-lib/commit/25660ea6595e800a71c5494bd3bb9eecd3609a5a))
35
+
36
+ ## [4.15.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.7...@pie-lib/render-ui@4.15.8) (2023-10-01)
34
37
 
35
38
  **Note:** Version bump only for package @pie-lib/render-ui
36
39
 
40
+ ## [4.15.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.6...@pie-lib/render-ui@4.15.7) (2023-09-27)
37
41
 
42
+ **Note:** Version bump only for package @pie-lib/render-ui
38
43
 
44
+ ## [4.15.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.5...@pie-lib/render-ui@4.15.6) (2023-09-27)
39
45
 
46
+ **Note:** Version bump only for package @pie-lib/render-ui
40
47
 
41
48
  ## [4.15.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.4...@pie-lib/render-ui@4.15.5) (2023-09-25)
42
49
 
43
50
  **Note:** Version bump only for package @pie-lib/render-ui
44
51
 
45
-
46
-
47
-
48
-
49
52
  ## [4.15.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.3...@pie-lib/render-ui@4.15.4) (2023-09-20)
50
53
 
51
54
  **Note:** Version bump only for package @pie-lib/render-ui
52
55
 
53
-
54
-
55
-
56
-
57
56
  ## [4.15.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.2...@pie-lib/render-ui@4.15.3) (2023-09-20)
58
57
 
59
58
  **Note:** Version bump only for package @pie-lib/render-ui
60
59
 
61
-
62
-
63
-
64
-
65
60
  ## [4.15.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.1...@pie-lib/render-ui@4.15.2) (2023-09-14)
66
61
 
67
62
  **Note:** Version bump only for package @pie-lib/render-ui
68
63
 
69
-
70
-
71
-
72
-
73
64
  ## [4.15.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.0...@pie-lib/render-ui@4.15.1) (2023-08-21)
74
65
 
75
-
76
66
  ### Bug Fixes
77
67
 
78
- * **render-ui:** DNA-17953 - avoid fontSize to fave initial value, avoid margins fot p elements ([3bdf0cf](https://github.com/pie-framework/pie-lib/commit/3bdf0cfa0ff343444b387b4840e904d76b27b41a))
79
-
80
-
81
-
82
-
68
+ - **render-ui:** DNA-17953 - avoid fontSize to fave initial value, avoid margins fot p elements ([3bdf0cf](https://github.com/pie-framework/pie-lib/commit/3bdf0cfa0ff343444b387b4840e904d76b27b41a))
83
69
 
84
70
  # [4.15.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.14.29...@pie-lib/render-ui@4.15.0) (2023-08-15)
85
71
 
86
-
87
72
  ### Features
88
73
 
89
- * **text-select:** adjust colors and alignment of the color ([a51ba55](https://github.com/pie-framework/pie-lib/commit/a51ba5547f6e1559915d6ea967d406923831b561))
90
- * **text-select:** PD-1163 create wrapper component ([b41db39](https://github.com/pie-framework/pie-lib/commit/b41db39ade332d19dca70a06d54acf51b5888c69))
91
- * **text-select:** PD-1163 updates to tokens in text select ([2535c91](https://github.com/pie-framework/pie-lib/commit/2535c911f378f4cf41c8471bfa1898b996ffacee))
92
-
93
-
94
-
95
-
74
+ - **text-select:** adjust colors and alignment of the color ([a51ba55](https://github.com/pie-framework/pie-lib/commit/a51ba5547f6e1559915d6ea967d406923831b561))
75
+ - **text-select:** PD-1163 create wrapper component ([b41db39](https://github.com/pie-framework/pie-lib/commit/b41db39ade332d19dca70a06d54acf51b5888c69))
76
+ - **text-select:** PD-1163 updates to tokens in text select ([2535c91](https://github.com/pie-framework/pie-lib/commit/2535c911f378f4cf41c8471bfa1898b996ffacee))
96
77
 
97
78
  ## [4.14.29](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.14.28...@pie-lib/render-ui@4.14.29) (2023-07-24)
98
79
 
99
-
100
80
  ### Bug Fixes
101
81
 
102
- * **render-ui:** answer choices answered rendered in a smaller font-size ([e7503e0](https://github.com/pie-framework/pie-lib/commit/e7503e029ed6872098646e8787e124f2d6a8a018))
103
-
104
-
105
-
106
-
82
+ - **render-ui:** answer choices answered rendered in a smaller font-size ([e7503e0](https://github.com/pie-framework/pie-lib/commit/e7503e029ed6872098646e8787e124f2d6a8a018))
107
83
 
108
84
  ## [4.14.28](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.14.27...@pie-lib/render-ui@4.14.28) (2023-06-24)
109
85
 
110
86
  **Note:** Version bump only for package @pie-lib/render-ui
111
87
 
112
-
113
-
114
-
115
-
116
88
  ## [4.14.27](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.14.26...@pie-lib/render-ui@4.14.27) (2023-06-13)
117
89
 
118
90
  **Note:** Version bump only for package @pie-lib/render-ui
119
91
 
120
-
121
-
122
-
123
-
124
92
  ## [4.14.26](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.14.25...@pie-lib/render-ui@4.14.26) (2023-06-12)
125
93
 
126
94
  **Note:** Version bump only for package @pie-lib/render-ui
@@ -0,0 +1 @@
1
+ []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/render-ui",
3
- "version": "4.15.10-next.1+23991a09",
3
+ "version": "4.16.1-beta.0",
4
4
  "description": "Some shared ui elements when rendering - but not worthy of their own package yet.",
5
5
  "module": "src/index.js",
6
6
  "main": "lib/index.js",
@@ -11,10 +11,12 @@
11
11
  "dependencies": {
12
12
  "@material-ui/core": "^3.8.3",
13
13
  "@material-ui/icons": "^3.0.2",
14
- "@pie-lib/icons": "^2.4.43",
15
- "@pie-lib/math-rendering": "2.5.18",
14
+ "@pie-lib/icons": "^2.5.1-beta.0",
15
+ "@pie-lib/math-rendering": "^3.3.1-beta.0",
16
+ "@pie-lib/test-utils": "beta",
16
17
  "classnames": "^2.2.6",
17
18
  "debug": "^4.1.1",
19
+ "lodash": "^4.17.11",
18
20
  "prop-types": "^15.7.2",
19
21
  "react-transition-group": "^2.5.2"
20
22
  },
@@ -26,5 +28,5 @@
26
28
  "react": "^16.8.1",
27
29
  "react-dom": "^16.8.1"
28
30
  },
29
- "gitHead": "23991a09b77492c24dcb5235049667cdcc211d80"
31
+ "gitHead": "e2aa3ddac60f49bcb8c2562370f496323642f453"
30
32
  }
@@ -0,0 +1,11 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`html-and-math render renders 1`] = `
4
+ <div
5
+ dangerouslySetInnerHTML={
6
+ Object {
7
+ "__html": "<p>hi</p>",
8
+ }
9
+ }
10
+ />
11
+ `;
@@ -0,0 +1,37 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Prompt with Custom tag renders with custom tag "span" correctly renders 1`] = `
4
+ <PreviewPrompt
5
+ className="prompt"
6
+ classes={
7
+ Object {
8
+ "label": "PreviewPrompt-label-4",
9
+ "legend": "PreviewPrompt-legend-2",
10
+ "prompt": "PreviewPrompt-prompt-1",
11
+ "promptTable": "PreviewPrompt-promptTable-5",
12
+ "rationale": "PreviewPrompt-rationale-3",
13
+ }
14
+ }
15
+ onClick={[Function]}
16
+ prompt="Which of these northern European countries are EU members? <math><mstack><msrow><mn>111</mn></msrow><msline/></mstack></math>"
17
+ tagName="span"
18
+ />
19
+ `;
20
+
21
+ exports[`Prompt without Custom tag default class with markup renders 1`] = `
22
+ <PreviewPrompt
23
+ className=""
24
+ classes={
25
+ Object {
26
+ "label": "PreviewPrompt-label-4",
27
+ "legend": "PreviewPrompt-legend-2",
28
+ "prompt": "PreviewPrompt-prompt-1",
29
+ "promptTable": "PreviewPrompt-promptTable-5",
30
+ "rationale": "PreviewPrompt-rationale-3",
31
+ }
32
+ }
33
+ onClick={[Function]}
34
+ prompt="Which of these northern European countries are EU members? <math><mstack><msrow><mn>111</mn></msrow><msline/></mstack></math>"
35
+ tagName=""
36
+ />
37
+ `;
@@ -0,0 +1,42 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Purpose renders fine renders child unaltered 1`] = `
4
+ <Purpose
5
+ purpose="passage"
6
+ >
7
+ <div
8
+ data-pie-purpose="passage"
9
+ key=".0"
10
+ >
11
+ text
12
+ </div>
13
+ </Purpose>
14
+ `;
15
+
16
+ exports[`Purpose renders fine renders child unaltered without purpose prop 1`] = `
17
+ <Purpose>
18
+ <div
19
+ key=".0"
20
+ >
21
+ text
22
+ </div>
23
+ </Purpose>
24
+ `;
25
+
26
+ exports[`Purpose renders fine renders children unaltered 1`] = `
27
+ <Purpose
28
+ purpose="something"
29
+ >
30
+ <div
31
+ data-pie-purpose="something"
32
+ key=".0"
33
+ >
34
+ <div>
35
+ text1
36
+ </div>
37
+ <div>
38
+ text2
39
+ </div>
40
+ </div>
41
+ </Purpose>
42
+ `;
@@ -0,0 +1,64 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Readable renders fine renders child unaltered 1`] = `
4
+ <Readable>
5
+ <div
6
+ data-pie-readable={true}
7
+ key=".0"
8
+ >
9
+ text
10
+ </div>
11
+ </Readable>
12
+ `;
13
+
14
+ exports[`Readable renders fine renders children unaltered 1`] = `
15
+ <Readable>
16
+ <div
17
+ data-pie-readable={true}
18
+ key=".0"
19
+ >
20
+ <div>
21
+ text1
22
+ </div>
23
+ <div>
24
+ text2
25
+ </div>
26
+ </div>
27
+ </Readable>
28
+ `;
29
+
30
+ exports[`Readable renders fine renders even with specific true tag 1`] = `
31
+ <Readable
32
+ false={true}
33
+ >
34
+ <div
35
+ data-pie-readable={false}
36
+ key=".0"
37
+ >
38
+ <div>
39
+ text1
40
+ </div>
41
+ <div>
42
+ text2
43
+ </div>
44
+ </div>
45
+ </Readable>
46
+ `;
47
+
48
+ exports[`Readable renders fine renders with false tag 1`] = `
49
+ <Readable
50
+ false={true}
51
+ >
52
+ <div
53
+ data-pie-readable={false}
54
+ key=".0"
55
+ >
56
+ <div>
57
+ text1
58
+ </div>
59
+ <div>
60
+ text2
61
+ </div>
62
+ </div>
63
+ </Readable>
64
+ `;
@@ -0,0 +1,95 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`response-indicators snapshot - no feedback 1`] = `
4
+ <div>
5
+ <span
6
+ onClick={[Function]}
7
+ >
8
+ <div
9
+ style={
10
+ Object {
11
+ "display": "inline-block",
12
+ "height": "30px",
13
+ "position": "relative",
14
+ "width": "30px",
15
+ }
16
+ }
17
+ >
18
+ <svg
19
+ preserveAspectRatio="xMinYMin meet"
20
+ style={
21
+ Object {
22
+ "enableBackground": "new 0 0 44 40",
23
+ }
24
+ }
25
+ version="1.1"
26
+ viewBox="0 0 44 40"
27
+ x="0px"
28
+ y="0px"
29
+ >
30
+
31
+ <circle
32
+ className="IconBase-bg-5"
33
+ cx="23"
34
+ cy="20.4"
35
+ r="16"
36
+ transform="translate(-3, 0)"
37
+ />
38
+ <polygon
39
+ className="IconBase-fg-6"
40
+ points="19.1,28.6 11.8,22.3 14.4,19.2 17.9,22.1 23.9,11.4 27.5,13.4"
41
+ transform="translate(0, 0)"
42
+ />
43
+ </svg>
44
+ </div>
45
+ </span>
46
+ </div>
47
+ `;
48
+
49
+ exports[`response-indicators snapshot - with feedback 1`] = `
50
+ <div
51
+ className="RawIndicator-responseIndicator-1"
52
+ >
53
+ <span
54
+ onClick={[Function]}
55
+ >
56
+ <div
57
+ style={
58
+ Object {
59
+ "display": "inline-block",
60
+ "height": "30px",
61
+ "position": "relative",
62
+ "width": "30px",
63
+ }
64
+ }
65
+ >
66
+ <svg
67
+ preserveAspectRatio="xMinYMin meet"
68
+ style={
69
+ Object {
70
+ "enableBackground": "new 0 0 44 40",
71
+ }
72
+ }
73
+ version="1.1"
74
+ viewBox="0 0 44 40"
75
+ x="0px"
76
+ y="0px"
77
+ >
78
+
79
+ <circle
80
+ className="IconBase-bg-5"
81
+ cx="23"
82
+ cy="20.4"
83
+ r="16"
84
+ transform="translate(-3, 0)"
85
+ />
86
+ <polygon
87
+ className="IconBase-fg-6"
88
+ points="19.1,28.6 11.8,22.3 14.4,19.2 17.9,22.1 23.9,11.4 27.5,13.4"
89
+ transform="translate(0, 0)"
90
+ />
91
+ </svg>
92
+ </div>
93
+ </span>
94
+ </div>
95
+ `;
@@ -0,0 +1,12 @@
1
+ import { v } from '../color';
2
+ describe('v', () => {
3
+ it.each`
4
+ args | expected
5
+ ${['text', 'black']} | ${'var(--pie-text, black)'}
6
+ ${['primary-text', 'text', 'black']} | ${'var(--pie-primary-text, var(--pie-text, black))'}
7
+ ${['black']} | ${'black'}
8
+ ${['#00ff00']} | ${'#00ff00'}
9
+ `('$args => $expected', ({ args, expected }) => {
10
+ expect(v('pie')(...args)).toEqual(expected);
11
+ });
12
+ });
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ import { hasMedia } from '../has-media'; // Assuming you have a hasMedia function
3
+
4
+ describe('hasMedia', () => {
5
+ it.each`
6
+ input | expected
7
+ ${'<img src="image.jpg" />'} | ${true}
8
+ ${'<audio src="audio.mp3" />'} | ${true}
9
+ ${'<div><img src="image.jpg" /></div>'} | ${true}
10
+ ${'<div><audio src="audio.mp3" /></div>'} | ${true}
11
+ ${'<div>No media here</div>'} | ${false}
12
+ ${'<div></div>'} | ${false}
13
+ ${' '} | ${false}
14
+ ${null} | ${false}
15
+ `('$input -> $expected', ({ input, expected }) => {
16
+ const output = hasMedia(input);
17
+
18
+ expect(output).toEqual(expected);
19
+ });
20
+ });
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { hasText } from '../has-text';
3
+
4
+ describe('has-text', () => {
5
+ it.each`
6
+ input | expected
7
+ ${'<div>Rationale</div>'} | ${true}
8
+ ${'Rationale'} | ${true}
9
+ ${'<div>hi</div>'} | ${true}
10
+ ${'<div>hi'} | ${true}
11
+ ${'<div></div>'} | ${false}
12
+ ${'<div> </div>'} | ${false}
13
+ ${'<div><br /> </div>'} | ${false}
14
+ ${' '} | ${false}
15
+ ${null} | ${false}
16
+ `('$input -> $expected', ({ input, expected }) => {
17
+ const output = hasText(input);
18
+
19
+ expect(output).toEqual(expected);
20
+ });
21
+ });
@@ -0,0 +1,46 @@
1
+ import HtmlAndMath from '../html-and-math';
2
+ import { shallow } from 'enzyme';
3
+ import React from 'react';
4
+ import { renderMath } from '@pie-lib/math-rendering';
5
+
6
+ jest.mock('@pie-lib/math-rendering', () => ({ renderMath: jest.fn() }));
7
+
8
+ describe('html-and-math', () => {
9
+ const mkWrapper = (extras) => {
10
+ const props = {
11
+ html: '<p>hi</p>',
12
+ ...extras,
13
+ };
14
+
15
+ return shallow(<HtmlAndMath {...props} />, {
16
+ disableLifecycleMethods: true,
17
+ });
18
+ };
19
+
20
+ describe('render', () => {
21
+ it('renders', () => {
22
+ const w = mkWrapper();
23
+
24
+ expect(w).toMatchSnapshot();
25
+ });
26
+ });
27
+
28
+ describe('componentDidMount', () => {
29
+ it('calls renderMath', () => {
30
+ const w = mkWrapper();
31
+ //mock the ref
32
+ w.instance().node = { node: true };
33
+ w.instance().componentDidMount();
34
+ expect(renderMath).toHaveBeenCalled();
35
+ });
36
+ });
37
+ describe('componentDidUpdate', () => {
38
+ it('calls renderMath', () => {
39
+ const w = mkWrapper();
40
+ //mock the ref
41
+ w.instance().node = { node: true };
42
+ w.instance().componentDidUpdate();
43
+ expect(renderMath).toHaveBeenCalled();
44
+ });
45
+ });
46
+ });
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import PreviewPrompt from '../preview-prompt';
4
+
5
+ describe('Prompt without Custom tag ', () => {
6
+ let wrapper;
7
+ let mkWrapper = (opts) => {
8
+ opts = {
9
+ classes: {},
10
+ prompt:
11
+ 'Which of these northern European countries are EU members? <math><mstack><msrow><mn>111</mn></msrow><msline/></mstack></math>',
12
+ tagName: '',
13
+ className: '',
14
+ ...opts,
15
+ };
16
+
17
+ return shallow(<PreviewPrompt {...opts} />);
18
+ };
19
+
20
+ beforeEach(() => {
21
+ wrapper = mkWrapper();
22
+ });
23
+
24
+ describe('default class with markup', () => {
25
+ it('renders', () => {
26
+ expect(wrapper.hasClass('prompt')).toEqual(false);
27
+ expect(wrapper).toMatchSnapshot();
28
+ });
29
+ });
30
+ });
31
+
32
+ describe('Prompt with Custom tag ', () => {
33
+ let wrapper;
34
+ let mkWrapper = (opts) => {
35
+ opts = {
36
+ classes: {},
37
+ prompt:
38
+ 'Which of these northern European countries are EU members? <math><mstack><msrow><mn>111</mn></msrow><msline/></mstack></math>',
39
+ tagName: '',
40
+ className: '',
41
+ ...opts,
42
+ };
43
+ return shallow(<PreviewPrompt {...opts} />);
44
+ };
45
+
46
+ beforeEach(() => {
47
+ wrapper = mkWrapper({ tagName: 'span', className: 'prompt' });
48
+ });
49
+
50
+ describe('renders with custom tag "span" correctly', () => {
51
+ it('renders', () => {
52
+ expect(wrapper.hasClass('prompt')).toEqual(true);
53
+ expect(wrapper).toMatchSnapshot();
54
+ });
55
+ });
56
+ });
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import Purpose from '../purpose';
4
+
5
+ describe('Purpose', () => {
6
+ let wrapper;
7
+
8
+ describe('renders fine', () => {
9
+ it('renders child unaltered without purpose prop', () => {
10
+ wrapper = mount(
11
+ <Purpose>
12
+ <div>text</div>
13
+ </Purpose>,
14
+ );
15
+ expect(wrapper.find('div')).toHaveLength(1);
16
+ expect(wrapper.html().includes('data-pie-purpose=""')).toEqual(false);
17
+ expect(wrapper.html().includes('text')).toEqual(true);
18
+ expect(wrapper).toMatchSnapshot();
19
+ });
20
+ it('renders child unaltered', () => {
21
+ wrapper = mount(
22
+ <Purpose purpose="passage">
23
+ <div>text</div>
24
+ </Purpose>,
25
+ );
26
+ expect(wrapper.find('div')).toHaveLength(1);
27
+ expect(wrapper.html().includes('data-pie-purpose="passage"')).toEqual(true);
28
+ expect(wrapper.html().includes('text')).toEqual(true);
29
+ expect(wrapper).toMatchSnapshot();
30
+ });
31
+ it('renders children unaltered', () => {
32
+ wrapper = mount(
33
+ <Purpose purpose="something">
34
+ <div>
35
+ <div>text1</div>
36
+ <div>text2</div>
37
+ </div>
38
+ </Purpose>,
39
+ );
40
+ expect(wrapper.find('div')).toHaveLength(3);
41
+ expect(wrapper.html().includes('data-pie-purpose="something"')).toEqual(true);
42
+ expect(wrapper.html().includes('text1')).toEqual(true);
43
+ expect(wrapper.html().includes('text3')).toEqual(false);
44
+ expect(wrapper).toMatchSnapshot();
45
+ });
46
+ });
47
+ });