@api-client/ui 0.5.39 → 0.5.40

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 (281) hide show
  1. package/build/tsconfig.tsbuildinfo +1 -0
  2. package/package.json +1 -1
  3. package/.aiexclude +0 -3
  4. package/.cursor/rules/html-and-css-best-practices.mdc +0 -63
  5. package/.cursor/rules/lit-best-practices.mdc +0 -89
  6. package/.editorconfig +0 -29
  7. package/.github/CONTRIBUTING.md +0 -24
  8. package/.github/instructions/html-and-css-best-practices.instructions.md +0 -70
  9. package/.github/instructions/lit-best-practices.instructions.md +0 -90
  10. package/.github/release.yml +0 -14
  11. package/.github/stale.yml +0 -23
  12. package/.github/workflows/auto-release.yml +0 -182
  13. package/.github/workflows/release.yml +0 -82
  14. package/.prettierrc.js +0 -14
  15. package/.vscode/settings.json +0 -18
  16. package/RELEASE.md +0 -163
  17. package/RELEASE_SETUP.md +0 -235
  18. package/build/src/demo/DemoPage.d.ts +0 -81
  19. package/build/src/demo/DemoPage.d.ts.map +0 -1
  20. package/build/src/demo/DemoPage.js +0 -175
  21. package/build/src/demo/DemoPage.js.map +0 -1
  22. package/build/src/demo/DemoStyles.d.ts +0 -3
  23. package/build/src/demo/DemoStyles.d.ts.map +0 -1
  24. package/build/src/demo/DemoStyles.js +0 -60
  25. package/build/src/demo/DemoStyles.js.map +0 -1
  26. package/build/test/elements/navigation/Navigation.test.d.ts +0 -3
  27. package/build/test/elements/navigation/Navigation.test.d.ts.map +0 -1
  28. package/build/test/elements/navigation/Navigation.test.js +0 -113
  29. package/build/test/elements/navigation/Navigation.test.js.map +0 -1
  30. package/commitlint.config.cjs +0 -2
  31. package/demo/elements/authorization/AuthPlugin.js +0 -57
  32. package/demo/elements/authorization/AuthProxy.js +0 -215
  33. package/demo/elements/authorization/api-key.html +0 -27
  34. package/demo/elements/authorization/api-key.ts +0 -44
  35. package/demo/elements/authorization/basic.html +0 -27
  36. package/demo/elements/authorization/basic.ts +0 -43
  37. package/demo/elements/authorization/bearer.html +0 -27
  38. package/demo/elements/authorization/bearer.ts +0 -43
  39. package/demo/elements/authorization/env.js +0 -8
  40. package/demo/elements/authorization/index.html +0 -44
  41. package/demo/elements/authorization/ntlm.html +0 -27
  42. package/demo/elements/authorization/ntlm.ts +0 -43
  43. package/demo/elements/authorization/oauth-authorize.html +0 -75
  44. package/demo/elements/authorization/oauth-authorize.ts +0 -40
  45. package/demo/elements/authorization/oauth-error.html +0 -18
  46. package/demo/elements/authorization/oauth-error.ts +0 -10
  47. package/demo/elements/authorization/oauth-popup.html +0 -36
  48. package/demo/elements/authorization/oauth2.html +0 -27
  49. package/demo/elements/authorization/oauth2.ts +0 -100
  50. package/demo/elements/authorization/oidc.html +0 -27
  51. package/demo/elements/authorization/oidc.ts +0 -139
  52. package/demo/elements/authorization/private.crt +0 -31
  53. package/demo/elements/authorization/private.csr +0 -28
  54. package/demo/elements/authorization/private.key +0 -51
  55. package/demo/elements/authorization/private.pem +0 -31
  56. package/demo/elements/authorization/redirect.html +0 -20
  57. package/demo/elements/authorization/ssl-commands.sh +0 -30
  58. package/demo/elements/authorization/ssl.conf +0 -24
  59. package/demo/elements/autocomplete/index.html +0 -64
  60. package/demo/elements/autocomplete/index.ts +0 -171
  61. package/demo/elements/code-editor/CodeEditorDemo.ts +0 -173
  62. package/demo/elements/code-editor/index.html +0 -19
  63. package/demo/elements/context-menu/DemoIcons.ts +0 -21
  64. package/demo/elements/context-menu/basic.html +0 -25
  65. package/demo/elements/context-menu/basic.ts +0 -119
  66. package/demo/elements/context-menu/custom-data.html +0 -25
  67. package/demo/elements/context-menu/custom-data.ts +0 -62
  68. package/demo/elements/context-menu/demo.css +0 -28
  69. package/demo/elements/context-menu/enabled-state.html +0 -25
  70. package/demo/elements/context-menu/enabled-state.ts +0 -73
  71. package/demo/elements/context-menu/icons.html +0 -25
  72. package/demo/elements/context-menu/icons.ts +0 -64
  73. package/demo/elements/context-menu/index.html +0 -43
  74. package/demo/elements/context-menu/nested.html +0 -25
  75. package/demo/elements/context-menu/nestedt.ts +0 -152
  76. package/demo/elements/context-menu/no-execute.html +0 -25
  77. package/demo/elements/context-menu/no-execute.ts +0 -134
  78. package/demo/elements/context-menu/radio-menu.html +0 -25
  79. package/demo/elements/context-menu/radio-menu.ts +0 -83
  80. package/demo/elements/context-menu/separators.html +0 -25
  81. package/demo/elements/context-menu/separators.ts +0 -172
  82. package/demo/elements/currency/index.html +0 -91
  83. package/demo/elements/currency/index.ts +0 -352
  84. package/demo/elements/environment/environment-editor.html +0 -20
  85. package/demo/elements/environment/environment-editor.ts +0 -49
  86. package/demo/elements/environment/index.html +0 -33
  87. package/demo/elements/environment/server-editor.html +0 -20
  88. package/demo/elements/environment/server-editor.ts +0 -67
  89. package/demo/elements/environment/variables-editor.html +0 -20
  90. package/demo/elements/environment/variables-editor.ts +0 -94
  91. package/demo/elements/har/har-viewer.html +0 -20
  92. package/demo/elements/har/har-viewer.ts +0 -76
  93. package/demo/elements/har/har1.har +0 -3044
  94. package/demo/elements/har/har2.json +0 -439
  95. package/demo/elements/har/index.html +0 -26
  96. package/demo/elements/highlight/example.md +0 -27
  97. package/demo/elements/highlight/index.html +0 -31
  98. package/demo/elements/highlight/marked-highlight.html +0 -132
  99. package/demo/elements/highlight/marked-highlight.ts +0 -22
  100. package/demo/elements/highlight/prism-highlight.html +0 -62
  101. package/demo/elements/highlight/prism-highlight.ts +0 -17
  102. package/demo/elements/http/body-editor.html +0 -17
  103. package/demo/elements/http/body-editor.ts +0 -115
  104. package/demo/elements/http/headers.html +0 -17
  105. package/demo/elements/http/headers.ts +0 -59
  106. package/demo/elements/http/http-assertions.html +0 -20
  107. package/demo/elements/http/http-assertions.ts +0 -89
  108. package/demo/elements/http/http-flows.html +0 -23
  109. package/demo/elements/http/http-flows.ts +0 -89
  110. package/demo/elements/http/index.html +0 -45
  111. package/demo/elements/http/request-editor.html +0 -26
  112. package/demo/elements/http/request-editor.ts +0 -197
  113. package/demo/elements/http/request-log.html +0 -16
  114. package/demo/elements/http/request-log.ts +0 -136
  115. package/demo/elements/http/url-editing.html +0 -17
  116. package/demo/elements/http/url-editing.ts +0 -112
  117. package/demo/elements/icons/index.html +0 -81
  118. package/demo/elements/icons/index.ts +0 -52
  119. package/demo/elements/index.html +0 -72
  120. package/demo/elements/mention-textarea/index.html +0 -19
  121. package/demo/elements/mention-textarea/index.ts +0 -205
  122. package/demo/elements/navigation/navigation-item.html +0 -49
  123. package/demo/elements/navigation/navigation-item.ts +0 -131
  124. package/demo/elements/navigation/navigation.html +0 -20
  125. package/demo/elements/navigation/navigation.ts +0 -45
  126. package/demo/elements/project/index.html +0 -29
  127. package/demo/elements/project/project-run-report.html +0 -20
  128. package/demo/elements/project/project-run-report.ts +0 -132
  129. package/demo/elements/project/request-editor.html +0 -23
  130. package/demo/elements/project/request-editor.ts +0 -232
  131. package/demo/elements/user/user-avatar.html +0 -17
  132. package/demo/elements/user/user-avatar.ts +0 -60
  133. package/demo/env.js +0 -4
  134. package/demo/index.html +0 -34
  135. package/demo/layout/index.html +0 -94
  136. package/demo/layout/index.ts +0 -190
  137. package/demo/md/DemoStyles.ts +0 -61
  138. package/demo/md/UiDemoPage.ts +0 -6
  139. package/demo/md/buttons/button.html +0 -121
  140. package/demo/md/buttons/button.ts +0 -246
  141. package/demo/md/buttons/group.html +0 -36
  142. package/demo/md/buttons/group.ts +0 -171
  143. package/demo/md/checkbox/index.html +0 -39
  144. package/demo/md/checkbox/index.ts +0 -220
  145. package/demo/md/chip/chip.html +0 -70
  146. package/demo/md/chip/chip.ts +0 -219
  147. package/demo/md/chip/pawel6c9a.jpg +0 -0
  148. package/demo/md/collapse/CustomDetail.ts +0 -89
  149. package/demo/md/collapse/collapse.html +0 -21
  150. package/demo/md/collapse/collapse.ts +0 -78
  151. package/demo/md/date-picker/date-picker.ts +0 -336
  152. package/demo/md/date-picker/index.html +0 -171
  153. package/demo/md/dialog/confirm-dialog.html +0 -49
  154. package/demo/md/dialog/confirm-dialog.ts +0 -121
  155. package/demo/md/dialog/dialog.html +0 -25
  156. package/demo/md/dialog/dialog.ts +0 -468
  157. package/demo/md/dropdown-list/index.html +0 -31
  158. package/demo/md/dropdown-list/index.ts +0 -158
  159. package/demo/md/icon-button/index.html +0 -122
  160. package/demo/md/icon-button/index.ts +0 -132
  161. package/demo/md/index.html +0 -73
  162. package/demo/md/inputs/input.html +0 -73
  163. package/demo/md/inputs/input.ts +0 -278
  164. package/demo/md/inputs/radio.html +0 -39
  165. package/demo/md/inputs/radio.ts +0 -156
  166. package/demo/md/inputs/switch.html +0 -45
  167. package/demo/md/inputs/switch.ts +0 -144
  168. package/demo/md/list/list.html +0 -65
  169. package/demo/md/list/list.ts +0 -204
  170. package/demo/md/listbox/listbox.html +0 -31
  171. package/demo/md/listbox/listbox.ts +0 -27
  172. package/demo/md/menu/index.html +0 -19
  173. package/demo/md/menu/index.ts +0 -514
  174. package/demo/md/notification/snack.html +0 -21
  175. package/demo/md/notification/snack.ts +0 -70
  176. package/demo/md/progress/progress.html +0 -46
  177. package/demo/md/progress/progress.ts +0 -161
  178. package/demo/md/segmented-button/index.html +0 -21
  179. package/demo/md/segmented-button/index.ts +0 -55
  180. package/demo/md/select/index.html +0 -16
  181. package/demo/md/select/index.ts +0 -217
  182. package/demo/md/tabs/tabs.html +0 -40
  183. package/demo/md/tabs/tabs.ts +0 -214
  184. package/demo/oauth-popup.html +0 -36
  185. package/demo/page.css +0 -8
  186. package/demo/resources/calendar-month.png +0 -0
  187. package/demo/resources/favorite.png +0 -0
  188. package/demo/resources/fingerprint.png +0 -0
  189. package/demo/resources/home-work.png +0 -0
  190. package/demo/resources/mood.png +0 -0
  191. package/demo/resources/print.png +0 -0
  192. package/demo/resources/stars.png +0 -0
  193. package/demo/resources/theaters.png +0 -0
  194. package/demo/tsconfig.json +0 -4
  195. package/eslint.config.js +0 -97
  196. package/scripts/copy-assets.js +0 -21
  197. package/scripts/release.js +0 -66
  198. package/src/demo/DemoPage.ts +0 -169
  199. package/src/demo/DemoStyles.ts +0 -60
  200. package/test/README.md +0 -375
  201. package/test/contextual-menu/ContextMenu.test.ts +0 -760
  202. package/test/contextual-menu/ContextMenuElement.test.ts +0 -569
  203. package/test/core/activity.spec.ts +0 -413
  204. package/test/core/activity_manager.spec.ts +0 -544
  205. package/test/core/application.spec.ts +0 -218
  206. package/test/core/fragment.spec.ts +0 -565
  207. package/test/core/fragment_manager.spec.ts +0 -404
  208. package/test/core/live_data.spec.ts +0 -558
  209. package/test/core/renderer.spec.ts +0 -113
  210. package/test/dom-assertions.test.ts +0 -182
  211. package/test/elements/MonacoSetup.ts +0 -65
  212. package/test/elements/authorization/basic-method.test.ts +0 -177
  213. package/test/elements/authorization/bearer-method.test.ts +0 -143
  214. package/test/elements/authorization/ntlm-method.test.ts +0 -219
  215. package/test/elements/authorization/oauth2-client-credentials-method.test.ts +0 -334
  216. package/test/elements/authorization/oauth2-code-method.test.ts +0 -320
  217. package/test/elements/authorization/oauth2-custom-grant-method.test.ts +0 -255
  218. package/test/elements/authorization/oauth2-device-code-method.test.ts +0 -371
  219. package/test/elements/authorization/oauth2-implicit-method.test.ts +0 -407
  220. package/test/elements/authorization/oauth2-jwt-method.test.ts +0 -217
  221. package/test/elements/authorization/oauth2-password-method.test.ts +0 -275
  222. package/test/elements/authorization/openid-method.test.ts +0 -591
  223. package/test/elements/autocomplete/autocomplete-input.spec.ts +0 -646
  224. package/test/elements/code-editor/code-editor.accessibility.test.ts +0 -298
  225. package/test/elements/code-editor/code-editor.test.ts +0 -574
  226. package/test/elements/currency/CurrencyPicker.accessibility.test.ts +0 -328
  227. package/test/elements/currency/CurrencyPicker.core.test.ts +0 -318
  228. package/test/elements/currency/CurrencyPicker.integration.test.ts +0 -482
  229. package/test/elements/currency/CurrencyPicker.test.ts +0 -486
  230. package/test/elements/data-table/DataTable.browser.test.ts +0 -649
  231. package/test/elements/har/HarUtils.test.ts +0 -45
  232. package/test/elements/har/HarViewerElement.test.ts +0 -687
  233. package/test/elements/har/test-data/har1.har +0 -3044
  234. package/test/elements/highlight/MarkedHighlightElement.test.ts +0 -452
  235. package/test/elements/highlight/PrismHighlightElement.test.ts +0 -79
  236. package/test/elements/highlight/PrismHighlighter.test.ts +0 -94
  237. package/test/elements/highlight/remoteSanitization.md +0 -1
  238. package/test/elements/highlight/test.md +0 -3
  239. package/test/elements/highlight/test1.md +0 -3
  240. package/test/elements/highlight/test2.md +0 -1
  241. package/test/elements/http/BodyFormdataEditorElement.test.ts +0 -482
  242. package/test/elements/http/BodyMultipartEditorElement.test.ts +0 -658
  243. package/test/elements/http/BodyRawEditorElement.test.ts +0 -90
  244. package/test/elements/http/CertificateAdd.test.ts +0 -457
  245. package/test/elements/http/HttpAssertions.test.ts +0 -994
  246. package/test/elements/http/HttpFlows.test.ts +0 -502
  247. package/test/elements/http/UrlEncodeUtils.test.ts +0 -202
  248. package/test/elements/layout/SplitItem.test.ts +0 -440
  249. package/test/elements/layout/SplitLayoutManager.test.ts +0 -1501
  250. package/test/elements/layout/SplitPanel.test.ts +0 -1109
  251. package/test/elements/mention-textarea/MentionTextArea.basic.test.ts +0 -114
  252. package/test/elements/mention-textarea/MentionTextArea.test.ts +0 -613
  253. package/test/elements/navigation/Navigation.test.ts +0 -120
  254. package/test/env.ts +0 -15
  255. package/test/events/EventTypes.test.ts +0 -363
  256. package/test/events/EventsTestHelpers.ts +0 -16
  257. package/test/helpers/TestUtils.ts +0 -243
  258. package/test/helpers/UiMock.ts +0 -185
  259. package/test/lib/Dom.test.ts +0 -231
  260. package/test/md/button/UiButton.test.ts +0 -347
  261. package/test/md/button/UiIconButton.test.ts +0 -155
  262. package/test/md/chip/UiChip.test.ts +0 -219
  263. package/test/md/collapse/UiCollapse.test.ts +0 -250
  264. package/test/md/collapse/flex-layout.test.ts +0 -105
  265. package/test/md/date-time/DateTime.test.ts +0 -348
  266. package/test/md/dialog/UiConfirmDialog.test.ts +0 -131
  267. package/test/md/dialog/UiDialog.test.ts +0 -759
  268. package/test/md/menu/Menu.test.ts +0 -855
  269. package/test/md/menu/MenuIntegration.test.ts +0 -426
  270. package/test/md/menu/MenuItem.test.ts +0 -652
  271. package/test/md/menu/SubMenu.test.ts +0 -410
  272. package/test/md/progress/UiCircularProgressElement.test.ts +0 -481
  273. package/test/md/progress/UiProgressElement.test.ts +0 -117
  274. package/test/md/progress/UiRangeElement.test.ts +0 -156
  275. package/test/md/select/Select.test.ts +0 -925
  276. package/test/plugins/takeScreenshotPlugin.js +0 -35
  277. package/test/setup.test.ts +0 -217
  278. package/test/setup.ts +0 -117
  279. package/test/tsconfig.json +0 -7
  280. package/web-dev-server.config.js +0 -21
  281. package/web-test-runner.config.js +0 -90
@@ -1,202 +0,0 @@
1
- import { assert } from '@open-wc/testing'
2
- import { IProperty, Property } from '@api-client/core/browser.js'
3
- // import { loadMonaco } from '../MonacoSetup.js'
4
- import {
5
- encodeUrlEncoded,
6
- encodeQueryString,
7
- modelItemToFormDataString,
8
- decodeUrlEncoded,
9
- formArrayToString,
10
- decodeQueryString,
11
- } from '../../../src/elements/http/UrlEncodeUtils.js'
12
-
13
- describe('UrlEncodeUtils', () => {
14
- describe('URL encoder', () => {
15
- it('encodes a string', () => {
16
- const src = 'test=encoded value&encoded name=encoded value'
17
- const compare = 'test=encoded+value&encoded+name=encoded+value'
18
- const result = encodeUrlEncoded(src)
19
- assert.equal(result, compare)
20
- })
21
-
22
- it('encodes a string with repeatable parameters', () => {
23
- const src = 'test=encoded value&test=other value&encoded name=encoded value'
24
- const compare = 'test=encoded+value&test=other+value&encoded+name=encoded+value'
25
- const result = encodeUrlEncoded(src)
26
- assert.equal(result, compare)
27
- })
28
-
29
- it('encodes an array', () => {
30
- const src: IProperty[] = [
31
- Property.String('test', 'encoded value').toJSON(),
32
- Property.String('encoded name', 'encoded value').toJSON(),
33
- ]
34
- const compare: IProperty[] = [
35
- Property.String('test', 'encoded+value').toJSON(),
36
- Property.String('encoded+name', 'encoded+value').toJSON(),
37
- ]
38
- const str = encodeUrlEncoded(src)
39
- assert.deepEqual(str, compare)
40
- })
41
-
42
- it('encodes an array with array value', () => {
43
- const base = Property.String().toJSON()
44
-
45
- const src: IProperty[] = [
46
- { ...base, name: 'test', value: ['encoded value', 'other value'] },
47
- Property.String('encoded name', 'encoded value').toJSON(),
48
- ]
49
- const compare: IProperty[] = [
50
- { ...base, name: 'test', value: ['encoded+value', 'other+value'] },
51
- Property.String('encoded+name', 'encoded+value').toJSON(),
52
- ]
53
- const result = encodeUrlEncoded(src)
54
- assert.deepEqual(result, compare)
55
- })
56
-
57
- it('encodes a query string', () => {
58
- const query = '/test path/?param name=param value'
59
- const encoded = encodeQueryString(query)
60
- // path will be encoded, this function encodes query params only.
61
- const compare = '%2Ftest+path%2F%3Fparam+name%3Dparam+value'
62
- assert.equal(encoded, compare)
63
- })
64
- })
65
-
66
- describe('URL decoder', () => {
67
- it('Decode encoded string', () => {
68
- const compare = 'test=encoded value&encoded name=encoded value'
69
- const src = 'test=encoded+value&encoded+name=encoded+value'
70
- const result = decodeUrlEncoded(src)
71
- assert.equal(result, compare)
72
- })
73
-
74
- it('Decode encoded string with repeatable parameters', () => {
75
- const src = 'test=encoded+value&encoded+name=encoded+value&test=other+value'
76
- const compare = 'test=encoded value&test=other value&encoded name=encoded value'
77
- const result = decodeUrlEncoded(src)
78
- assert.equal(result, compare)
79
- })
80
-
81
- it('Decodes encoded array', () => {
82
- const compare: IProperty[] = [
83
- Property.String('test', 'encoded value').toJSON(),
84
- Property.String('encoded name', 'encoded value').toJSON(),
85
- ]
86
- const input: IProperty[] = [
87
- Property.String('test', 'encoded+value').toJSON(),
88
- Property.String('encoded+name', 'encoded+value').toJSON(),
89
- ]
90
- const result = decodeUrlEncoded(input)
91
- assert.deepEqual(result, compare)
92
- })
93
-
94
- it('Decodes encoded array with array value', () => {
95
- const base = Property.String().toJSON()
96
-
97
- const compare: IProperty[] = [
98
- Property.String('test', 'encoded value').toJSON(),
99
- { ...base, name: 'encoded name', value: ['encoded value', 'other value'] },
100
- ]
101
-
102
- const src: IProperty[] = [
103
- Property.String('test', 'encoded+value').toJSON(),
104
- { ...base, name: 'encoded+name', value: ['encoded+value', 'other+value'] },
105
- ]
106
- const str = decodeUrlEncoded(src)
107
- assert.deepEqual(str, compare)
108
- })
109
- })
110
-
111
- describe('modelItemToFormDataString()', () => {
112
- it('returns undefined when item is not enabled', () => {
113
- const property = Property.String('', '', false).toJSON()
114
- const result = modelItemToFormDataString(property)
115
- assert.isUndefined(result)
116
- })
117
-
118
- it('returns undefined when no name and value', () => {
119
- const property = Property.String('', '').toJSON()
120
- const result = modelItemToFormDataString(property)
121
- assert.isUndefined(result)
122
- })
123
-
124
- it('returns undefined when no value value and no required', () => {
125
- const property = Property.String('test', '', false).toJSON()
126
- const result = modelItemToFormDataString(property)
127
- assert.isUndefined(result)
128
- })
129
-
130
- it('returns a string', () => {
131
- const property = Property.String('test', 'value', true).toJSON()
132
- const result = modelItemToFormDataString(property)
133
- assert.typeOf(result, 'string')
134
- })
135
-
136
- it('always returns a string', () => {
137
- const property = Property.Boolean('test', true, true).toJSON()
138
- const result = modelItemToFormDataString(property)
139
- assert.equal(result, 'test=true')
140
- })
141
-
142
- it('processes array values', () => {
143
- const property = Property.fromType('test', '', true).toJSON()
144
- property.value = ['a', 'b']
145
- const result = modelItemToFormDataString(property)
146
- assert.equal(result, 'test=a&test=b')
147
- })
148
- })
149
-
150
- describe('Array to string', () => {
151
- it('Create payload string from an array', () => {
152
- const list: IProperty[] = [
153
- Property.String('test', 'encoded value').toJSON(),
154
- Property.String('encoded name', 'encoded value').toJSON(),
155
- ]
156
- const compare = 'test=encoded value&encoded name=encoded value'
157
- const str = formArrayToString(list)
158
- assert.equal(str, compare)
159
- })
160
-
161
- it('Empty model returns empty string', () => {
162
- const list: IProperty[] = [Property.String('', '').toJSON()]
163
- const str = formArrayToString(list)
164
- assert.equal(str, '')
165
- })
166
-
167
- it('Should create www-urlencoded string from array', () => {
168
- const list: IProperty[] = [
169
- Property.String('test', 'encoded value').toJSON(),
170
- Property.String('encoded name', 'encoded value').toJSON(),
171
- ]
172
- const compare = 'test=encoded+value&encoded+name=encoded+value'
173
- const str = formArrayToString(encodeUrlEncoded(list) as IProperty[])
174
- assert.equal(str, compare)
175
- })
176
-
177
- it('Should create payload string from array with array value', () => {
178
- const arrayProperty = Property.String('test', '').toJSON()
179
- arrayProperty.value = ['encoded value', 'other value']
180
- const list: IProperty[] = [arrayProperty, Property.String('encoded name', 'encoded value').toJSON()]
181
- const compare = 'test=encoded value&test=other value&encoded name=encoded value'
182
- const str = formArrayToString(list)
183
- assert.equal(str, compare)
184
- })
185
- })
186
-
187
- describe('encodeQueryString()', () => {
188
- it('returns undefined when no input', () => {
189
- // @ts-expect-error For testing purposes
190
- const result = encodeQueryString(undefined)
191
- assert.isUndefined(result)
192
- })
193
- })
194
-
195
- describe('decodeQueryString()', () => {
196
- it('returns undefined when no input', () => {
197
- // @ts-expect-error For testing purposes
198
- const result = decodeQueryString(undefined)
199
- assert.isUndefined(result)
200
- })
201
- })
202
- })
@@ -1,440 +0,0 @@
1
- import { assert } from '@open-wc/testing'
2
- import sinon from 'sinon'
3
- import { ISplitItem, SplitItem } from '../../../src/elements/layout/SplitItem.js'
4
- import { SplitLayout } from '../../../src/elements/layout/SplitLayout.js'
5
- import { SplitPanel } from '../../../src/elements/layout/SplitPanel.js'
6
-
7
- describe('layout', () => {
8
- describe('SplitItem', () => {
9
- describe('new()', () => {
10
- let manager: SplitLayout
11
-
12
- beforeEach(() => {
13
- manager = new SplitLayout()
14
- })
15
-
16
- it('sets the kind', () => {
17
- const kind = 'test-kind'
18
- const instance = new SplitItem(manager, {
19
- key: '',
20
- kind,
21
- label: '',
22
- })
23
- assert.equal(instance.kind, kind)
24
- })
25
-
26
- it('sets the key', () => {
27
- const key = 'test-key'
28
- const instance = new SplitItem(manager, {
29
- key,
30
- kind: '',
31
- label: '',
32
- })
33
- assert.equal(instance.key, key)
34
- })
35
-
36
- it('sets the label', () => {
37
- const label = 'test-label'
38
- const instance = new SplitItem(manager, {
39
- key: '',
40
- kind: '',
41
- label,
42
- })
43
- assert.equal(instance.label, label)
44
- })
45
-
46
- it('sets the parent', () => {
47
- const parent = 'test-parent'
48
- const instance = new SplitItem(manager, {
49
- key: '',
50
- kind: '',
51
- label: '',
52
- parent,
53
- })
54
- assert.equal(instance.parent, parent)
55
- })
56
-
57
- it('re-sets the parent', () => {
58
- const schema: ISplitItem = {
59
- key: '',
60
- kind: '',
61
- label: '',
62
- parent: 'test-parent',
63
- }
64
- const instance = new SplitItem(manager, schema)
65
- delete schema.parent
66
- instance.new(schema)
67
- assert.isUndefined(instance.parent)
68
- })
69
-
70
- it('sets the icon', () => {
71
- const icon = 'add'
72
- const instance = new SplitItem(manager, {
73
- key: '',
74
- kind: '',
75
- label: '',
76
- icon,
77
- })
78
- assert.equal(instance.icon, icon)
79
- })
80
-
81
- it('re-sets the icon', () => {
82
- const schema: ISplitItem = {
83
- key: '',
84
- kind: '',
85
- label: '',
86
- icon: 'add',
87
- }
88
- const instance = new SplitItem(manager, schema)
89
- delete schema.icon
90
- instance.new(schema)
91
- assert.isUndefined(instance.icon)
92
- })
93
-
94
- it('sets the pinned', () => {
95
- const pinned = true
96
- const instance = new SplitItem(manager, {
97
- key: '',
98
- kind: '',
99
- label: '',
100
- pinned,
101
- })
102
- assert.isTrue(instance.pinned)
103
- })
104
-
105
- it('re-sets the pinned', () => {
106
- const schema: ISplitItem = {
107
- key: '',
108
- kind: '',
109
- label: '',
110
- pinned: true,
111
- }
112
- const instance = new SplitItem(manager, schema)
113
- delete schema.pinned
114
- instance.new(schema)
115
- assert.isUndefined(instance.pinned)
116
- })
117
-
118
- it('sets the persistent', () => {
119
- const persistent = true
120
- const instance = new SplitItem(manager, {
121
- key: '',
122
- kind: '',
123
- label: '',
124
- persistent,
125
- })
126
- assert.isTrue(instance.persistent)
127
- })
128
-
129
- it('re-sets the persistent', () => {
130
- const schema: ISplitItem = {
131
- key: '',
132
- kind: '',
133
- label: '',
134
- persistent: true,
135
- }
136
- const instance = new SplitItem(manager, schema)
137
- delete schema.persistent
138
- instance.new(schema)
139
- assert.isUndefined(instance.persistent)
140
- })
141
-
142
- it('sets the loading', () => {
143
- const loading = true
144
- const instance = new SplitItem(manager, {
145
- key: '',
146
- kind: '',
147
- label: '',
148
- loading,
149
- })
150
- assert.isTrue(instance.loading)
151
- })
152
-
153
- it('re-sets the loading', () => {
154
- const schema: ISplitItem = {
155
- key: '',
156
- kind: '',
157
- label: '',
158
- loading: true,
159
- }
160
- const instance = new SplitItem(manager, schema)
161
- delete schema.loading
162
- instance.new(schema)
163
- assert.isUndefined(instance.loading)
164
- })
165
-
166
- it('sets the isDirty', () => {
167
- const isDirty = true
168
- const instance = new SplitItem(manager, {
169
- key: '',
170
- kind: '',
171
- label: '',
172
- isDirty,
173
- })
174
- assert.isTrue(instance.isDirty)
175
- })
176
-
177
- it('re-sets the isDirty', () => {
178
- const schema: ISplitItem = {
179
- key: '',
180
- kind: '',
181
- label: '',
182
- isDirty: true,
183
- }
184
- const instance = new SplitItem(manager, schema)
185
- delete schema.isDirty
186
- instance.new(schema)
187
- assert.isUndefined(instance.isDirty)
188
- })
189
-
190
- it('sets the index', () => {
191
- const index = 1
192
- const instance = new SplitItem(manager, {
193
- key: '',
194
- kind: '',
195
- label: '',
196
- index,
197
- })
198
- assert.equal(instance.index, index)
199
- })
200
-
201
- it('re-sets the index', () => {
202
- const schema: ISplitItem = {
203
- key: '',
204
- kind: '',
205
- label: '',
206
- index: 1,
207
- }
208
- const instance = new SplitItem(manager, schema)
209
- delete schema.index
210
- instance.new(schema)
211
- assert.equal(instance.index, 0)
212
- })
213
- })
214
-
215
- describe('toJSON()', () => {
216
- let manager: SplitLayout
217
- let base: ISplitItem
218
-
219
- beforeEach(() => {
220
- manager = new SplitLayout()
221
- base = {
222
- key: 'test-key',
223
- kind: 'test-kind',
224
- label: 'test-label',
225
- }
226
- })
227
-
228
- it('serializes the kind', () => {
229
- const instance = new SplitItem(manager, base)
230
- assert.equal(instance.toJSON().kind, 'test-kind')
231
- })
232
-
233
- it('serializes the key', () => {
234
- const instance = new SplitItem(manager, base)
235
- assert.equal(instance.toJSON().key, 'test-key')
236
- })
237
-
238
- it('serializes the label', () => {
239
- const instance = new SplitItem(manager, base)
240
- assert.equal(instance.toJSON().label, 'test-label')
241
- })
242
-
243
- it('serializes the label', () => {
244
- const instance = new SplitItem(manager, { ...base, parent: 'test-parent' })
245
- assert.equal(instance.toJSON().parent, 'test-parent')
246
- })
247
-
248
- it('serializes the icon', () => {
249
- const instance = new SplitItem(manager, { ...base, icon: 'add' })
250
- assert.equal(instance.toJSON().icon, 'add')
251
- })
252
-
253
- it('serializes the pinned', () => {
254
- const instance = new SplitItem(manager, { ...base, pinned: false })
255
- assert.isFalse(instance.toJSON().pinned)
256
- })
257
-
258
- it('serializes the persistent', () => {
259
- const instance = new SplitItem(manager, { ...base, persistent: false })
260
- assert.isFalse(instance.toJSON().persistent)
261
- })
262
-
263
- it('serializes the loading', () => {
264
- const instance = new SplitItem(manager, { ...base, loading: false })
265
- assert.isFalse(instance.toJSON().loading)
266
- })
267
-
268
- it('serializes the isDirty', () => {
269
- const instance = new SplitItem(manager, { ...base, isDirty: false })
270
- assert.isFalse(instance.toJSON().isDirty)
271
- })
272
-
273
- it('serializes the index', () => {
274
- const instance = new SplitItem(manager, { ...base, index: 0 })
275
- assert.equal(instance.toJSON().index, 0)
276
- })
277
-
278
- it('serializes the value', () => {
279
- const instance = new SplitItem(manager, { ...base, value: 'something' })
280
- assert.equal(instance.toJSON().value, 'something')
281
- })
282
-
283
- it('serializes the value with the toJSON() function', () => {
284
- const value = {
285
- a: 'a',
286
- toJSON: (): unknown => {
287
- const serialized = {
288
- a: 'b',
289
- }
290
- return serialized
291
- },
292
- }
293
- const instance = new SplitItem(manager, { ...base, value })
294
- assert.deepEqual(instance.toJSON().value, { a: 'b' })
295
- })
296
- })
297
-
298
- describe('getParents()', () => {
299
- let manager: SplitLayout
300
-
301
- beforeEach(() => {
302
- manager = new SplitLayout()
303
- })
304
-
305
- it('returns undefined when no parent', () => {
306
- const instance = new SplitItem(manager, {
307
- key: 'test-key',
308
- kind: 'test-kind',
309
- label: 'test-label',
310
- })
311
- const result = instance.getParents()
312
- assert.deepEqual(result, [])
313
- })
314
-
315
- it('returns the parent panel', () => {
316
- const panel = manager.addPanel()
317
- const instance = panel.addItem({
318
- key: 'test-key',
319
- kind: 'test-kind',
320
- label: 'test-label',
321
- })
322
- const result = instance.getParents()
323
- assert.deepEqual(result, [panel])
324
- })
325
- })
326
-
327
- // describe('remove()', () => {
328
- // let manager: SplitLayout;
329
- // let panel: SplitPanel;
330
- // let item: SplitItem;
331
-
332
- // beforeEach(() => {
333
- // manager = new SplitLayout();
334
- // panel = manager.addPanel();
335
- // item = panel.addItem({
336
- // key: 'test-key',
337
- // kind: 'test-kind',
338
- // label: 'test-label',
339
- // });
340
- // });
341
-
342
- // it('removes the item from definitions', () => {
343
- // item.remove();
344
- // const result = manager.definitions.get(item.key);
345
- // assert.notOk(result);
346
- // });
347
-
348
- // it('removes the item from the parent items', () => {
349
- // item.remove();
350
- // assert.deepEqual(panel.items, []);
351
- // });
352
-
353
- // it('informs the panel listeners about item removed', () => {
354
- // const spy = sinon.spy();
355
- // manager.addEventListener('closetab', spy);
356
- // item.remove();
357
- // assert.isTrue(spy.calledOnce, 'the event is dispatched');
358
- // const e = spy.args[0][0] as CustomEvent<ITabCloseDetail>;
359
- // assert.equal(e.detail.tab, item.key, 'has the item key on the detail')
360
- // assert.equal(e.detail.panel, panel.key, 'has the panel key on the detail')
361
- // });
362
-
363
- // it('informs the panel listeners about layout change', () => {
364
- // const spy = sinon.spy();
365
- // manager.addEventListener('change', spy);
366
- // item.remove();
367
- // assert.isTrue(spy.calledOnce, 'the event is dispatched');
368
- // });
369
- // });
370
-
371
- // describe('setSelected()', () => {
372
- // let manager: SplitLayout;
373
- // let panel: SplitPanel;
374
- // let item: SplitItem;
375
-
376
- // beforeEach(() => {
377
- // manager = new SplitLayout();
378
- // panel = manager.addPanel();
379
- // item = panel.addItem({
380
- // key: 'test-key',
381
- // kind: 'test-kind',
382
- // label: 'test-label',
383
- // });
384
- // });
385
-
386
- // it('sets item selected with the panel', () => {
387
- // item.setSelected();
388
- // assert.equal(panel.selected, item.key);
389
- // });
390
-
391
- // it('informs the panel listeners about layout change', () => {
392
- // const spy = sinon.spy();
393
- // manager.addEventListener('change', spy);
394
- // item.setSelected();
395
- // assert.isTrue(spy.calledOnce, 'the event is dispatched');
396
- // });
397
- // });
398
-
399
- describe('setLabel()', () => {
400
- let manager: SplitLayout
401
- let panel: SplitPanel
402
- let item: SplitItem
403
-
404
- beforeEach(() => {
405
- manager = new SplitLayout()
406
- panel = manager.addPanel()
407
- item = panel.addItem({
408
- key: 'test-key',
409
- kind: 'test-kind',
410
- label: 'test-label',
411
- })
412
- })
413
-
414
- it('sets the label when changed', () => {
415
- item.setLabel('other')
416
- assert.equal(item.label, 'other')
417
- })
418
-
419
- it('calls updateView on the panel', () => {
420
- const spy = sinon.spy(panel, 'updateView')
421
- item.setLabel('other')
422
- assert.isTrue(spy.calledOnce, 'the method is called')
423
- })
424
-
425
- it('informs the panel listeners about layout change', () => {
426
- const spy = sinon.spy()
427
- manager.addEventListener('change', spy)
428
- item.setLabel('other')
429
- assert.isTrue(spy.calledOnce, 'the event is dispatched')
430
- })
431
-
432
- it('ignores side effects when value is the same', () => {
433
- const spy = sinon.spy()
434
- manager.addEventListener('change', spy)
435
- item.setLabel('test-label')
436
- assert.isFalse(spy.called, 'the event is not dispatched')
437
- })
438
- })
439
- })
440
- })