@gogocat/data-bind 1.11.0 → 2.0.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 (274) hide show
  1. package/.editorconfig +14 -14
  2. package/.vscode/launch.json +12 -12
  3. package/CONFIGURATION.md +294 -0
  4. package/REACTIVE_MODE.md +553 -0
  5. package/README.md +266 -829
  6. package/babel.config.json +30 -0
  7. package/dist/js/_escape.d.ts +14 -0
  8. package/dist/js/_escape.d.ts.map +1 -0
  9. package/dist/js/applyBinding.d.ts +11 -0
  10. package/dist/js/applyBinding.d.ts.map +1 -0
  11. package/dist/js/attrBinding.d.ts +12 -0
  12. package/dist/js/attrBinding.d.ts.map +1 -0
  13. package/dist/js/binder.d.ts +67 -0
  14. package/dist/js/binder.d.ts.map +1 -0
  15. package/dist/js/changeBinding.d.ts +19 -0
  16. package/dist/js/changeBinding.d.ts.map +1 -0
  17. package/dist/js/commentWrapper.d.ts +39 -0
  18. package/dist/js/commentWrapper.d.ts.map +1 -0
  19. package/dist/js/config.d.ts +55 -0
  20. package/dist/js/config.d.ts.map +1 -0
  21. package/dist/js/createBindingOption.d.ts +32 -0
  22. package/dist/js/createBindingOption.d.ts.map +1 -0
  23. package/dist/js/createEventBinding.d.ts +10 -0
  24. package/dist/js/createEventBinding.d.ts.map +1 -0
  25. package/dist/js/cssBinding.d.ts +15 -0
  26. package/dist/js/cssBinding.d.ts.map +1 -0
  27. package/dist/js/dataBind.js +2772 -2519
  28. package/dist/js/dataBind.min.js +8 -1
  29. package/dist/js/dataBind.min.js.map +1 -1
  30. package/dist/js/domWalker.d.ts +9 -0
  31. package/dist/js/domWalker.d.ts.map +1 -0
  32. package/dist/js/forOfBinding.d.ts +12 -0
  33. package/dist/js/forOfBinding.d.ts.map +1 -0
  34. package/dist/js/hoverBinding.d.ts +13 -0
  35. package/dist/js/hoverBinding.d.ts.map +1 -0
  36. package/dist/js/ifBinding.d.ts +12 -0
  37. package/dist/js/ifBinding.d.ts.map +1 -0
  38. package/dist/js/index.d.ts +10 -0
  39. package/dist/js/index.d.ts.map +1 -0
  40. package/dist/js/modelBinding.d.ts +12 -0
  41. package/dist/js/modelBinding.d.ts.map +1 -0
  42. package/dist/js/postProcess.d.ts +3 -0
  43. package/dist/js/postProcess.d.ts.map +1 -0
  44. package/dist/js/pubSub.d.ts +11 -0
  45. package/dist/js/pubSub.d.ts.map +1 -0
  46. package/dist/js/reactiveProxy.d.ts +28 -0
  47. package/dist/js/reactiveProxy.d.ts.map +1 -0
  48. package/dist/js/renderForOfBinding.d.ts +8 -0
  49. package/dist/js/renderForOfBinding.d.ts.map +1 -0
  50. package/dist/js/renderIfBinding.d.ts +22 -0
  51. package/dist/js/renderIfBinding.d.ts.map +1 -0
  52. package/dist/js/renderIteration.d.ts +16 -0
  53. package/dist/js/renderIteration.d.ts.map +1 -0
  54. package/dist/js/renderTemplate.d.ts +14 -0
  55. package/dist/js/renderTemplate.d.ts.map +1 -0
  56. package/dist/js/renderTemplatesBinding.d.ts +19 -0
  57. package/dist/js/renderTemplatesBinding.d.ts.map +1 -0
  58. package/dist/js/showBinding.d.ts +13 -0
  59. package/dist/js/showBinding.d.ts.map +1 -0
  60. package/dist/js/switchBinding.d.ts +13 -0
  61. package/dist/js/switchBinding.d.ts.map +1 -0
  62. package/dist/js/textBinding.d.ts +13 -0
  63. package/dist/js/textBinding.d.ts.map +1 -0
  64. package/dist/js/types/_escape.d.ts +14 -0
  65. package/dist/js/types/_escape.d.ts.map +1 -0
  66. package/dist/js/types/applyBinding.d.ts +11 -0
  67. package/dist/js/types/applyBinding.d.ts.map +1 -0
  68. package/dist/js/types/attrBinding.d.ts +12 -0
  69. package/dist/js/types/attrBinding.d.ts.map +1 -0
  70. package/dist/js/types/binder.d.ts +67 -0
  71. package/dist/js/types/binder.d.ts.map +1 -0
  72. package/dist/js/types/changeBinding.d.ts +19 -0
  73. package/dist/js/types/changeBinding.d.ts.map +1 -0
  74. package/dist/js/types/commentWrapper.d.ts +39 -0
  75. package/dist/js/types/commentWrapper.d.ts.map +1 -0
  76. package/dist/js/types/config.d.ts +55 -0
  77. package/dist/js/types/config.d.ts.map +1 -0
  78. package/dist/js/types/createBindingOption.d.ts +32 -0
  79. package/dist/js/types/createBindingOption.d.ts.map +1 -0
  80. package/dist/js/types/createEventBinding.d.ts +10 -0
  81. package/dist/js/types/createEventBinding.d.ts.map +1 -0
  82. package/dist/js/types/cssBinding.d.ts +15 -0
  83. package/dist/js/types/cssBinding.d.ts.map +1 -0
  84. package/dist/js/types/domWalker.d.ts +9 -0
  85. package/dist/js/types/domWalker.d.ts.map +1 -0
  86. package/dist/js/types/forOfBinding.d.ts +12 -0
  87. package/dist/js/types/forOfBinding.d.ts.map +1 -0
  88. package/dist/js/types/hoverBinding.d.ts +13 -0
  89. package/dist/js/types/hoverBinding.d.ts.map +1 -0
  90. package/dist/js/types/ifBinding.d.ts +12 -0
  91. package/dist/js/types/ifBinding.d.ts.map +1 -0
  92. package/dist/js/types/index.d.ts +10 -0
  93. package/dist/js/types/index.d.ts.map +1 -0
  94. package/dist/js/types/modelBinding.d.ts +12 -0
  95. package/dist/js/types/modelBinding.d.ts.map +1 -0
  96. package/dist/js/types/postProcess.d.ts +3 -0
  97. package/dist/js/types/postProcess.d.ts.map +1 -0
  98. package/dist/js/types/pubSub.d.ts +11 -0
  99. package/dist/js/types/pubSub.d.ts.map +1 -0
  100. package/dist/js/types/reactiveProxy.d.ts +28 -0
  101. package/dist/js/types/reactiveProxy.d.ts.map +1 -0
  102. package/dist/js/types/renderForOfBinding.d.ts +8 -0
  103. package/dist/js/types/renderForOfBinding.d.ts.map +1 -0
  104. package/dist/js/types/renderIfBinding.d.ts +22 -0
  105. package/dist/js/types/renderIfBinding.d.ts.map +1 -0
  106. package/dist/js/types/renderIteration.d.ts +16 -0
  107. package/dist/js/types/renderIteration.d.ts.map +1 -0
  108. package/dist/js/types/renderTemplate.d.ts +14 -0
  109. package/dist/js/types/renderTemplate.d.ts.map +1 -0
  110. package/dist/js/types/renderTemplatesBinding.d.ts +19 -0
  111. package/dist/js/types/renderTemplatesBinding.d.ts.map +1 -0
  112. package/dist/js/types/showBinding.d.ts +13 -0
  113. package/dist/js/types/showBinding.d.ts.map +1 -0
  114. package/dist/js/types/switchBinding.d.ts +13 -0
  115. package/dist/js/types/switchBinding.d.ts.map +1 -0
  116. package/dist/js/types/textBinding.d.ts +13 -0
  117. package/dist/js/types/textBinding.d.ts.map +1 -0
  118. package/dist/js/types/types.d.ts +111 -0
  119. package/dist/js/types/types.d.ts.map +1 -0
  120. package/dist/js/types/util.d.ts +119 -0
  121. package/dist/js/types/util.d.ts.map +1 -0
  122. package/dist/js/types.d.ts +111 -0
  123. package/dist/js/types.d.ts.map +1 -0
  124. package/dist/js/util.d.ts +119 -0
  125. package/dist/js/util.d.ts.map +1 -0
  126. package/eslint.config.js +124 -0
  127. package/examples/DBMONSTER_COMPARISON.md +123 -0
  128. package/examples/afterRenderDemo.html +119 -0
  129. package/examples/bootstrap/css/animate.css +1579 -1579
  130. package/examples/bootstrap/css/bootstrap.min.css +6 -6
  131. package/examples/bootstrap/css/homeservices.css +378 -390
  132. package/examples/bootstrap/css/open-iconic.css +511 -511
  133. package/examples/bootstrap/fonts/open-iconic.svg +543 -543
  134. package/examples/bootstrap/js/compMessageDialog.js +20 -19
  135. package/examples/bootstrap/js/compSearchBar.js +12 -19
  136. package/examples/bootstrap/js/compSearchResults.js +50 -46
  137. package/examples/bootstrap/js/featureAdsResult.json +65 -65
  138. package/examples/bootstrap/js/searchResult.json +57 -57
  139. package/examples/bootstrap.html +343 -332
  140. package/examples/css/baseTodo.css +141 -141
  141. package/examples/css/dbMonsterStyles.css +27 -27
  142. package/examples/css/indexTodo.css +374 -374
  143. package/examples/dbmonsterForOfReactive.html +40 -0
  144. package/examples/dbmonsterReact.html +19 -0
  145. package/examples/forOfBindingSimpleDebug.html +45 -0
  146. package/examples/form.html +20 -4
  147. package/examples/globalConfig.html +131 -0
  148. package/examples/js/afterRenderDemo.js +190 -0
  149. package/examples/js/appTodo.js +46 -46
  150. package/examples/js/attrBindingDemo.js +2 -2
  151. package/examples/js/dbMonApp.js +24 -26
  152. package/examples/js/dbMonAppReact.jsx +79 -0
  153. package/examples/js/dbMonAppReactive.js +28 -0
  154. package/examples/js/fiberDemo.js +4 -4
  155. package/examples/js/filtersDemo.js +8 -8
  156. package/examples/js/forOfDemo.js +7 -9
  157. package/examples/js/forOfDemoComplex.js +44 -17
  158. package/examples/js/form.js +44 -12
  159. package/examples/js/globalConfig.js +117 -0
  160. package/examples/js/ifBindingDemo.js +16 -16
  161. package/examples/js/reactiveDemo.js +119 -0
  162. package/examples/js/switchBindingDemo.js +8 -8
  163. package/examples/react-dbmonster/dist/bundle.js +43 -0
  164. package/examples/react-dbmonster/package-lock.json +537 -0
  165. package/examples/react-dbmonster/package.json +16 -0
  166. package/examples/react-dbmonster/src/index.jsx +80 -0
  167. package/examples/reactiveDemo.html +127 -0
  168. package/examples/refreshRateTest.html +75 -75
  169. package/index.html +841 -0
  170. package/package.json +31 -34
  171. package/rollup.config.js +79 -36
  172. package/src/{_escape.js → _escape.ts} +19 -17
  173. package/src/applyBinding.ts +179 -0
  174. package/src/{attrBinding.js → attrBinding.ts} +14 -13
  175. package/src/binder.ts +289 -0
  176. package/src/changeBinding.ts +93 -0
  177. package/src/{commentWrapper.js → commentWrapper.ts} +33 -30
  178. package/src/config.ts +107 -0
  179. package/src/createBindingOption.ts +91 -0
  180. package/src/createEventBinding.ts +88 -0
  181. package/src/{cssBinding.js → cssBinding.ts} +13 -11
  182. package/src/{domWalker.js → domWalker.ts} +44 -30
  183. package/src/{forOfBinding.js → forOfBinding.ts} +4 -3
  184. package/src/hoverBinding.ts +84 -0
  185. package/src/{ifBinding.js → ifBinding.ts} +14 -12
  186. package/src/index.ts +53 -0
  187. package/src/{modelBinding.js → modelBinding.ts} +11 -9
  188. package/src/postProcess.ts +22 -0
  189. package/src/{pubSub.js → pubSub.ts} +24 -15
  190. package/src/reactiveProxy.ts +285 -0
  191. package/src/{renderForOfBinding.js → renderForOfBinding.ts} +55 -33
  192. package/src/{renderIfBinding.js → renderIfBinding.ts} +45 -20
  193. package/src/renderIteration.ts +53 -0
  194. package/src/renderTemplate.ts +165 -0
  195. package/src/renderTemplatesBinding.ts +73 -0
  196. package/src/{showBinding.js → showBinding.ts} +4 -3
  197. package/src/{switchBinding.js → switchBinding.ts} +18 -15
  198. package/src/{textBinding.js → textBinding.ts} +5 -4
  199. package/src/types.ts +124 -0
  200. package/src/util.ts +810 -0
  201. package/test/css/reporter.css +9 -9
  202. package/test/fixtures/dataBindBootstrap.html +2 -2
  203. package/test/fixtures/formBindings.html +9 -1
  204. package/test/globals.d.ts +19 -0
  205. package/test/helpers/testHelper.js +46 -11
  206. package/test/mocks/featureAdsResult.json +65 -65
  207. package/test/mocks/searchResult.json +57 -57
  208. package/test/specs/{attrBinding.spec.js → attrBinding.spec.ts} +103 -106
  209. package/test/specs/{binder.spec.js → binder.spec.ts} +29 -27
  210. package/test/specs/blurBinding.spec.ts +60 -0
  211. package/test/specs/chainableUse.spec.ts +125 -0
  212. package/test/specs/clickBinding.spec.ts +194 -0
  213. package/test/specs/{cssBinding.spec.js → cssBinding.spec.ts} +72 -79
  214. package/test/specs/{dataBindBootstrap.spec.js → dataBindBootstrap.spec.ts} +332 -313
  215. package/test/specs/{filter.spec.js → filter.spec.ts} +75 -76
  216. package/test/specs/{forOfBinding.spec.js → forOfBinding.spec.ts} +208 -219
  217. package/test/specs/formBinding.spec.ts +272 -0
  218. package/test/specs/ifBinding.spec.ts +165 -0
  219. package/test/specs/{nestedComponent.spec.js → nestedComponent.spec.ts} +88 -88
  220. package/test/specs/reactiveProxy.spec.ts +465 -0
  221. package/test/specs/{showBinding.spec.js → showBinding.spec.ts} +148 -149
  222. package/test/specs/{switchBinding.spec.js → switchBinding.spec.ts} +172 -173
  223. package/test/specs/templateBinding.spec.ts +273 -0
  224. package/test/specs/{textBinding.spec.js → textBinding.spec.ts} +47 -48
  225. package/test/tsconfig.json +31 -0
  226. package/test-output.txt +200 -0
  227. package/test-reactive.html +224 -0
  228. package/tsconfig.json +28 -0
  229. package/vendors/lodash.custom.js +4577 -4577
  230. package/vendors/lodash.custom.min.js +45 -45
  231. package/vitest.config.js +27 -0
  232. package/.eslintrc.js +0 -1
  233. package/.grunt/grunt-contrib-jasmine/boot.js +0 -161
  234. package/.grunt/grunt-contrib-jasmine/dist/js/dataBind.js +0 -9
  235. package/.grunt/grunt-contrib-jasmine/grunt-template-jasmine-istanbul/reporter.js +0 -23
  236. package/.grunt/grunt-contrib-jasmine/jasmine-html.js +0 -853
  237. package/.grunt/grunt-contrib-jasmine/jasmine.css +0 -271
  238. package/.grunt/grunt-contrib-jasmine/jasmine.js +0 -9761
  239. package/.grunt/grunt-contrib-jasmine/jasmine_favicon.png +0 -0
  240. package/.grunt/grunt-contrib-jasmine/json2.js +0 -489
  241. package/.grunt/grunt-contrib-jasmine/reporter.js +0 -107
  242. package/coverage/coverage.json +0 -1
  243. package/coverage/lcov/lcov-report/base.css +0 -213
  244. package/coverage/lcov/lcov-report/index.html +0 -93
  245. package/coverage/lcov/lcov-report/js/dataBind.js.html +0 -6596
  246. package/coverage/lcov/lcov-report/js/index.html +0 -93
  247. package/coverage/lcov/lcov-report/prettify.css +0 -1
  248. package/coverage/lcov/lcov-report/prettify.js +0 -1
  249. package/coverage/lcov/lcov-report/sort-arrow-sprite.png +0 -0
  250. package/coverage/lcov/lcov-report/sorter.js +0 -158
  251. package/coverage/lcov/lcov.info +0 -1991
  252. package/eslintrc.json +0 -40
  253. package/examples/bootstrap/js/bootstrap.min.js +0 -6
  254. package/examples/bootstrap/js/popper.min.js +0 -5
  255. package/examples/bootstrap/js/searchSuggestion.js +0 -58
  256. package/examples/bootstrap/js/typeahead.jquery.js +0 -1538
  257. package/gruntfile.js +0 -92
  258. package/gulpfile.js +0 -32
  259. package/src/binder.js +0 -422
  260. package/src/changeBinding.js +0 -57
  261. package/src/config.js +0 -65
  262. package/src/createBindingOption.js +0 -66
  263. package/src/createEventBinding.js +0 -46
  264. package/src/eventSystem.js +0 -46
  265. package/src/hoverBinding.js +0 -57
  266. package/src/index.js +0 -26
  267. package/src/renderTemplate.js +0 -128
  268. package/src/util.js +0 -648
  269. package/test/specs/blurBinding.spec.js +0 -57
  270. package/test/specs/formBinding.spec.js +0 -292
  271. package/test/specs/ifBinding.spec.js +0 -169
  272. package/test/specs/templateBinding.spec.js +0 -117
  273. package/vendors/jasmine-jquery.js +0 -841
  274. package/vendors/jquery-3.2.1.min.js +0 -4
@@ -1,10 +1,10 @@
1
- .jasmine-summary > .jasmine-suite {
2
- display: block;
3
- border-bottom: 1px solid #999;
4
- padding-bottom: 1em;
5
- margin-bottom: 1em;
6
- }
7
-
8
- .jasmine-suite-detail {
9
- font-size: 1.2em;
1
+ .jasmine-summary > .jasmine-suite {
2
+ display: block;
3
+ border-bottom: 1px solid #999;
4
+ padding-bottom: 1em;
5
+ margin-bottom: 1em;
6
+ }
7
+
8
+ .jasmine-suite-detail {
9
+ font-size: 1.2em;
10
10
  }
@@ -32,7 +32,7 @@
32
32
  <h4 class="text-center section-title" data-bind-text="searchResultTitle">Featured service providers</h4>
33
33
  <div id="search-result-columns" class="card-columns" data-bind-tmp="{id: 'searchResultItem', data: '$root', append: true}">
34
34
  <div class="card result-item" data-index="0">
35
- <img class="card-img-top result-item__img" src="bootstrap/images/pic-home.jpg" alt="Card image">
35
+ <img class="card-img-top result-item__img" src="images/pic-home.jpg" alt="Card image">
36
36
  <div class="card-body">
37
37
  <h4 class="card-title">Card title that wraps to a new line</h4>
38
38
  <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
@@ -63,7 +63,7 @@
63
63
  </div>
64
64
 
65
65
  <div class="card result-item" data-index="2">
66
- <img class="card-img-top result-item__img" src="bootstrap/images/pic-deck.jpg" alt="Card image">
66
+ <img class="card-img-top result-item__img" src="images/pic-deck.jpg" alt="Card image">
67
67
  <div class="card-body">
68
68
  <h4 class="card-title">Card title</h4>
69
69
  <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
@@ -29,7 +29,15 @@
29
29
  </div>
30
30
  <div>
31
31
  <label for="testRange">Choose a range:</label>
32
- <input id="testRange" type="range" min="0" max="5" step="1" data-bind-model="testRange" data-bind-change="onTestRangeChanged">
32
+ <input id="testRange"
33
+ type="range"
34
+ min="0"
35
+ max="5"
36
+ step="1"
37
+ data-bind-model="testRange"
38
+ data-bind-change="onTestRangeChanged"
39
+ data-bind-input="onTestRangeInputChange"
40
+ >
33
41
  <label id="testRangeLabel" data-bind-text="testRange"></label>
34
42
  </div>
35
43
  <div>
@@ -0,0 +1,19 @@
1
+ // Global test helpers and dataBind types
2
+ declare global {
3
+ // dataBind global
4
+ const dataBind: {
5
+ init: (element: Element | null, viewModel: any) => any;
6
+ use: (plugin: any) => void;
7
+ };
8
+
9
+ // Test helper functions
10
+ function loadFixture(fixturePath: string): void;
11
+ function simulateInput(element: HTMLElement, value: string): void;
12
+ function simulateClick(element: HTMLElement): void;
13
+ function simulateBlur(element: HTMLElement): void;
14
+
15
+ // jQuery (used in some test fixtures)
16
+ const $: any;
17
+ }
18
+
19
+ export {};
@@ -1,11 +1,46 @@
1
- /*
2
- * overwrite requestAnimationFrame to use setTimout.
3
- * Otherewise sometime unpredictable in jasmine asyn test.
4
- * Since request animation frame callback run when browser decide it is free (we don't know exactly when)
5
- */
6
- window.requestAnimationFrame = function(fn) {
7
- return window.setTimeout(fn, 15);
8
- };
9
- window.cancelAnimationFrame = function(id) {
10
- return window.clearTimeout(id);
11
- };
1
+ import {afterEach} from 'vitest';
2
+ import {readFileSync} from 'fs';
3
+ import {resolve} from 'path';
4
+ import dataBind from '../../src/index';
5
+
6
+ /*
7
+ * overwrite requestAnimationFrame to use setTimeout.
8
+ * Otherwise sometimes unpredictable in async tests.
9
+ * Since request animation frame callback runs when browser decides it is free (we don't know exactly when)
10
+ */
11
+ global.requestAnimationFrame = (fn) => {
12
+ return setTimeout(fn, 15);
13
+ };
14
+ global.cancelAnimationFrame = (id) => {
15
+ return clearTimeout(id);
16
+ };
17
+
18
+ // Make dataBind globally available for tests (like it was in Jasmine)
19
+ global.dataBind = dataBind;
20
+
21
+ // Helper function to load HTML fixtures
22
+ global.loadFixture = (fixturePath) => {
23
+ const fullPath = resolve(process.cwd(), fixturePath);
24
+ const html = readFileSync(fullPath, 'utf-8');
25
+ document.body.innerHTML = html;
26
+ };
27
+
28
+ // Helper functions for tests to replace jQuery
29
+ global.simulateInput = (element, value) => {
30
+ element.value = value;
31
+ element.dispatchEvent(new Event('input', {bubbles: true}));
32
+ element.dispatchEvent(new Event('change', {bubbles: true}));
33
+ };
34
+
35
+ global.simulateClick = (element) => {
36
+ element.dispatchEvent(new MouseEvent('click', {bubbles: true, cancelable: true}));
37
+ };
38
+
39
+ global.simulateBlur = (element) => {
40
+ element.dispatchEvent(new FocusEvent('blur', {bubbles: true}));
41
+ };
42
+
43
+ // Helper to clean up DOM after each test
44
+ afterEach(() => {
45
+ document.body.innerHTML = '';
46
+ });
@@ -1,66 +1,66 @@
1
- [{
2
- "id": "001",
3
- "title": "Card title that wraps to a new line",
4
- "description": "This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
5
- "image": "bootstrap/images/pic-home.jpg",
6
- "bookmarked": false,
7
- "numLikes": 110
8
- },
9
- {
10
- "id": "002",
11
- "title": "Card title",
12
- "description": "This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.",
13
- "image": "",
14
- "bookmarked": false,
15
- "numLikes": 9
16
- },
17
- {
18
- "id": "003",
19
- "title": "Card title",
20
- "description": "This card has supporting text below as a natural lead-in to additional content.",
21
- "image": "bootstrap/images/pic-deck.jpg",
22
- "bookmarked": false,
23
- "numLikes": 8
24
- },
25
- {
26
- "id": "004",
27
- "title": "Card title",
28
- "description": "This card has supporting text below as a natural lead-in to additional content.",
29
- "image": "bootstrap/images/pic-carpenter.jpg",
30
- "bookmarked": false,
31
- "numLikes": 8,
32
- "highlight": true
33
- },
34
- {
35
- "id": "005",
36
- "title": "Card title",
37
- "description": "This card has supporting text below as a natural lead-in to additional content.",
38
- "image": "",
39
- "bookmarked": false,
40
- "numLikes": 68
41
- },
42
- {
43
- "id": "006",
44
- "title": "Card title that wraps to a new line",
45
- "description": "This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
46
- "image": "bootstrap/images/pic-bathrooms.jpg",
47
- "bookmarked": true,
48
- "numLikes": 99
49
- },
50
- {
51
- "id": "007",
52
- "title": "Card title",
53
- "description": "This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.",
54
- "image": "",
55
- "bookmarked": false,
56
- "numLikes": 9
57
- },
58
- {
59
- "id": "008",
60
- "title": "Card title",
61
- "description": "This card has supporting text below as a natural lead-in to additional content.",
62
- "image": "bootstrap/images/pic-backyard.jpg",
63
- "bookmarked": false,
64
- "numLikes": 24
65
- }
1
+ [{
2
+ "id": "001",
3
+ "title": "Card title that wraps to a new line",
4
+ "description": "This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
5
+ "image": "bootstrap/images/pic-home.jpg",
6
+ "bookmarked": false,
7
+ "numLikes": 110
8
+ },
9
+ {
10
+ "id": "002",
11
+ "title": "Card title",
12
+ "description": "This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.",
13
+ "image": "",
14
+ "bookmarked": false,
15
+ "numLikes": 9
16
+ },
17
+ {
18
+ "id": "003",
19
+ "title": "Card title",
20
+ "description": "This card has supporting text below as a natural lead-in to additional content.",
21
+ "image": "bootstrap/images/pic-deck.jpg",
22
+ "bookmarked": false,
23
+ "numLikes": 8
24
+ },
25
+ {
26
+ "id": "004",
27
+ "title": "Card title",
28
+ "description": "This card has supporting text below as a natural lead-in to additional content.",
29
+ "image": "bootstrap/images/pic-carpenter.jpg",
30
+ "bookmarked": false,
31
+ "numLikes": 8,
32
+ "highlight": true
33
+ },
34
+ {
35
+ "id": "005",
36
+ "title": "Card title",
37
+ "description": "This card has supporting text below as a natural lead-in to additional content.",
38
+ "image": "",
39
+ "bookmarked": false,
40
+ "numLikes": 68
41
+ },
42
+ {
43
+ "id": "006",
44
+ "title": "Card title that wraps to a new line",
45
+ "description": "This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
46
+ "image": "bootstrap/images/pic-bathrooms.jpg",
47
+ "bookmarked": true,
48
+ "numLikes": 99
49
+ },
50
+ {
51
+ "id": "007",
52
+ "title": "Card title",
53
+ "description": "This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.",
54
+ "image": "",
55
+ "bookmarked": false,
56
+ "numLikes": 9
57
+ },
58
+ {
59
+ "id": "008",
60
+ "title": "Card title",
61
+ "description": "This card has supporting text below as a natural lead-in to additional content.",
62
+ "image": "bootstrap/images/pic-backyard.jpg",
63
+ "bookmarked": false,
64
+ "numLikes": 24
65
+ }
66
66
  ]
@@ -1,58 +1,58 @@
1
- [{
2
- "id": "001",
3
- "title": "Card title that wraps to a new line",
4
- "description": "This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
5
- "image": "bootstrap/images/pic-home.jpg",
6
- "bookmarked": false,
7
- "numLikes": 110
8
- },
9
- {
10
- "id": "456",
11
- "title": "Card title",
12
- "description": "This card has supporting text below as a natural lead-in to additional content.",
13
- "image": "",
14
- "bookmarked": false,
15
- "numLikes": 8
16
- },
17
- {
18
- "id": "789",
19
- "title": "Sample carpemter service",
20
- "description": "This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.",
21
- "image": "bootstrap/images/pic-carpenter.jpg",
22
- "bookmarked": false,
23
- "numLikes": 8,
24
- "highlight": true
25
- },
26
- {
27
- "id": "888",
28
- "title": "Sample timber floor service",
29
- "description": "This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
30
- "image": "bootstrap/images/pic-deck.jpg",
31
- "bookmarked": false,
32
- "numLikes": 8
33
- },
34
- {
35
- "id": "222",
36
- "title": "Sample timber floor service",
37
- "description": "This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
38
- "image": "",
39
- "bookmarked": false,
40
- "numLikes": 8
41
- },
42
- {
43
- "id": "333",
44
- "title": "Sample boothroom service",
45
- "description": "This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.",
46
- "image": "bootstrap/images/pic-bathrooms.jpg",
47
- "bookmarked": true,
48
- "numLikes": 8
49
- },
50
- {
51
- "id": "444",
52
- "title": "Sample gardening service",
53
- "description": "This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
54
- "image": "bootstrap/images/pic-backyard.jpg",
55
- "bookmarked": false,
56
- "numLikes": 8
57
- }
1
+ [{
2
+ "id": "001",
3
+ "title": "Card title that wraps to a new line",
4
+ "description": "This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
5
+ "image": "bootstrap/images/pic-home.jpg",
6
+ "bookmarked": false,
7
+ "numLikes": 110
8
+ },
9
+ {
10
+ "id": "456",
11
+ "title": "Card title",
12
+ "description": "This card has supporting text below as a natural lead-in to additional content.",
13
+ "image": "",
14
+ "bookmarked": false,
15
+ "numLikes": 8
16
+ },
17
+ {
18
+ "id": "789",
19
+ "title": "Sample carpemter service",
20
+ "description": "This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.",
21
+ "image": "bootstrap/images/pic-carpenter.jpg",
22
+ "bookmarked": false,
23
+ "numLikes": 8,
24
+ "highlight": true
25
+ },
26
+ {
27
+ "id": "888",
28
+ "title": "Sample timber floor service",
29
+ "description": "This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
30
+ "image": "bootstrap/images/pic-deck.jpg",
31
+ "bookmarked": false,
32
+ "numLikes": 8
33
+ },
34
+ {
35
+ "id": "222",
36
+ "title": "Sample timber floor service",
37
+ "description": "This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
38
+ "image": "",
39
+ "bookmarked": false,
40
+ "numLikes": 8
41
+ },
42
+ {
43
+ "id": "333",
44
+ "title": "Sample boothroom service",
45
+ "description": "This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.",
46
+ "image": "bootstrap/images/pic-bathrooms.jpg",
47
+ "bookmarked": true,
48
+ "numLikes": 8
49
+ },
50
+ {
51
+ "id": "444",
52
+ "title": "Sample gardening service",
53
+ "description": "This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.",
54
+ "image": "bootstrap/images/pic-backyard.jpg",
55
+ "bookmarked": false,
56
+ "numLikes": 8
57
+ }
58
58
  ]
@@ -1,106 +1,103 @@
1
- describe('Given [data-bind-comp="attr-component"] inited', () => {
2
- const namespace = {};
3
- const testAttr2Obj = {
4
- id: 'newId',
5
- ref: 'newRef2',
6
- };
7
-
8
- jasmine.getFixtures().fixturesPath = 'test';
9
-
10
- beforeEach(() => {
11
- loadFixtures('./fixtures/attrBinding.html');
12
-
13
- namespace.viewModel = {
14
- heading: 'Test data-if-binding',
15
- attr1: {
16
- style: 'width:300px',
17
- ref: 'newRef',
18
- },
19
- attr2: function($data) {
20
- return testAttr2Obj;
21
- },
22
- updateView: function(opt) {
23
- this.APP.render(opt);
24
- },
25
- };
26
-
27
- namespace.myAttrComponent = dataBind.init(document.querySelector('[data-bind-comp="attr-component"]'), namespace.viewModel);
28
-
29
- namespace.myAttrComponent.render();
30
- });
31
-
32
- afterEach(() => {
33
- // clean up all app/components
34
- for (const prop in namespace) {
35
- if (namespace.hasOwnProperty(prop)) {
36
- delete namespace[prop];
37
- }
38
- }
39
- });
40
-
41
- it('Then [data-bind-comp="myAttrComponent"] should have render', (done) => {
42
- setTimeout(() => {
43
- const $testAttr1 = document.getElementById('testAttr1');
44
- expect($testAttr1.textContent).toBe(namespace.viewModel.heading);
45
- done();
46
- }, 200);
47
- });
48
-
49
- it('Should update testAttr1 attributes', (done) => {
50
- setTimeout(function() {
51
- const $testAttr1 = document.getElementById('testAttr1');
52
- expect($testAttr1.getAttribute('ref')).toBe(namespace.viewModel.attr1.ref);
53
- expect($testAttr1.getAttribute('style')).toBe(namespace.viewModel.attr1.style);
54
- // check existing attribute untouch
55
- expect($testAttr1.getAttribute('id')).toBe('testAttr1');
56
- expect($testAttr1.getAttribute('class')).toBe('test');
57
- done();
58
- }, 200);
59
- });
60
-
61
- it('Should update testAttr2 attributes as viewModel function property', (done) => {
62
- setTimeout(() => {
63
- const $testAttr2 = document.getElementById(testAttr2Obj.id);
64
- expect($testAttr2.getAttribute('ref')).toBe(testAttr2Obj.ref);
65
- expect($testAttr2.getAttribute('id')).toBe(testAttr2Obj.id);
66
- done();
67
- }, 200);
68
- });
69
-
70
- it('Should update attribute when viewModel updated', (done) => {
71
- const updatedRef = 'updatedRef';
72
- const disabled = 'disabled';
73
-
74
- namespace.viewModel.attr1.ref = updatedRef;
75
- namespace.viewModel.attr1.disabled = disabled;
76
- namespace.myAttrComponent.render();
77
-
78
- setTimeout(() => {
79
- const $testAttr1 = document.getElementById('testAttr1');
80
- expect($testAttr1.getAttribute('ref')).toBe(updatedRef);
81
- expect($testAttr1.getAttribute('disabled')).toBe(disabled);
82
- expect($testAttr1.getAttribute('style')).toBe(namespace.viewModel.attr1.style);
83
- // check existing attribute untouch
84
- expect($testAttr1.getAttribute('id')).toBe('testAttr1');
85
- expect($testAttr1.getAttribute('class')).toBe('test');
86
- done();
87
- }, 200);
88
- });
89
-
90
- it('Should remove attribute when viewModel updated', (done) => {
91
- const updatedRef2 = 'updatedRef2';
92
- namespace.viewModel.attr1 = {
93
- ref: updatedRef2,
94
- };
95
-
96
- setTimeout(() => {
97
- const $testAttr1 = document.getElementById('testAttr1');
98
- expect($testAttr1.getAttribute('ref')).toBe(updatedRef2);
99
- expect($testAttr1.getAttribute('style')).toBe(null);
100
- // check existing attribute untouch
101
- expect($testAttr1.getAttribute('id')).toBe('testAttr1');
102
- expect($testAttr1.getAttribute('class')).toBe('test');
103
- done();
104
- }, 200);
105
- });
106
- });
1
+ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
2
+ import {waitFor} from '@testing-library/dom';
3
+
4
+ describe('Given [data-bind-comp="attr-component"] inited', () => {
5
+ const namespace: any = {};
6
+ const testAttr2Obj = {
7
+ id: 'newId',
8
+ ref: 'newRef2',
9
+ };
10
+
11
+ beforeEach(() => {
12
+ loadFixture('test/fixtures/attrBinding.html');
13
+
14
+ namespace.viewModel = {
15
+ heading: 'Test data-if-binding',
16
+ attr1: {
17
+ style: 'width:300px',
18
+ ref: 'newRef',
19
+ },
20
+ attr2(_$data: any) {
21
+ return testAttr2Obj;
22
+ },
23
+ updateView(opt?: any) {
24
+ this.APP.render(opt);
25
+ },
26
+ };
27
+
28
+ namespace.myAttrComponent = dataBind.init(document.querySelector('[data-bind-comp="attr-component"]'), namespace.viewModel);
29
+
30
+ namespace.myAttrComponent.render();
31
+ });
32
+
33
+ afterEach(() => {
34
+ // clean up all app/components
35
+ for (const prop in namespace) {
36
+ if (Object.prototype.hasOwnProperty.call(namespace, prop)) {
37
+ delete namespace[prop];
38
+ }
39
+ }
40
+ });
41
+
42
+ it('Then [data-bind-comp="myAttrComponent"] should have render', async () => {
43
+ await waitFor(() => {
44
+ const $testAttr1 = document.getElementById('testAttr1')!;
45
+ expect($testAttr1.textContent).toBe(namespace.viewModel.heading);
46
+ }, {timeout: 500});
47
+ });
48
+
49
+ it('Should update testAttr1 attributes', async () => {
50
+ await waitFor(() => {
51
+ const $testAttr1 = document.getElementById('testAttr1')!;
52
+ expect($testAttr1.getAttribute('ref')).toBe(namespace.viewModel.attr1.ref);
53
+ expect($testAttr1.getAttribute('style')).toBe(namespace.viewModel.attr1.style);
54
+ // check existing attribute untouch
55
+ expect($testAttr1.getAttribute('id')).toBe('testAttr1');
56
+ expect($testAttr1.getAttribute('class')).toBe('test');
57
+ }, {timeout: 500});
58
+ });
59
+
60
+ it('Should update testAttr2 attributes as viewModel function property', async () => {
61
+ await waitFor(() => {
62
+ const $testAttr2 = document.getElementById(testAttr2Obj.id)!;
63
+ expect($testAttr2.getAttribute('ref')).toBe(testAttr2Obj.ref);
64
+ expect($testAttr2.getAttribute('id')).toBe(testAttr2Obj.id);
65
+ }, {timeout: 500});
66
+ });
67
+
68
+ it('Should update attribute when viewModel updated', async () => {
69
+ const updatedRef = 'updatedRef';
70
+ const disabled = 'disabled';
71
+ namespace.viewModel.attr1 = {
72
+ ref: updatedRef,
73
+ disabled,
74
+ style: namespace.viewModel.attr1.style,
75
+ };
76
+
77
+ await waitFor(() => {
78
+ const $testAttr1 = document.getElementById('testAttr1')!;
79
+ expect($testAttr1.getAttribute('ref')).toBe(updatedRef);
80
+ expect($testAttr1.getAttribute('disabled')).toBe(disabled);
81
+ expect($testAttr1.getAttribute('style')).toBe(namespace.viewModel.attr1.style);
82
+ // check existing attribute untouch
83
+ expect($testAttr1.getAttribute('id')).toBe('testAttr1');
84
+ expect($testAttr1.getAttribute('class')).toBe('test');
85
+ }, {timeout: 500});
86
+ });
87
+
88
+ it('Should remove attribute when viewModel updated', async () => {
89
+ const updatedRef2 = 'updatedRef2';
90
+ namespace.viewModel.attr1 = {
91
+ ref: updatedRef2,
92
+ };
93
+
94
+ await waitFor(() => {
95
+ const $testAttr1 = document.getElementById('testAttr1')!;
96
+ expect($testAttr1.getAttribute('ref')).toBe(updatedRef2);
97
+ expect($testAttr1.getAttribute('style')).toBe(null);
98
+ // check existing attribute untouch
99
+ expect($testAttr1.getAttribute('id')).toBe('testAttr1');
100
+ expect($testAttr1.getAttribute('class')).toBe('test');
101
+ }, {timeout: 500});
102
+ });
103
+ });