@api-client/ui 0.5.38 → 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 (299) hide show
  1. package/build/src/md/list/internals/ListItem.d.ts +24 -15
  2. package/build/src/md/list/internals/ListItem.d.ts.map +1 -1
  3. package/build/src/md/list/internals/ListItem.js +85 -59
  4. package/build/src/md/list/internals/ListItem.js.map +1 -1
  5. package/build/src/md/list/internals/ListItem.styles.js +11 -11
  6. package/build/src/md/list/internals/ListItem.styles.js.map +1 -1
  7. package/build/src/md/select/internals/Option.d.ts +4 -14
  8. package/build/src/md/select/internals/Option.d.ts.map +1 -1
  9. package/build/src/md/select/internals/Option.js +13 -28
  10. package/build/src/md/select/internals/Option.js.map +1 -1
  11. package/build/src/md/select/internals/Select.d.ts +1 -1
  12. package/build/src/md/select/internals/Select.d.ts.map +1 -1
  13. package/build/src/md/select/internals/Select.js +15 -5
  14. package/build/src/md/select/internals/Select.js.map +1 -1
  15. package/build/tsconfig.tsbuildinfo +1 -0
  16. package/package.json +1 -1
  17. package/src/md/list/internals/ListItem.styles.ts +11 -11
  18. package/src/md/list/internals/ListItem.ts +68 -43
  19. package/src/md/select/internals/Option.ts +14 -26
  20. package/src/md/select/internals/Select.ts +15 -5
  21. package/.aiexclude +0 -3
  22. package/.cursor/rules/html-and-css-best-practices.mdc +0 -63
  23. package/.cursor/rules/lit-best-practices.mdc +0 -89
  24. package/.editorconfig +0 -29
  25. package/.github/CONTRIBUTING.md +0 -24
  26. package/.github/instructions/html-and-css-best-practices.instructions.md +0 -70
  27. package/.github/instructions/lit-best-practices.instructions.md +0 -90
  28. package/.github/release.yml +0 -14
  29. package/.github/stale.yml +0 -23
  30. package/.github/workflows/auto-release.yml +0 -182
  31. package/.github/workflows/release.yml +0 -82
  32. package/.prettierrc.js +0 -14
  33. package/.vscode/settings.json +0 -18
  34. package/RELEASE.md +0 -163
  35. package/RELEASE_SETUP.md +0 -235
  36. package/build/src/demo/DemoPage.d.ts +0 -81
  37. package/build/src/demo/DemoPage.d.ts.map +0 -1
  38. package/build/src/demo/DemoPage.js +0 -175
  39. package/build/src/demo/DemoPage.js.map +0 -1
  40. package/build/src/demo/DemoStyles.d.ts +0 -3
  41. package/build/src/demo/DemoStyles.d.ts.map +0 -1
  42. package/build/src/demo/DemoStyles.js +0 -60
  43. package/build/src/demo/DemoStyles.js.map +0 -1
  44. package/build/test/elements/navigation/Navigation.test.d.ts +0 -3
  45. package/build/test/elements/navigation/Navigation.test.d.ts.map +0 -1
  46. package/build/test/elements/navigation/Navigation.test.js +0 -113
  47. package/build/test/elements/navigation/Navigation.test.js.map +0 -1
  48. package/commitlint.config.cjs +0 -2
  49. package/demo/elements/authorization/AuthPlugin.js +0 -57
  50. package/demo/elements/authorization/AuthProxy.js +0 -215
  51. package/demo/elements/authorization/api-key.html +0 -27
  52. package/demo/elements/authorization/api-key.ts +0 -44
  53. package/demo/elements/authorization/basic.html +0 -27
  54. package/demo/elements/authorization/basic.ts +0 -43
  55. package/demo/elements/authorization/bearer.html +0 -27
  56. package/demo/elements/authorization/bearer.ts +0 -43
  57. package/demo/elements/authorization/env.js +0 -8
  58. package/demo/elements/authorization/index.html +0 -44
  59. package/demo/elements/authorization/ntlm.html +0 -27
  60. package/demo/elements/authorization/ntlm.ts +0 -43
  61. package/demo/elements/authorization/oauth-authorize.html +0 -75
  62. package/demo/elements/authorization/oauth-authorize.ts +0 -40
  63. package/demo/elements/authorization/oauth-error.html +0 -18
  64. package/demo/elements/authorization/oauth-error.ts +0 -10
  65. package/demo/elements/authorization/oauth-popup.html +0 -36
  66. package/demo/elements/authorization/oauth2.html +0 -27
  67. package/demo/elements/authorization/oauth2.ts +0 -100
  68. package/demo/elements/authorization/oidc.html +0 -27
  69. package/demo/elements/authorization/oidc.ts +0 -139
  70. package/demo/elements/authorization/private.crt +0 -31
  71. package/demo/elements/authorization/private.csr +0 -28
  72. package/demo/elements/authorization/private.key +0 -51
  73. package/demo/elements/authorization/private.pem +0 -31
  74. package/demo/elements/authorization/redirect.html +0 -20
  75. package/demo/elements/authorization/ssl-commands.sh +0 -30
  76. package/demo/elements/authorization/ssl.conf +0 -24
  77. package/demo/elements/autocomplete/index.html +0 -64
  78. package/demo/elements/autocomplete/index.ts +0 -171
  79. package/demo/elements/code-editor/CodeEditorDemo.ts +0 -173
  80. package/demo/elements/code-editor/index.html +0 -19
  81. package/demo/elements/context-menu/DemoIcons.ts +0 -21
  82. package/demo/elements/context-menu/basic.html +0 -25
  83. package/demo/elements/context-menu/basic.ts +0 -119
  84. package/demo/elements/context-menu/custom-data.html +0 -25
  85. package/demo/elements/context-menu/custom-data.ts +0 -62
  86. package/demo/elements/context-menu/demo.css +0 -28
  87. package/demo/elements/context-menu/enabled-state.html +0 -25
  88. package/demo/elements/context-menu/enabled-state.ts +0 -73
  89. package/demo/elements/context-menu/icons.html +0 -25
  90. package/demo/elements/context-menu/icons.ts +0 -64
  91. package/demo/elements/context-menu/index.html +0 -43
  92. package/demo/elements/context-menu/nested.html +0 -25
  93. package/demo/elements/context-menu/nestedt.ts +0 -152
  94. package/demo/elements/context-menu/no-execute.html +0 -25
  95. package/demo/elements/context-menu/no-execute.ts +0 -134
  96. package/demo/elements/context-menu/radio-menu.html +0 -25
  97. package/demo/elements/context-menu/radio-menu.ts +0 -83
  98. package/demo/elements/context-menu/separators.html +0 -25
  99. package/demo/elements/context-menu/separators.ts +0 -172
  100. package/demo/elements/currency/index.html +0 -91
  101. package/demo/elements/currency/index.ts +0 -352
  102. package/demo/elements/environment/environment-editor.html +0 -20
  103. package/demo/elements/environment/environment-editor.ts +0 -49
  104. package/demo/elements/environment/index.html +0 -33
  105. package/demo/elements/environment/server-editor.html +0 -20
  106. package/demo/elements/environment/server-editor.ts +0 -67
  107. package/demo/elements/environment/variables-editor.html +0 -20
  108. package/demo/elements/environment/variables-editor.ts +0 -94
  109. package/demo/elements/har/har-viewer.html +0 -20
  110. package/demo/elements/har/har-viewer.ts +0 -76
  111. package/demo/elements/har/har1.har +0 -3044
  112. package/demo/elements/har/har2.json +0 -439
  113. package/demo/elements/har/index.html +0 -26
  114. package/demo/elements/highlight/example.md +0 -27
  115. package/demo/elements/highlight/index.html +0 -31
  116. package/demo/elements/highlight/marked-highlight.html +0 -132
  117. package/demo/elements/highlight/marked-highlight.ts +0 -22
  118. package/demo/elements/highlight/prism-highlight.html +0 -62
  119. package/demo/elements/highlight/prism-highlight.ts +0 -17
  120. package/demo/elements/http/body-editor.html +0 -17
  121. package/demo/elements/http/body-editor.ts +0 -115
  122. package/demo/elements/http/headers.html +0 -17
  123. package/demo/elements/http/headers.ts +0 -59
  124. package/demo/elements/http/http-assertions.html +0 -20
  125. package/demo/elements/http/http-assertions.ts +0 -89
  126. package/demo/elements/http/http-flows.html +0 -23
  127. package/demo/elements/http/http-flows.ts +0 -89
  128. package/demo/elements/http/index.html +0 -45
  129. package/demo/elements/http/request-editor.html +0 -26
  130. package/demo/elements/http/request-editor.ts +0 -197
  131. package/demo/elements/http/request-log.html +0 -16
  132. package/demo/elements/http/request-log.ts +0 -136
  133. package/demo/elements/http/url-editing.html +0 -17
  134. package/demo/elements/http/url-editing.ts +0 -112
  135. package/demo/elements/icons/index.html +0 -81
  136. package/demo/elements/icons/index.ts +0 -52
  137. package/demo/elements/index.html +0 -72
  138. package/demo/elements/mention-textarea/index.html +0 -19
  139. package/demo/elements/mention-textarea/index.ts +0 -205
  140. package/demo/elements/navigation/navigation-item.html +0 -49
  141. package/demo/elements/navigation/navigation-item.ts +0 -131
  142. package/demo/elements/navigation/navigation.html +0 -20
  143. package/demo/elements/navigation/navigation.ts +0 -45
  144. package/demo/elements/project/index.html +0 -29
  145. package/demo/elements/project/project-run-report.html +0 -20
  146. package/demo/elements/project/project-run-report.ts +0 -132
  147. package/demo/elements/project/request-editor.html +0 -23
  148. package/demo/elements/project/request-editor.ts +0 -232
  149. package/demo/elements/user/user-avatar.html +0 -17
  150. package/demo/elements/user/user-avatar.ts +0 -60
  151. package/demo/env.js +0 -4
  152. package/demo/index.html +0 -34
  153. package/demo/layout/index.html +0 -94
  154. package/demo/layout/index.ts +0 -190
  155. package/demo/md/DemoStyles.ts +0 -61
  156. package/demo/md/UiDemoPage.ts +0 -6
  157. package/demo/md/buttons/button.html +0 -121
  158. package/demo/md/buttons/button.ts +0 -246
  159. package/demo/md/buttons/group.html +0 -36
  160. package/demo/md/buttons/group.ts +0 -171
  161. package/demo/md/checkbox/index.html +0 -39
  162. package/demo/md/checkbox/index.ts +0 -220
  163. package/demo/md/chip/chip.html +0 -70
  164. package/demo/md/chip/chip.ts +0 -219
  165. package/demo/md/chip/pawel6c9a.jpg +0 -0
  166. package/demo/md/collapse/CustomDetail.ts +0 -89
  167. package/demo/md/collapse/collapse.html +0 -21
  168. package/demo/md/collapse/collapse.ts +0 -78
  169. package/demo/md/date-picker/date-picker.ts +0 -336
  170. package/demo/md/date-picker/index.html +0 -171
  171. package/demo/md/dialog/confirm-dialog.html +0 -49
  172. package/demo/md/dialog/confirm-dialog.ts +0 -121
  173. package/demo/md/dialog/dialog.html +0 -25
  174. package/demo/md/dialog/dialog.ts +0 -468
  175. package/demo/md/dropdown-list/index.html +0 -31
  176. package/demo/md/dropdown-list/index.ts +0 -158
  177. package/demo/md/icon-button/index.html +0 -122
  178. package/demo/md/icon-button/index.ts +0 -132
  179. package/demo/md/index.html +0 -73
  180. package/demo/md/inputs/input.html +0 -73
  181. package/demo/md/inputs/input.ts +0 -278
  182. package/demo/md/inputs/radio.html +0 -39
  183. package/demo/md/inputs/radio.ts +0 -156
  184. package/demo/md/inputs/switch.html +0 -45
  185. package/demo/md/inputs/switch.ts +0 -144
  186. package/demo/md/list/list.html +0 -65
  187. package/demo/md/list/list.ts +0 -204
  188. package/demo/md/listbox/listbox.html +0 -31
  189. package/demo/md/listbox/listbox.ts +0 -27
  190. package/demo/md/menu/index.html +0 -19
  191. package/demo/md/menu/index.ts +0 -514
  192. package/demo/md/notification/snack.html +0 -21
  193. package/demo/md/notification/snack.ts +0 -70
  194. package/demo/md/progress/progress.html +0 -46
  195. package/demo/md/progress/progress.ts +0 -161
  196. package/demo/md/segmented-button/index.html +0 -21
  197. package/demo/md/segmented-button/index.ts +0 -55
  198. package/demo/md/select/index.html +0 -16
  199. package/demo/md/select/index.ts +0 -207
  200. package/demo/md/tabs/tabs.html +0 -40
  201. package/demo/md/tabs/tabs.ts +0 -214
  202. package/demo/oauth-popup.html +0 -36
  203. package/demo/page.css +0 -8
  204. package/demo/resources/calendar-month.png +0 -0
  205. package/demo/resources/favorite.png +0 -0
  206. package/demo/resources/fingerprint.png +0 -0
  207. package/demo/resources/home-work.png +0 -0
  208. package/demo/resources/mood.png +0 -0
  209. package/demo/resources/print.png +0 -0
  210. package/demo/resources/stars.png +0 -0
  211. package/demo/resources/theaters.png +0 -0
  212. package/demo/tsconfig.json +0 -4
  213. package/eslint.config.js +0 -97
  214. package/scripts/copy-assets.js +0 -21
  215. package/scripts/release.js +0 -66
  216. package/src/demo/DemoPage.ts +0 -169
  217. package/src/demo/DemoStyles.ts +0 -60
  218. package/test/README.md +0 -375
  219. package/test/contextual-menu/ContextMenu.test.ts +0 -760
  220. package/test/contextual-menu/ContextMenuElement.test.ts +0 -569
  221. package/test/core/activity.spec.ts +0 -413
  222. package/test/core/activity_manager.spec.ts +0 -544
  223. package/test/core/application.spec.ts +0 -218
  224. package/test/core/fragment.spec.ts +0 -565
  225. package/test/core/fragment_manager.spec.ts +0 -404
  226. package/test/core/live_data.spec.ts +0 -558
  227. package/test/core/renderer.spec.ts +0 -113
  228. package/test/dom-assertions.test.ts +0 -182
  229. package/test/elements/MonacoSetup.ts +0 -65
  230. package/test/elements/authorization/basic-method.test.ts +0 -177
  231. package/test/elements/authorization/bearer-method.test.ts +0 -143
  232. package/test/elements/authorization/ntlm-method.test.ts +0 -219
  233. package/test/elements/authorization/oauth2-client-credentials-method.test.ts +0 -334
  234. package/test/elements/authorization/oauth2-code-method.test.ts +0 -320
  235. package/test/elements/authorization/oauth2-custom-grant-method.test.ts +0 -255
  236. package/test/elements/authorization/oauth2-device-code-method.test.ts +0 -371
  237. package/test/elements/authorization/oauth2-implicit-method.test.ts +0 -407
  238. package/test/elements/authorization/oauth2-jwt-method.test.ts +0 -217
  239. package/test/elements/authorization/oauth2-password-method.test.ts +0 -275
  240. package/test/elements/authorization/openid-method.test.ts +0 -591
  241. package/test/elements/autocomplete/autocomplete-input.spec.ts +0 -646
  242. package/test/elements/code-editor/code-editor.accessibility.test.ts +0 -298
  243. package/test/elements/code-editor/code-editor.test.ts +0 -574
  244. package/test/elements/currency/CurrencyPicker.accessibility.test.ts +0 -328
  245. package/test/elements/currency/CurrencyPicker.core.test.ts +0 -318
  246. package/test/elements/currency/CurrencyPicker.integration.test.ts +0 -482
  247. package/test/elements/currency/CurrencyPicker.test.ts +0 -486
  248. package/test/elements/data-table/DataTable.browser.test.ts +0 -649
  249. package/test/elements/har/HarUtils.test.ts +0 -45
  250. package/test/elements/har/HarViewerElement.test.ts +0 -687
  251. package/test/elements/har/test-data/har1.har +0 -3044
  252. package/test/elements/highlight/MarkedHighlightElement.test.ts +0 -452
  253. package/test/elements/highlight/PrismHighlightElement.test.ts +0 -79
  254. package/test/elements/highlight/PrismHighlighter.test.ts +0 -94
  255. package/test/elements/highlight/remoteSanitization.md +0 -1
  256. package/test/elements/highlight/test.md +0 -3
  257. package/test/elements/highlight/test1.md +0 -3
  258. package/test/elements/highlight/test2.md +0 -1
  259. package/test/elements/http/BodyFormdataEditorElement.test.ts +0 -482
  260. package/test/elements/http/BodyMultipartEditorElement.test.ts +0 -658
  261. package/test/elements/http/BodyRawEditorElement.test.ts +0 -90
  262. package/test/elements/http/CertificateAdd.test.ts +0 -457
  263. package/test/elements/http/HttpAssertions.test.ts +0 -994
  264. package/test/elements/http/HttpFlows.test.ts +0 -502
  265. package/test/elements/http/UrlEncodeUtils.test.ts +0 -202
  266. package/test/elements/layout/SplitItem.test.ts +0 -440
  267. package/test/elements/layout/SplitLayoutManager.test.ts +0 -1501
  268. package/test/elements/layout/SplitPanel.test.ts +0 -1109
  269. package/test/elements/mention-textarea/MentionTextArea.basic.test.ts +0 -114
  270. package/test/elements/mention-textarea/MentionTextArea.test.ts +0 -613
  271. package/test/elements/navigation/Navigation.test.ts +0 -120
  272. package/test/env.ts +0 -15
  273. package/test/events/EventTypes.test.ts +0 -363
  274. package/test/events/EventsTestHelpers.ts +0 -16
  275. package/test/helpers/TestUtils.ts +0 -243
  276. package/test/helpers/UiMock.ts +0 -185
  277. package/test/lib/Dom.test.ts +0 -231
  278. package/test/md/button/UiButton.test.ts +0 -347
  279. package/test/md/button/UiIconButton.test.ts +0 -155
  280. package/test/md/chip/UiChip.test.ts +0 -219
  281. package/test/md/collapse/UiCollapse.test.ts +0 -250
  282. package/test/md/collapse/flex-layout.test.ts +0 -105
  283. package/test/md/date-time/DateTime.test.ts +0 -348
  284. package/test/md/dialog/UiConfirmDialog.test.ts +0 -131
  285. package/test/md/dialog/UiDialog.test.ts +0 -759
  286. package/test/md/menu/Menu.test.ts +0 -855
  287. package/test/md/menu/MenuIntegration.test.ts +0 -426
  288. package/test/md/menu/MenuItem.test.ts +0 -652
  289. package/test/md/menu/SubMenu.test.ts +0 -410
  290. package/test/md/progress/UiCircularProgressElement.test.ts +0 -481
  291. package/test/md/progress/UiProgressElement.test.ts +0 -117
  292. package/test/md/progress/UiRangeElement.test.ts +0 -156
  293. package/test/md/select/Select.test.ts +0 -925
  294. package/test/plugins/takeScreenshotPlugin.js +0 -35
  295. package/test/setup.test.ts +0 -217
  296. package/test/setup.ts +0 -117
  297. package/test/tsconfig.json +0 -7
  298. package/web-dev-server.config.js +0 -21
  299. package/web-test-runner.config.js +0 -90
@@ -1,1109 +0,0 @@
1
- import { assert } from '@open-wc/testing'
2
- import sinon from 'sinon'
3
- import { SplitItem } from '../../../src/elements/layout/SplitItem.js'
4
- import { ITabCloseDetail, SplitLayout } from '../../../src/elements/layout/SplitLayout.js'
5
- import { SplitPanel } from '../../../src/elements/layout/SplitPanel.js'
6
- import {
7
- IPanelObject,
8
- LayoutType,
9
- PanelState,
10
- SplitCloseDirection,
11
- SplitDirection,
12
- SplitRegion,
13
- } from '../../../src/elements/layout/type.js'
14
-
15
- describe('layout', () => {
16
- describe('SplitPanel', () => {
17
- describe('new()', () => {
18
- let manager: SplitLayout
19
-
20
- beforeEach(() => {
21
- manager = new SplitLayout()
22
- })
23
-
24
- it('sets a random key', () => {
25
- const panel = new SplitPanel(manager, { layout: SplitDirection.horizontal })
26
- assert.isNotEmpty(panel.key)
27
- })
28
-
29
- it('sets the passed key', () => {
30
- const panel = new SplitPanel(manager, { layout: SplitDirection.horizontal, key: 'abc' })
31
- assert.equal(panel.key, 'abc')
32
- })
33
-
34
- it('sets the passed layout', () => {
35
- const panel = new SplitPanel(manager, { layout: SplitDirection.vertical })
36
- assert.equal(panel.layout, SplitDirection.vertical)
37
- })
38
-
39
- it('sets the default layout', () => {
40
- const panel = new SplitPanel(manager)
41
- assert.equal(panel.layout, SplitDirection.horizontal)
42
- })
43
-
44
- it('sets the passed selected', () => {
45
- const panel = new SplitPanel(manager, { layout: SplitDirection.vertical, selected: 'a' })
46
- assert.equal(panel.selected, 'a')
47
- })
48
-
49
- it('sets the default selected', () => {
50
- const panel = new SplitPanel(manager)
51
- assert.isUndefined(panel.selected)
52
- })
53
-
54
- it('sets the default state', () => {
55
- const panel = new SplitPanel(manager)
56
- assert.equal(panel.state, PanelState.idle)
57
- })
58
-
59
- it('sets copy of the items', () => {
60
- const items: IPanelObject[] = [
61
- {
62
- key: 'i1',
63
- type: LayoutType.item,
64
- },
65
- ]
66
- const panel = new SplitPanel(manager, { layout: SplitDirection.vertical, items })
67
- assert.deepEqual(panel.items, items, 'sets the value')
68
- items.splice(0, 1)
69
- assert.lengthOf(panel.items, 1, 'the array is a copy.')
70
- })
71
-
72
- it('sets default items', () => {
73
- const items: IPanelObject[] = [
74
- {
75
- key: 'i1',
76
- type: LayoutType.item,
77
- },
78
- ]
79
- const panel = new SplitPanel(manager, { layout: SplitDirection.vertical, items })
80
- panel.new({ layout: SplitDirection.vertical })
81
- assert.lengthOf(panel.items, 0, 'the array is empty')
82
- })
83
- })
84
-
85
- describe('toJSON()', () => {
86
- let manager: SplitLayout
87
-
88
- beforeEach(() => {
89
- manager = new SplitLayout()
90
- })
91
-
92
- it('serializes the layout', () => {
93
- const panel = new SplitPanel(manager, { layout: SplitDirection.vertical })
94
- const result = panel.toJSON()
95
- assert.equal(result.layout, SplitDirection.vertical)
96
- })
97
-
98
- it('serializes the key', () => {
99
- const panel = new SplitPanel(manager, { layout: SplitDirection.vertical, key: 'abc' })
100
- const result = panel.toJSON()
101
- assert.equal(result.key, 'abc')
102
- })
103
-
104
- it('serializes the items', () => {
105
- const items: IPanelObject[] = [
106
- {
107
- key: 'i1',
108
- type: LayoutType.item,
109
- },
110
- ]
111
- const panel = new SplitPanel(manager, { layout: SplitDirection.vertical, items })
112
- const result = panel.toJSON()
113
- assert.deepEqual(result.items, items)
114
- })
115
-
116
- it('serialized items are a copy', () => {
117
- const items: IPanelObject[] = [
118
- {
119
- key: 'i1',
120
- type: LayoutType.item,
121
- },
122
- ]
123
- const panel = new SplitPanel(manager, { layout: SplitDirection.vertical, items })
124
- const result = panel.toJSON()
125
- items[0].key = 'i2'
126
- assert.equal(result.items![0].key, 'i1')
127
- items.splice(0, 1)
128
- assert.lengthOf(result.items!, 1)
129
- })
130
-
131
- it('ignores items when empty', () => {
132
- const panel = new SplitPanel(manager, { layout: SplitDirection.vertical })
133
- const result = panel.toJSON()
134
- assert.isUndefined(result.items)
135
- })
136
-
137
- it('serializes the selected', () => {
138
- const panel = new SplitPanel(manager, { layout: SplitDirection.vertical, selected: 'abc' })
139
- const result = panel.toJSON()
140
- assert.equal(result.selected, 'abc')
141
- })
142
-
143
- it('serializes selected when not set', () => {
144
- const panel = new SplitPanel(manager, { layout: SplitDirection.vertical })
145
- const result = panel.toJSON()
146
- assert.isUndefined(result.selected)
147
- })
148
- })
149
-
150
- describe('getParent()', () => {
151
- let manager: SplitLayout
152
-
153
- beforeEach(() => {
154
- manager = new SplitLayout()
155
- })
156
-
157
- it('returns undefined when no parent', () => {
158
- const instance = new SplitPanel(manager)
159
- const result = instance.getParent()
160
- assert.isUndefined(result)
161
- })
162
-
163
- it('returns the parent panel', () => {
164
- const p1 = manager.addPanel()
165
- const p2 = p1.addPanel()
166
- const result = p2.getParent()
167
- assert.deepEqual(result, p1)
168
- })
169
- })
170
-
171
- describe('canDrop()', () => {
172
- let manager: SplitLayout
173
-
174
- beforeEach(() => {
175
- manager = new SplitLayout()
176
- })
177
-
178
- it('returns false when has no items', () => {
179
- const instance = new SplitPanel(manager)
180
- assert.isFalse(instance.canDrop())
181
- })
182
-
183
- it('returns true what has a panel', () => {
184
- const p1 = manager.addPanel()
185
- p1.addPanel()
186
- assert.isTrue(p1.canDrop())
187
- })
188
-
189
- it('returns true what has an item', () => {
190
- const p1 = manager.addPanel()
191
- p1.addItem({
192
- key: 'test-key',
193
- kind: 'test-kind',
194
- label: 'test-label',
195
- })
196
- assert.isTrue(p1.canDrop())
197
- })
198
- })
199
-
200
- describe('sortedItems()', () => {
201
- let manager: SplitLayout
202
- let panel: SplitPanel
203
- let items: SplitItem[]
204
-
205
- beforeEach(() => {
206
- manager = new SplitLayout()
207
- panel = manager.addPanel()
208
- const i1 = panel.addItem({
209
- key: 'i1',
210
- kind: '',
211
- label: '',
212
- })
213
- const i2 = panel.addItem({
214
- key: 'i2',
215
- kind: '',
216
- label: '',
217
- })
218
- const i3 = panel.addItem({
219
- key: 'i3',
220
- kind: '',
221
- label: '',
222
- })
223
- items = [i1, i2, i3]
224
- })
225
-
226
- it('returns items in order of adding', () => {
227
- const result = panel.sortedItems()
228
- assert.deepEqual(result, items)
229
- })
230
-
231
- it('sorts the items', () => {
232
- items[0].index = 1
233
- items[1].index = 0
234
- items[2].index = 2
235
- const result = panel.sortedItems()
236
- assert.deepEqual(result, [items[1], items[0], items[2]])
237
- })
238
-
239
- it('the returning array is a copy', () => {
240
- const result = panel.sortedItems()
241
- result.splice(0, 1)
242
- assert.lengthOf(panel.items, 3)
243
- })
244
- })
245
-
246
- describe('nextIndex()', () => {
247
- let manager: SplitLayout
248
- let panel: SplitPanel
249
-
250
- beforeEach(() => {
251
- manager = new SplitLayout()
252
- panel = manager.addPanel()
253
- })
254
-
255
- it('sets the index when no items', () => {
256
- const result = panel.nextIndex()
257
- assert.equal(result, 0)
258
- })
259
-
260
- it('sets the next available index', () => {
261
- panel.addItem({
262
- key: 'i1',
263
- kind: '',
264
- label: '',
265
- })
266
- const result = panel.nextIndex()
267
- assert.equal(result, 1)
268
- })
269
-
270
- it('sets the next available index with a gap', () => {
271
- const p1 = panel.addItem({
272
- key: 'i1',
273
- kind: '',
274
- label: '',
275
- })
276
- p1.index = 4
277
- const result = panel.nextIndex()
278
- assert.equal(result, 0)
279
- })
280
-
281
- it('returns the index after multiple items', () => {
282
- const i1 = panel.addItem({
283
- key: 'i1',
284
- kind: '',
285
- label: '',
286
- })
287
- i1.index = 0
288
- const i2 = panel.addItem({
289
- key: 'i2',
290
- kind: '',
291
- label: '',
292
- })
293
- i2.index = 1
294
- const i3 = panel.addItem({
295
- key: 'i3',
296
- kind: '',
297
- label: '',
298
- })
299
- i3.index = 2
300
- const result = panel.nextIndex()
301
- assert.equal(result, 3)
302
- })
303
-
304
- it('returns the index with a gap', () => {
305
- const i1 = panel.addItem({
306
- key: 'i1',
307
- kind: '',
308
- label: '',
309
- })
310
- i1.index = 0
311
- const i2 = panel.addItem({
312
- key: 'i2',
313
- kind: '',
314
- label: '',
315
- })
316
- i2.index = 2
317
- const i3 = panel.addItem({
318
- key: 'i3',
319
- kind: '',
320
- label: '',
321
- })
322
- i3.index = 3
323
- const result = panel.nextIndex()
324
- assert.equal(result, 1)
325
- })
326
- })
327
-
328
- describe('hasItem()', () => {
329
- let manager: SplitLayout
330
- let panel: SplitPanel
331
-
332
- beforeEach(() => {
333
- manager = new SplitLayout()
334
- panel = manager.addPanel()
335
- })
336
-
337
- it('returns true when the panel has an item', () => {
338
- const i1 = panel.addItem({
339
- key: 'i1',
340
- kind: '',
341
- label: '',
342
- })
343
- assert.isTrue(panel.hasItem(i1.key))
344
- })
345
-
346
- it('returns false when the panel has no such item', () => {
347
- panel.addItem({
348
- key: 'i1',
349
- kind: '',
350
- label: '',
351
- })
352
- assert.isFalse(panel.hasItem('other'))
353
- })
354
- })
355
-
356
- describe('addItem()', () => {
357
- describe('center region', () => {
358
- let manager: SplitLayout
359
- let panel: SplitPanel
360
-
361
- beforeEach(() => {
362
- manager = new SplitLayout()
363
- panel = manager.addPanel()
364
- })
365
-
366
- it('does nothing when adding an existing item', () => {
367
- const i1 = panel.addItem({
368
- key: 'i1',
369
- kind: '',
370
- label: '',
371
- })
372
- const spy = sinon.spy(manager, 'notifyChange')
373
- panel.addItem(i1)
374
- assert.isFalse(spy.called)
375
- })
376
-
377
- it('adds an item to to the items', () => {
378
- panel.addItem({
379
- key: 'i1',
380
- kind: '',
381
- label: '',
382
- })
383
- assert.lengthOf(panel.items, 1, 'panel has a single item')
384
- assert.equal(panel.items[0].key, 'i1', 'the item has the key')
385
- assert.equal(panel.items[0].type, LayoutType.item, 'the item has the type')
386
- })
387
-
388
- it("adds an item to manager's definitions", () => {
389
- panel.addItem({
390
- key: 'i1',
391
- kind: '',
392
- label: '',
393
- })
394
- const item = manager.definitions.get('i1')!
395
- assert.equal(item.type, LayoutType.item, 'the definition has the type')
396
- const value = item.value as SplitItem
397
- assert.equal(value.key, 'i1', 'the definition has the key')
398
- })
399
-
400
- it('notifies about the change.', () => {
401
- const spy = sinon.spy(manager, 'notifyChange')
402
- panel.addItem({
403
- key: 'i1',
404
- kind: '',
405
- label: '',
406
- })
407
- assert.isTrue(spy.calledOnce)
408
- })
409
-
410
- it('calls the updateView()', () => {
411
- const spy = sinon.spy(panel, 'updateView')
412
- panel.addItem({
413
- key: 'i1',
414
- kind: '',
415
- label: '',
416
- })
417
- assert.isTrue(spy.calledOnce)
418
- })
419
-
420
- it('sets a default next index', () => {
421
- const i1 = panel.addItem({
422
- key: 'i1',
423
- kind: '',
424
- label: '',
425
- })
426
- const i2 = panel.addItem({
427
- key: 'i2',
428
- kind: '',
429
- label: '',
430
- })
431
- assert.equal(i1.index, 0)
432
- assert.equal(i2.index, 1)
433
- })
434
-
435
- it("respects the item's index.", () => {
436
- const i1 = panel.addItem({
437
- key: 'i1',
438
- kind: '',
439
- label: '',
440
- index: 1,
441
- })
442
- assert.equal(i1.index, 1)
443
- })
444
-
445
- it("respects the option's index.", () => {
446
- const i1 = panel.addItem(
447
- {
448
- key: 'i1',
449
- kind: '',
450
- label: '',
451
- },
452
- { index: 1 }
453
- )
454
- assert.equal(i1.index, 1)
455
- })
456
-
457
- it("respects the option's index has priority", () => {
458
- const i1 = panel.addItem(
459
- {
460
- key: 'i1',
461
- kind: '',
462
- label: '',
463
- index: 1,
464
- },
465
- { index: 2 }
466
- )
467
- assert.equal(i1.index, 2)
468
- })
469
-
470
- it('sets the item selected', () => {
471
- const i1 = panel.addItem({
472
- key: 'i1',
473
- kind: '',
474
- label: '',
475
- })
476
- assert.equal(panel.selected, i1.key)
477
- })
478
- })
479
-
480
- describe('east region', () => {
481
- let manager: SplitLayout
482
- let panel: SplitPanel
483
-
484
- beforeEach(() => {
485
- manager = new SplitLayout()
486
- panel = manager.addPanel({ layout: SplitDirection.vertical })
487
-
488
- panel.addItem({
489
- key: 'pre',
490
- kind: '',
491
- label: '',
492
- })
493
- })
494
-
495
- it('splits the layout horizontally', () => {
496
- panel.addItem(
497
- {
498
- key: 'i1',
499
- kind: '',
500
- label: '',
501
- },
502
- { region: SplitRegion.east }
503
- )
504
- assert.equal(panel.layout, SplitDirection.horizontal)
505
- })
506
-
507
- it('adds 2 split panels as items', () => {
508
- panel.addItem(
509
- {
510
- key: 'i1',
511
- kind: '',
512
- label: '',
513
- },
514
- { region: SplitRegion.east }
515
- )
516
- const [p1, p2] = panel.items
517
- assert.ok(p1, 'has the first panel')
518
- assert.ok(p2, 'has the second panel')
519
- assert.equal(p1.type, LayoutType.panel, '#1 has the panel type')
520
- assert.equal(p2.type, LayoutType.panel, '#2 has the panel type')
521
- })
522
-
523
- it('moves the existing items to the first panel', () => {
524
- panel.addItem(
525
- {
526
- key: 'i1',
527
- kind: '',
528
- label: '',
529
- },
530
- { region: SplitRegion.east }
531
- )
532
- const [p1] = panel.items
533
- const def = manager.findPanel(p1.key)!
534
- assert.lengthOf(def.items, 1, 'the panel has an item')
535
- assert.equal(def.items[0].key, 'pre', 'the panel has the moved item')
536
- })
537
-
538
- it('adds the new item to the other panel', () => {
539
- const i1 = panel.addItem(
540
- {
541
- key: 'i1',
542
- kind: '',
543
- label: '',
544
- },
545
- { region: SplitRegion.east }
546
- )
547
- const [, p2] = panel.items
548
- const def = manager.findPanel(p2.key)!
549
- assert.lengthOf(def.items, 1, 'the panel has an item')
550
- assert.equal(def.items[0].key, i1.key, 'the panel has the created item')
551
- })
552
-
553
- it('notifies about the change', () => {
554
- const spy = sinon.spy(manager, 'notifyChange')
555
- panel.addItem(
556
- {
557
- key: 'i1',
558
- kind: '',
559
- label: '',
560
- },
561
- { region: SplitRegion.east }
562
- )
563
- assert.isTrue(spy.calledOnce)
564
- })
565
- })
566
-
567
- describe('west region', () => {
568
- let manager: SplitLayout
569
- let panel: SplitPanel
570
-
571
- beforeEach(() => {
572
- manager = new SplitLayout()
573
- panel = manager.addPanel({ layout: SplitDirection.vertical })
574
-
575
- panel.addItem({
576
- key: 'pre',
577
- kind: '',
578
- label: '',
579
- })
580
- })
581
-
582
- it('splits the layout horizontally', () => {
583
- panel.addItem(
584
- {
585
- key: 'i1',
586
- kind: '',
587
- label: '',
588
- },
589
- { region: SplitRegion.west }
590
- )
591
- assert.equal(panel.layout, SplitDirection.horizontal)
592
- })
593
-
594
- it('adds 2 split panels as items', () => {
595
- panel.addItem(
596
- {
597
- key: 'i1',
598
- kind: '',
599
- label: '',
600
- },
601
- { region: SplitRegion.west }
602
- )
603
- const [p1, p2] = panel.items
604
- assert.ok(p1, 'has the first panel')
605
- assert.ok(p2, 'has the second panel')
606
- assert.equal(p1.type, LayoutType.panel, '#1 has the panel type')
607
- assert.equal(p2.type, LayoutType.panel, '#2 has the panel type')
608
- })
609
-
610
- it('moves the existing items to the second panel', () => {
611
- panel.addItem(
612
- {
613
- key: 'i1',
614
- kind: '',
615
- label: '',
616
- },
617
- { region: SplitRegion.west }
618
- )
619
- const [, p2] = panel.items
620
- const def = manager.findPanel(p2.key)!
621
- assert.lengthOf(def.items, 1, 'the panel has an item')
622
- assert.equal(def.items[0].key, 'pre', 'the panel has the moved item')
623
- })
624
-
625
- it('adds the new item to the other panel', () => {
626
- const i1 = panel.addItem(
627
- {
628
- key: 'i1',
629
- kind: '',
630
- label: '',
631
- },
632
- { region: SplitRegion.west }
633
- )
634
- const [p1] = panel.items
635
- const def = manager.findPanel(p1.key)!
636
- assert.lengthOf(def.items, 1, 'the panel has an item')
637
- assert.equal(def.items[0].key, i1.key, 'the panel has the created item')
638
- })
639
-
640
- it('notifies about the change', () => {
641
- const spy = sinon.spy(manager, 'notifyChange')
642
- panel.addItem(
643
- {
644
- key: 'i1',
645
- kind: '',
646
- label: '',
647
- },
648
- { region: SplitRegion.west }
649
- )
650
- assert.isTrue(spy.calledOnce)
651
- })
652
- })
653
-
654
- describe('south region', () => {
655
- let manager: SplitLayout
656
- let panel: SplitPanel
657
-
658
- beforeEach(() => {
659
- manager = new SplitLayout()
660
- panel = manager.addPanel({ layout: SplitDirection.horizontal })
661
-
662
- panel.addItem({
663
- key: 'pre',
664
- kind: '',
665
- label: '',
666
- })
667
- })
668
-
669
- it('splits the layout vertical', () => {
670
- panel.addItem(
671
- {
672
- key: 'i1',
673
- kind: '',
674
- label: '',
675
- },
676
- { region: SplitRegion.south }
677
- )
678
- assert.equal(panel.layout, SplitDirection.vertical)
679
- })
680
-
681
- it('adds 2 split panels as items', () => {
682
- panel.addItem(
683
- {
684
- key: 'i1',
685
- kind: '',
686
- label: '',
687
- },
688
- { region: SplitRegion.south }
689
- )
690
- const [p1, p2] = panel.items
691
- assert.ok(p1, 'has the first panel')
692
- assert.ok(p2, 'has the second panel')
693
- assert.equal(p1.type, LayoutType.panel, '#1 has the panel type')
694
- assert.equal(p2.type, LayoutType.panel, '#2 has the panel type')
695
- })
696
-
697
- it('moves the existing items to the first panel', () => {
698
- panel.addItem(
699
- {
700
- key: 'i1',
701
- kind: '',
702
- label: '',
703
- },
704
- { region: SplitRegion.south }
705
- )
706
- const [p1] = panel.items
707
- const def = manager.findPanel(p1.key)!
708
- assert.lengthOf(def.items, 1, 'the panel has an item')
709
- assert.equal(def.items[0].key, 'pre', 'the panel has the moved item')
710
- })
711
-
712
- it('adds the new item to the other panel', () => {
713
- const i1 = panel.addItem(
714
- {
715
- key: 'i1',
716
- kind: '',
717
- label: '',
718
- },
719
- { region: SplitRegion.south }
720
- )
721
- const [, p2] = panel.items
722
- const def = manager.findPanel(p2.key)!
723
- assert.lengthOf(def.items, 1, 'the panel has an item')
724
- assert.equal(def.items[0].key, i1.key, 'the panel has the created item')
725
- })
726
-
727
- it('notifies about the change', () => {
728
- const spy = sinon.spy(manager, 'notifyChange')
729
- panel.addItem(
730
- {
731
- key: 'i1',
732
- kind: '',
733
- label: '',
734
- },
735
- { region: SplitRegion.south }
736
- )
737
- assert.isTrue(spy.calledOnce)
738
- })
739
- })
740
-
741
- describe('north region', () => {
742
- let manager: SplitLayout
743
- let panel: SplitPanel
744
-
745
- beforeEach(() => {
746
- manager = new SplitLayout()
747
- panel = manager.addPanel({ layout: SplitDirection.horizontal })
748
-
749
- panel.addItem({
750
- key: 'pre',
751
- kind: '',
752
- label: '',
753
- })
754
- })
755
-
756
- it('splits the layout vertical', () => {
757
- panel.addItem(
758
- {
759
- key: 'i1',
760
- kind: '',
761
- label: '',
762
- },
763
- { region: SplitRegion.north }
764
- )
765
- assert.equal(panel.layout, SplitDirection.vertical)
766
- })
767
-
768
- it('adds 2 split panels as items', () => {
769
- panel.addItem(
770
- {
771
- key: 'i1',
772
- kind: '',
773
- label: '',
774
- },
775
- { region: SplitRegion.north }
776
- )
777
- const [p1, p2] = panel.items
778
- assert.ok(p1, 'has the first panel')
779
- assert.ok(p2, 'has the second panel')
780
- assert.equal(p1.type, LayoutType.panel, '#1 has the panel type')
781
- assert.equal(p2.type, LayoutType.panel, '#2 has the panel type')
782
- })
783
-
784
- it('moves the existing items to the other panel', () => {
785
- panel.addItem(
786
- {
787
- key: 'i1',
788
- kind: '',
789
- label: '',
790
- },
791
- { region: SplitRegion.north }
792
- )
793
- const [, p2] = panel.items
794
- const def = manager.findPanel(p2.key)!
795
- assert.lengthOf(def.items, 1, 'the panel has an item')
796
- assert.equal(def.items[0].key, 'pre', 'the panel has the moved item')
797
- })
798
-
799
- it('adds the new item to the first panel', () => {
800
- const i1 = panel.addItem(
801
- {
802
- key: 'i1',
803
- kind: '',
804
- label: '',
805
- },
806
- { region: SplitRegion.north }
807
- )
808
- const [p1] = panel.items
809
- const def = manager.findPanel(p1.key)!
810
- assert.lengthOf(def.items, 1, 'the panel has an item')
811
- assert.equal(def.items[0].key, i1.key, 'the panel has the created item')
812
- })
813
-
814
- it('notifies about the change', () => {
815
- const spy = sinon.spy(manager, 'notifyChange')
816
- panel.addItem(
817
- {
818
- key: 'i1',
819
- kind: '',
820
- label: '',
821
- },
822
- { region: SplitRegion.north }
823
- )
824
- assert.isTrue(spy.calledOnce)
825
- })
826
- })
827
- })
828
-
829
- describe('removeItem()', () => {
830
- let manager: SplitLayout
831
- let panel: SplitPanel
832
-
833
- beforeEach(() => {
834
- manager = new SplitLayout()
835
- panel = manager.addPanel()
836
- })
837
-
838
- it('removes an item from the panel and keeps the panel as the first from root', () => {
839
- const i1 = panel.addItem({
840
- key: 'i1',
841
- kind: '',
842
- label: '',
843
- })
844
- panel.removeItem(i1.key)
845
- assert.isFalse(panel.hasItem(i1.key), 'the panel has no item')
846
- assert.ok(manager.definitions.get(panel.key), 'keeps the panel')
847
- })
848
-
849
- it('removes an item from the panel and keeps the panel with more items', () => {
850
- const p1 = panel.addPanel()
851
- const i1 = p1.addItem({
852
- key: 'i1',
853
- kind: '',
854
- label: '',
855
- })
856
- p1.addItem({
857
- key: 'i2',
858
- kind: '',
859
- label: '',
860
- })
861
- p1.removeItem(i1.key)
862
- assert.isFalse(p1.hasItem(i1.key), 'the panel has no item')
863
- assert.ok(manager.definitions.get(p1.key), 'keeps the panel')
864
- })
865
-
866
- it('removes an item and the panel when empty', () => {
867
- const p1 = panel.addPanel()
868
- const i1 = p1.addItem({
869
- key: 'i1',
870
- kind: '',
871
- label: '',
872
- })
873
- p1.removeItem(i1.key)
874
- assert.isFalse(p1.hasItem(i1.key), 'the panel has no item')
875
- assert.isUndefined(manager.definitions.get(p1.key), 'removes the panel')
876
- })
877
-
878
- it('removes item definition', () => {
879
- const i1 = panel.addItem({
880
- key: 'i1',
881
- kind: '',
882
- label: '',
883
- })
884
- panel.removeItem(i1.key)
885
- assert.isUndefined(manager.definitions.get(i1.key), 'removes the item')
886
- })
887
-
888
- it('notifies tab removed when the panel has no more parents', () => {
889
- const i1 = panel.addItem({
890
- key: 'i1',
891
- kind: '',
892
- label: '',
893
- })
894
- const spy = sinon.spy()
895
- manager.addEventListener('closetab', spy)
896
- panel.removeItem(i1.key)
897
- assert.isTrue(spy.calledOnce, 'removes the item')
898
- const event = spy.args[0][0] as CustomEvent<ITabCloseDetail>
899
- assert.equal(event.detail.tab, i1.key, 'has the tab key')
900
- assert.equal(event.detail.panel, panel.key, 'has the panel key')
901
- })
902
-
903
- it('notifies tab removed when the panel has more items', () => {
904
- const p1 = panel.addPanel()
905
- const i1 = p1.addItem({
906
- key: 'i1',
907
- kind: '',
908
- label: '',
909
- })
910
- p1.addItem({
911
- key: 'i2',
912
- kind: '',
913
- label: '',
914
- })
915
- const spy = sinon.spy()
916
- manager.addEventListener('closetab', spy)
917
- p1.removeItem(i1.key)
918
- assert.isTrue(spy.calledOnce, 'removes the item')
919
- const event = spy.args[0][0] as CustomEvent<ITabCloseDetail>
920
- assert.equal(event.detail.tab, i1.key, 'has the tab key')
921
- assert.equal(event.detail.panel, p1.key, 'has the panel key')
922
- })
923
-
924
- it('notifies tab removed when removing the panel', () => {
925
- const p1 = panel.addPanel()
926
- const i1 = p1.addItem({
927
- key: 'i1',
928
- kind: '',
929
- label: '',
930
- })
931
- const spy = sinon.spy()
932
- manager.addEventListener('closetab', spy)
933
- p1.removeItem(i1.key)
934
- assert.isTrue(spy.calledOnce, 'removes the item')
935
- const event = spy.args[0][0] as CustomEvent<ITabCloseDetail>
936
- assert.equal(event.detail.tab, i1.key, 'has the tab key')
937
- assert.equal(event.detail.panel, p1.key, 'has the panel key')
938
- })
939
-
940
- it('moves the selection to the next item', () => {
941
- const p1 = panel.addPanel()
942
- const i1 = p1.addItem({
943
- key: 'i1',
944
- kind: '',
945
- label: '',
946
- })
947
- const i2 = p1.addItem({
948
- key: 'i2',
949
- kind: '',
950
- label: '',
951
- })
952
- p1.selected = i1.key
953
- p1.removeItem(i1.key)
954
- assert.equal(p1.selected, i2.key)
955
- })
956
-
957
- it('moves the selection to the previous item', () => {
958
- const p1 = panel.addPanel()
959
- const i1 = p1.addItem({
960
- key: 'i1',
961
- kind: '',
962
- label: '',
963
- })
964
- const i2 = p1.addItem({
965
- key: 'i2',
966
- kind: '',
967
- label: '',
968
- })
969
- p1.selected = i2.key
970
- p1.removeItem(i2.key)
971
- assert.equal(p1.selected, i1.key)
972
- })
973
-
974
- it('moves the selection to the first item', () => {
975
- const p1 = panel.addPanel()
976
- const i1 = p1.addItem({
977
- key: 'i1',
978
- kind: '',
979
- label: '',
980
- index: 2,
981
- })
982
- const i2 = p1.addItem({
983
- key: 'i2',
984
- kind: '',
985
- label: '',
986
- index: 4,
987
- })
988
- p1.selected = i2.key
989
- p1.removeItem(i2.key)
990
- assert.equal(p1.selected, i1.key)
991
- })
992
- })
993
-
994
- describe('removeRelative()', () => {
995
- let manager: SplitLayout
996
- let panel: SplitPanel
997
- let items: SplitItem[]
998
-
999
- beforeEach(() => {
1000
- manager = new SplitLayout()
1001
- panel = manager.addPanel()
1002
- items = new Array(5).fill('').map((_, index) => {
1003
- const item = panel.addItem({
1004
- key: `i${index}`,
1005
- kind: '',
1006
- label: `i${index}`,
1007
- })
1008
- return item
1009
- })
1010
- })
1011
-
1012
- it('removes items to the left', () => {
1013
- panel.removeRelative(items[2].key, SplitCloseDirection.left)
1014
- assert.lengthOf(panel.items, 3, 'has 3 remaining items')
1015
- assert.equal(panel.items[0].key, items[2].key, 'leaves the item')
1016
- assert.equal(panel.items[1].key, items[3].key, 'has the right item #1')
1017
- assert.equal(panel.items[2].key, items[4].key, 'has the right item #2')
1018
- })
1019
-
1020
- it('removes items to the right', () => {
1021
- panel.removeRelative(items[2].key, SplitCloseDirection.right)
1022
- assert.lengthOf(panel.items, 3, 'has 3 remaining items')
1023
- assert.equal(panel.items[0].key, items[0].key, 'has the left item #1')
1024
- assert.equal(panel.items[1].key, items[1].key, 'has the left item #2')
1025
- assert.equal(panel.items[2].key, items[2].key, 'leaves the item')
1026
- })
1027
-
1028
- it('removes items on the both sides', () => {
1029
- panel.removeRelative(items[2].key, SplitCloseDirection.both)
1030
- assert.lengthOf(panel.items, 1, 'has single item')
1031
- assert.equal(panel.items[0].key, items[2].key, 'leaves the item')
1032
- })
1033
-
1034
- it('does not remove items on the left when selecting first item', () => {
1035
- panel.removeRelative(items[4].key, SplitCloseDirection.right)
1036
- assert.lengthOf(panel.items, 5, 'has all items')
1037
- })
1038
-
1039
- it('does not remove items on the right when selecting first item', () => {
1040
- panel.removeRelative(items[0].key, SplitCloseDirection.left)
1041
- assert.lengthOf(panel.items, 5, 'has all items')
1042
- })
1043
-
1044
- it('removes definitions for removed items', () => {
1045
- panel.removeRelative(items[1].key, SplitCloseDirection.both)
1046
- assert.isUndefined(manager.definitions.get(items[0].key), 'has no item on the left')
1047
- assert.isUndefined(manager.definitions.get(items[2].key), 'has no item on the right')
1048
- assert.ok(manager.definitions.get(items[1].key), 'has the item')
1049
- })
1050
-
1051
- it('notifies tab close', () => {
1052
- const spy = sinon.spy()
1053
- manager.addEventListener('closetab', spy)
1054
- panel.removeRelative(items[1].key, SplitCloseDirection.both)
1055
- assert.equal(spy.callCount, 4, 'dispatches for each removed tab')
1056
- })
1057
-
1058
- it('notifies change once', () => {
1059
- const spy = sinon.spy(manager, 'notifyChange')
1060
- panel.removeRelative(items[1].key, SplitCloseDirection.both)
1061
- assert.equal(spy.callCount, 1, 'calls the change only once')
1062
- })
1063
-
1064
- it('updates the view once', () => {
1065
- const spy = sinon.spy(manager, 'updateView')
1066
- panel.removeRelative(items[1].key, SplitCloseDirection.both)
1067
- assert.equal(spy.callCount, 1, 'calls the change only once')
1068
- })
1069
- })
1070
-
1071
- describe('removePanel()', () => {
1072
- let manager: SplitLayout
1073
- let panel: SplitPanel
1074
-
1075
- beforeEach(() => {
1076
- manager = new SplitLayout()
1077
- panel = manager.addPanel()
1078
- })
1079
-
1080
- it('removes a panel from a parent', () => {
1081
- const p1 = panel.addPanel()
1082
- panel.removePanel(p1.key)
1083
-
1084
- assert.isFalse(panel.hasItem(p1.key))
1085
- })
1086
-
1087
- it("removes panel's definition", () => {
1088
- const p1 = panel.addPanel()
1089
- panel.removePanel(p1.key)
1090
-
1091
- assert.isUndefined(manager.definitions.get(p1.key))
1092
- })
1093
-
1094
- it('removes items from the panel', () => {
1095
- const p1 = panel.addPanel()
1096
- const p2 = p1.addPanel()
1097
- const i1 = p2.addItem({
1098
- key: 'i1',
1099
- kind: '',
1100
- label: '',
1101
- })
1102
- panel.removePanel(p1.key)
1103
-
1104
- assert.isUndefined(manager.definitions.get(p2.key), 'child panel definition is removed')
1105
- assert.isUndefined(manager.definitions.get(i1.key), 'child item definition is removed')
1106
- })
1107
- })
1108
- })
1109
- })