bitwrench 1.2.15 → 2.0.7

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 (119) hide show
  1. package/README.md +160 -158
  2. package/bin/bitwrench.js +3 -0
  3. package/dist/bitwrench-code-edit.cjs.js +639 -0
  4. package/dist/bitwrench-code-edit.es5.js +875 -0
  5. package/dist/bitwrench-code-edit.es5.min.js +15 -0
  6. package/dist/bitwrench-code-edit.esm.js +628 -0
  7. package/dist/bitwrench-code-edit.esm.min.js +15 -0
  8. package/dist/bitwrench-code-edit.umd.js +645 -0
  9. package/dist/bitwrench-code-edit.umd.min.js +15 -0
  10. package/dist/bitwrench.cjs.js +6983 -0
  11. package/dist/bitwrench.cjs.min.js +62 -0
  12. package/dist/bitwrench.css +5100 -0
  13. package/dist/bitwrench.es5.js +8446 -0
  14. package/dist/bitwrench.es5.min.js +31 -0
  15. package/dist/bitwrench.esm.js +6981 -0
  16. package/dist/bitwrench.esm.min.js +62 -0
  17. package/dist/bitwrench.umd.js +6989 -0
  18. package/dist/bitwrench.umd.min.js +62 -0
  19. package/dist/builds.json +127 -0
  20. package/dist/sri.json +18 -0
  21. package/package.json +86 -24
  22. package/readme.html +288 -0
  23. package/src/bitwrench-code-edit.js +627 -0
  24. package/src/bitwrench-color-utils.js +311 -0
  25. package/src/bitwrench-component-base.js +736 -0
  26. package/src/bitwrench-components-inline.js +374 -0
  27. package/src/bitwrench-components-v2.js +1879 -0
  28. package/src/bitwrench-components.js +610 -0
  29. package/src/bitwrench-styles.js +3240 -0
  30. package/src/bitwrench.js +3367 -0
  31. package/src/cli/convert.js +205 -0
  32. package/src/cli/index.js +122 -0
  33. package/src/cli/inject.js +55 -0
  34. package/src/cli/layout-default.js +142 -0
  35. package/src/generate-css.js +381 -0
  36. package/src/vendor/quikdown.js +654 -0
  37. package/src/version.js +16 -0
  38. package/.eslintrc.json +0 -27
  39. package/.github/workflows/codeql-analysis.yml +0 -72
  40. package/.travis.yml +0 -34
  41. package/bitwrench.css +0 -92
  42. package/bitwrench.js +0 -3348
  43. package/bitwrench.js_sri.txt +0 -1
  44. package/bitwrench.min.js +0 -1
  45. package/bitwrench.min.js_sri.txt +0 -1
  46. package/bitwrench_ESM.js +0 -3207
  47. package/dev/bitwrench-todo.md +0 -215
  48. package/dev/css-arrows.md +0 -23
  49. package/dev/docStringDev.js +0 -124
  50. package/dev/docStringParseDev.js +0 -171
  51. package/dev/figures.html +0 -37
  52. package/dev/html_gen.js +0 -349
  53. package/dev/htmld.md +0 -250
  54. package/dev/htmldev.html +0 -45
  55. package/dev/index-old.html +0 -87
  56. package/dev/misc-notes.md +0 -21
  57. package/dev/notes.md +0 -2
  58. package/dev/sizes.html +0 -49
  59. package/dev/universal-js-module.js +0 -37
  60. package/examples/example1.html +0 -78
  61. package/examples/example10.html +0 -84
  62. package/examples/example2.html +0 -44
  63. package/examples/example3.html +0 -50
  64. package/examples/example4.html +0 -22
  65. package/examples/example5.html +0 -82
  66. package/examples/example6.html +0 -128
  67. package/examples/example7.html +0 -91
  68. package/examples/example8.html +0 -27
  69. package/examples/example9.html +0 -102
  70. package/icon/bitwrench-dark-tall.png +0 -0
  71. package/icon/bitwrench-dark.png +0 -0
  72. package/icon/bitwrench-icon-lt-grey.png +0 -0
  73. package/icon/bitwrench-icon.vsd +0 -0
  74. package/icon/bitwrench-logo-dark.png +0 -0
  75. package/icon/bitwrench-logo-full.png +0 -0
  76. package/icon/bitwrench-logo-green.png +0 -0
  77. package/icon/bitwrench-logo-grey.png +0 -0
  78. package/icon/bitwrench-logo-white.png +0 -0
  79. package/icon/bitwrench-logos-colors.png +0 -0
  80. package/icon/bitwrench-thick-logo.png +0 -0
  81. package/icon/bitwrench-thick-teal/android-chrome-192x192.png +0 -0
  82. package/icon/bitwrench-thick-teal/android-chrome-512x512.png +0 -0
  83. package/icon/bitwrench-thick-teal/apple-touch-icon.png +0 -0
  84. package/icon/bitwrench-thick-teal/browserconfig.xml +0 -9
  85. package/icon/bitwrench-thick-teal/favicon-16x16.png +0 -0
  86. package/icon/bitwrench-thick-teal/favicon-32x32.png +0 -0
  87. package/icon/bitwrench-thick-teal/favicon.ico +0 -0
  88. package/icon/bitwrench-thick-teal/mstile-144x144.png +0 -0
  89. package/icon/bitwrench-thick-teal/mstile-150x150.png +0 -0
  90. package/icon/bitwrench-thick-teal/mstile-310x150.png +0 -0
  91. package/icon/bitwrench-thick-teal/mstile-310x310.png +0 -0
  92. package/icon/bitwrench-thick-teal/mstile-70x70.png +0 -0
  93. package/icon/bitwrench-thick-teal/site.webmanifest +0 -19
  94. package/icon/bitwrench-thick-teal.ico +0 -0
  95. package/icon/bitwrench-thick-teal.svg +0 -44
  96. package/icon/bitwrench-thick-teal.zip +0 -0
  97. package/icon/favicon-test.html +0 -20
  98. package/icon/logos-test.PNG +0 -0
  99. package/images/bitwrench-512x512.png +0 -0
  100. package/images/bitwrench-logo-med.png +0 -0
  101. package/images/bitwrench-thick-logo.png +0 -0
  102. package/images/bitwrench-thick-logo.svg +0 -64
  103. package/images/bitwrench-thick-teal.ico +0 -0
  104. package/images/favicon.ico +0 -0
  105. package/index.html +0 -256
  106. package/instr_tmp/bitwrench.js +0 -1350
  107. package/karma.conf.js +0 -140
  108. package/makefile +0 -21
  109. package/quick-docs.html +0 -206
  110. package/test/bitwrench_test.js +0 -1255
  111. package/test/karma-test.js +0 -1081
  112. package/tools/bw_deprecatedNames.js +0 -19
  113. package/tools/bwconsole.js +0 -20
  114. package/tools/createSimpleHTMLPage.js +0 -41
  115. package/tools/emitreadme.sh +0 -4
  116. package/tools/export-bw-default-css.js +0 -41
  117. package/tools/umd2ModuleHack.js +0 -32
  118. package/tools/update-bw-package.js +0 -36
  119. package/tools/updatereadme.js +0 -34
@@ -1,1081 +0,0 @@
1
- /*"""
2
- bitwrench test functions for karma headless browser tests
3
-
4
- note you may need an env var set such as :
5
-
6
- export CHROME_BIN=/usr/bin/chromium-browser
7
-
8
- """*/
9
- "use strict";
10
-
11
-
12
- // ================================================================
13
- var setupdom = function(wnd,html) {
14
- if (bw.isNodeJS() ) {
15
-
16
- const testDoc = `<!DOCTYPE html><html><head></head><body><span id="myTestSpan">starter</span><div class="foo">default</div></body></html>`;
17
- wnd = (new JSDOM( (((typeof html) !== "undefined") ? html : testDoc),
18
- {
19
- runScripts: "dangerously" ,
20
- created: function (errors, wnd) { wnd[coverageVar] = global[coverageVar]; console.log(coverageVar) },
21
- done : function (errors, wnd) {if (errors) {console.log(errors); done(true); } else { window = wnd; done(); }
22
- }
23
- })).window;
24
-
25
- // Execute my library by inserting a <script> tag containing it.
26
- const scriptEl = window.document.createElement("script");
27
- scriptEl.textContent = bitwrenchFileInstrumented;
28
- window.document.head.appendChild(scriptEl);
29
- }
30
- else {
31
- wnd = window; // yes the global window -- we're in the browser
32
- console.log("browser context")
33
- }
34
- return wnd;
35
- }
36
-
37
-
38
-
39
- //tests begin:
40
- // ================================================================
41
- describe("#choice(x,choiceDict{},defaultVal) - Allows a dictionary to be used as a switch statement, including functions as values. ", function() {
42
- /**
43
-
44
- */
45
- var tests = [
46
- {args: [1, {1:2,foo:"bar"},function(){return "defaultUsed"}], expected: 2 },
47
- {args: ["foo", {1:2, foo:function(x){return x+"bar"}},function(){return "defaultUsed"}], expected: "foobar" },
48
- {args: [3, {1:2,foo:"bar"},function(x){return "not found: " + String(x)}], expected: "not found: 3" },
49
- ];
50
-
51
- tests.forEach(function(test) {
52
- it("bw.choice " + test.args.length + "args", function() {
53
- var res = bw.choice.apply(null, test.args);
54
- assert.equal(res, test.expected);
55
- });
56
- });
57
-
58
- });
59
-
60
- // ================================================================
61
- describe("#jsonClone() - duplicate a (simple) object by converting to JSON and back", function() {
62
- /**
63
-
64
- */
65
- var tests = [
66
- {args: [{1:2,foo:"bar"}], expected: {1:2,foo:"bar"} },
67
- {args: ["foo"], expected: "foo" }
68
- ];
69
-
70
- tests.forEach(function(test) {
71
- it("bw.jsonClone " + test.args.length + "args", function() {
72
- var res = bw.jsonClone.apply(null, test.args);
73
- assert.deepEqual(res, test.expected);
74
- });
75
- });
76
- });
77
-
78
- // ================================================================
79
- describe("#typeOf()", function() {
80
- /**
81
- test built-in basic bitwrench typeof operator
82
- */
83
-
84
- //using meta tests
85
- var x;
86
- var tests = [
87
- {args: [[]], expected: "array"},
88
- {args: [{}], expected: "object"},
89
- {args: [1], expected: "number"},
90
- {args: ["test string"], expected: "string"},
91
- {args: [x], expected: "undefined"},
92
- {args: [null], expected: "null"},
93
- {args: [new Date()], expected: "date"},
94
- {args: [function(){}], expected: "function"},
95
- {args: [class{}], expected: "function" }
96
- ];
97
-
98
- tests.forEach(function(test) {
99
- it("bw.typeOf (internal type operator) " + test.args.length + " args", function() {
100
- var res = bw.typeOf.apply(null, test.args);
101
- assert.equal(res, test.expected);
102
- });
103
- });
104
-
105
- });
106
- // ================================================================
107
- describe("#typeAssign(x,type,trueV,FalseV) - see if a variable is a certain type or one of a list of types", function() {
108
- /**
109
-
110
- */
111
- var tests = [
112
- {args: [1,0,true,false], expected:false }, // needs typeString to be a number or string
113
- {args: [1,"number",true,false], expected: true },
114
- {args: [1,"string",true,false], expected: false },
115
- {args: [1,["number","string"],true,false], expected: true }
116
- ];
117
-
118
- tests.forEach(function(test) {
119
- it("bw.typeAssign " + test.args.length + "args", function() {
120
- var res = bw.typeAssign.apply(null, test.args);
121
- assert.equal(res, test.expected);
122
- });
123
- });
124
- });
125
- // ================================================================
126
- describe("#typeConvert(x,type,trueV,FalseV) - see if a variable is a certain type or one of a list of types, allows output to be functional", function() {
127
- /**
128
-
129
- */
130
- var tests = [
131
- {args: [1,0,true,false], expected:false }, // needs typeString to be a number or string
132
- {args: [1,"number",true,false], expected: true },
133
- {args: [1,"string",true,false], expected: false },
134
- {args: [1,["number","string"],true,false], expected: true },
135
- {args: [1,["number","string"],function(){return "true"},function(){return "false"}], expected: "true" },
136
- {args: [1,["number","string"],function(){return "true"},function(x){return x}], expected: "true" },
137
- {args: [{},["number","string"],function(){return "true"},function(){return "false"}], expected: "false" }
138
- ];
139
-
140
- tests.forEach(function(test) {
141
- it("bw.typeConvert " + test.args.length + "args", function() {
142
- var res = bw.typeConvert.apply(null, test.args);
143
- assert.equal(res, test.expected);
144
- });
145
- });
146
- });
147
-
148
- // ================================================================
149
- describe("#typeConvert(x,type,trueV,FalseV) - see if a variable is a certain type or one of a list of types, allows output to be functional", function() {
150
- /**
151
-
152
- */
153
- var tests = [
154
- {args: [1,0,true,false], expected:false }, // needs typeString to be a number or string
155
- {args: [1,"number",true,false], expected: true },
156
- {args: [1,"string",true,false], expected: false },
157
- {args: [1,["number","string"],true,false], expected: true },
158
- {args: [1,["number","string"],function(){return "true"},function(){return "false"}], expected: "true" },
159
- {args: [1,["number","string"],function(){return "true"},function(x){return x}], expected: "true" },
160
- {args: [{},["number","string"],function(){return "true"},function(){return "false"}], expected: "false" }
161
- ];
162
-
163
- tests.forEach(function(test) {
164
- it("bw.typeConvert " + test.args.length + "args", function() {
165
- var res = bw.typeConvert.apply(null, test.args);
166
- assert.equal(res, test.expected);
167
- });
168
- });
169
- });
170
- // ================================================================
171
-
172
- describe("#arrayUniq([]) - return uniq elements of an Array", function() {
173
- /**
174
-
175
- */
176
- var tests = [
177
-
178
- {args: [[1,2,3,2,1]], expected:[1,2,3] },
179
- {args: [1], expected: []} // type check
180
- ];
181
-
182
- tests.forEach(function(test) {
183
- it("bw.arrayUniq " + test.args.length + "args", function() {
184
- var res = bw.arrayUniq.apply(null, test.args);
185
- assert.deepEqual(res, test.expected);
186
- });
187
- });
188
- });
189
- // ================================================================
190
-
191
- describe("#arrayBinA(a[],b[]) - return elements of Array B in Array A ", function() {
192
- /**
193
-
194
- */
195
- var tests = [
196
-
197
- {args: [[1,2,3,2,1],[1,3,5]], expected:[1,3] },
198
- {args: [1,[]], expected: []}, //type check
199
- {args: [[],1], expected: []} //type check
200
- ];
201
-
202
- tests.forEach(function(test) {
203
- it("bw.arrayBinA " + test.args.length + "args", function() {
204
- var res = bw.arrayBinA.apply(null, test.args);
205
- assert.deepEqual(res, test.expected);
206
- });
207
- });
208
- });
209
- // ================================================================
210
-
211
- describe("#arrayBNotinA(a,b) - return elements of Array B not in Array A ", function() {
212
- /**
213
-
214
- */
215
- var tests = [
216
- {args: [[1,2,3,2,1],[1,3,5]], expected:[5] },
217
- {args: [1,[]], expected: []}, //type check
218
- {args: [[],1], expected: []} //type check
219
- ];
220
-
221
- tests.forEach(function(test) {
222
- it("bw.arrayBNotinA " + test.args.length + "args", function() {
223
- var res = bw.arrayBNotInA.apply(null, test.args);
224
- assert.deepEqual(res, test.expected);
225
- });
226
- });
227
- });
228
-
229
- describe("#bw.DOMIsElement()", function() {
230
- /**
231
-
232
-
233
- */
234
- var wind;
235
- beforeEach(() => {
236
- wind = setupdom(wind);
237
- });
238
-
239
- it("DOMIsElement()", () => {
240
- assert.equal(wind.bw.DOMIsElement(wind.bw.DOM("span")[0]), true); // test jsdom is using bw correctly in window context
241
- });
242
- it("DOMIsElement()", () => {
243
- assert.equal(wind.bw.DOMIsElement(wind.bw.DOM("not an Element")[0]), false); // test jsdom is using bw correctly in window context
244
- });
245
- });
246
- // ================================================================
247
-
248
- describe("#colorInterp((x, in0, in1, colors, stretch) - interpolate a value from an array of colors ", function() {
249
- /**
250
-
251
- */
252
- var tests = [
253
- {args: [228,100,355,["#000","rgb(255,255,255)"]], expected:[128,128,128,255,"rgb"] },
254
- {args: [162.5,100,200,["#000","#aaa","#fff","#000","#bbb"]], expected: [127.5, 127.5, 127.5, 255, "rgb"]}
255
- ];
256
-
257
- tests.forEach(function(test) {
258
- it("bw.colorInterp " + test.args.length + "args", function() {
259
- var res = bw.colorInterp.apply(null, test.args);
260
- assert.deepEqual(res, test.expected);
261
- });
262
- });
263
- });
264
-
265
- // ================================================================
266
- /*
267
- some useful color values:
268
-
269
- Black #000000 (0,0,0) (0°,0%,0%)
270
- White #FFFFFF (255,255,255) (0°,0%,100%)
271
- Red #FF0000 (255,0,0) (0°,100%,50%)
272
- Lime #00FF00 (0,255,0) (120°,100%,50%)
273
- Blue #0000FF (0,0,255) (240°,100%,50%)
274
- Yellow #FFFF00 (255,255,0) (60°,100%,50%)
275
- Cyan #00FFFF (0,255,255) (180°,100%,50%)
276
- Magenta #FF00FF (255,0,255) (300°,100%,50%)
277
- Silver #BFBFBF (191,191,191) (0°,0%,75%)
278
- */
279
-
280
- describe("#colorHslToRgb(h, s, l, a - convert HSL color space to RGB ", function() {
281
- /**
282
- test conversion of HSL colors to RGB
283
- */
284
- var tests = [
285
- {args: [120,100,50,128], expected:[0,255,0,128,"rgb"] } ,
286
- {args: [[0,0,75,128]], expected:[191,191,191,128,"rgb"] }
287
- ];
288
-
289
- var crnd = function(a){return [Math.round(a[0]),Math.round(a[1]),Math.round(a[2]),Math.round(a[3]),a[4] ];}
290
- tests.forEach(function(test) {
291
- it("bw.colorHslToRgb " + test.args.length + "args", function() {
292
- var res = bw.colorHslToRgb.apply(null, test.args);
293
- //res = crnd(res);
294
- assert.deepEqual(res, test.expected);
295
- });
296
- });
297
- });
298
-
299
-
300
- // ================================================================
301
-
302
- describe("#colorRgbToHsl(r, g, b, a - convert HSL color space to RGB ", function() {
303
- /**
304
- test conversion of RGB style colors to HSL
305
- */
306
- var tests = [
307
- {args: [0,255,0,100], expected:[120,100,50,100,"hsl"] },
308
- {args: [[191,191,191,100]], expected:[0,0,75,100,"hsl"] }
309
- ];
310
-
311
- var hrnd = function(a){return [Math.round(a[0]*360),bw.fixNum(a[1],2),bw.fixNum(a[2],2),Math.round(a[3]),a[4] ];}
312
-
313
- tests.forEach(function(test) {
314
- it("bw.colorRgbToHsl " + test.args.length + "args", function() {
315
- var res = bw.colorRgbToHsl.apply(null, test.args);
316
- //res = hrnd(res);
317
- assert.deepEqual(res, test.expected);
318
- });
319
- });
320
- });
321
-
322
- describe("#colorParse(colorToParseString, defaultAlpha - parse a color object e.g. #abc or HSL(12,3,43,0.3) to a bitwrench color array [,,,] ", function() {
323
- /**
324
-
325
- */
326
- var tests = [
327
- {args: ["#abc"], expected:[170, 187, 204, 255, "rgb"] },
328
- {args: ["#abc",255], expected:[170, 187, 204, 255, "rgb"] },
329
- {args: ["#abcd"], expected:[170, 187, 204, 221, "rgb"] },
330
- {args: ["#AABBCC"], expected:[170, 187, 204, 255, "rgb"] },
331
- {args: ["hsl(12,34,45,100)"], expected:[12,34,45,100,"hsl"] },
332
- {args: [" hsl ( 12 , 34, 45, 100 )"], expected:[12,34,45,100,"hsl"] },
333
- {args: [[0xaa,0xbb,0xcc]], expected: [0xaa,0xbb,0xcc,0xff,"rgb"]},
334
- {args: [[10,20,30,40,"rgb"]], expected: [10,20,30,40,"rgb"]},
335
- {args: [[300,20,30,50,"hsl"]], expected: [300,20,30,50,"hsl"]}
336
- ];
337
-
338
-
339
- tests.forEach(function(test) {
340
- it("bw.colorParse " + test.args.length + "args", function() {
341
- var res = bw.colorParse.apply(null, test.args);
342
- //res = hrnd(res);
343
- assert.deepEqual(res, test.expected);
344
- });
345
- });
346
- });
347
-
348
- describe("#colorConvertColorSpace( convert a color from one space to another)", function() {
349
- /**
350
- test conversion of RGB style colors to HSL
351
- */
352
- var tests = [
353
- {args: [[0,255,0,100,"rgb"],"hsl"], expected:[120,100,50,100,"hsl"] },
354
- {args: [[0,255,0,100,"rgb"],"rgb"], expected:[0,255,0,100,"rgb"] },
355
- {args: [[120,100,50,111,"hsl"],"rgb"], expected:[0,255,0,111,"rgb"] },
356
- {args: [[120,100,50,111,"hsl"],"hsl"], expected:[120,100,50,111,"hsl"] }
357
- ];
358
-
359
- var hrnd = function(a){return [Math.round(a[0]*360),bw.fixNum(a[1],2),bw.fixNum(a[2],2),Math.round(a[3]),a[4] ];}
360
-
361
- tests.forEach(function(test) {
362
- it("bw.colorConvertColorSpace " + test.args.length + "args", function() {
363
- var res = bw.colorConvertColorSpace.apply(null, test.args);
364
- //res = hrnd(res);
365
- assert.deepEqual(res, test.expected);
366
- });
367
- });
368
- });
369
- //====================================================================================
370
- describe("#URLParamParse(url, optKey, OptDefValue - parse URL query string (must have ? present) to get values", function() {
371
- /**
372
- test extraction or URL params. note in bitwrench this is used both for URL parsing and "command line" args parsing
373
- */
374
- var tests = [
375
- {args: ["http://bar.com:80?foo=bar&x=234&y=45"], expected:{foo:"bar",x:"234",y:"45"} },
376
- {args: ["?a=123&b=234","a"], expected:"123" },
377
- {args: ["?a=123&b=234","c"], expected: undefined },
378
- {args: ["?a=123&b=234","c","def"], expected:"def" },
379
- {args: ["?a=123&b=234&d&e=#123","d","def",true], expected:true }, // case of key with no value
380
- {args: ["?a=123&b=234&d&e=#123","e","#123",true], expected:"#123" },
381
- {args: ["https:1bca.com/a/b/c?a=134&b=234#thisisit&d=234","b","no",true], expected: "234#thisisit"},
382
- {args: ["https:1bca.com/a/b/c?a=134&b=234#thisisit&d=234","b","no",false], expected: "234"},
383
- {args: ["https:1bca.com/a/b/c?a=134&b=234#thisisit&d=234","b","no"], expected: "234" }
384
-
385
- ];
386
-
387
-
388
- tests.forEach(function(test) {
389
- it("bw.URLParamParse " + test.args.length + "args", function() {
390
- var res = bw.URLParamParse.apply(null, test.args);
391
- if (typeof res == "string")
392
- assert.equal(res, test.expected);
393
- else
394
- assert.deepEqual(res, test.expected);
395
- });
396
- });
397
- });
398
- //====================================================================================
399
- describe("#URLHash (url,defValue) - returns the hash portion of a url encoded string. If no params supplied attempts to get has from window.location.href", function() {
400
- /**
401
- see if a URL has a hash string at the end
402
- */
403
- var tests = [
404
- {args: [], expected: undefined},
405
- {args: ["http://bar.com:80?foo=bar&x=234&y=45#123"], expected:"123" },
406
- {args: ["?a=123&b=234","no"], expected:"no" },
407
- ];
408
-
409
-
410
- tests.forEach(function(test) {
411
- it("bw.URLHash " + test.args.length + "args", function() {
412
- var res = bw.URLHash.apply(null, test.args);
413
- if (typeof res == "string")
414
- assert.equal(res, test.expected);
415
- else
416
- assert.deepEqual(res, test.expected);
417
- });
418
- });
419
- });
420
- //====================================================================================
421
- describe("#URLParamPack (dict,addQuestionToFront) -packs a simple (not deep) dict in to URL form", function() {
422
- /**
423
- pack a simple dict to a URL encoded string.
424
- */
425
- var tests = [
426
- {args: [{123:"abc",234:456}], expected: "123=abc&234=456"},
427
- {args: [{123:"abc",234:456},true], expected: "?123=abc&234=456"},
428
- {args: ["foo"], expected:"" },
429
- ];
430
-
431
-
432
- tests.forEach(function(test) {
433
- it("bw.URLParamPack " + test.args.length + "args", function() {
434
- var res = bw.URLParamPack.apply(null, test.args);
435
- assert.deepEqual(res, test.expected);
436
- });
437
- });
438
- });
439
- //====================================================================================
440
- describe("#htmlSafeStr (string) -encodes chars such as & < > ' etc to HTML safe equiv. also handles spaces, linefeeds and tabs", function() {
441
- /**
442
- see if a URL has a hash string at the end
443
- */
444
- var tests = [
445
- {args: ["<>& x\tx\nabc"], expected: "&lt;&gt;&amp; x&nbsp;&nbsp;&nbsp;&nbsp;x<br>abc"},
446
- {args: ["abcdefghijklmopqurstuvwxyz1234567890-=_+[]{}|;',./?"], expected: "abcdefghijklmopqurstuvwxyz1234567890-=_+[]{}|;&#039;,./?"}
447
- ];
448
-
449
-
450
- tests.forEach(function(test) {
451
- it("bw.htmlSafeStr " + test.args.length + "args", function() {
452
- var res = bw.htmlSafeStr.apply(null, test.args);
453
- assert.deepEqual(res, test.expected);
454
- });
455
- });
456
- });
457
- //====================================================================================
458
- describe("#htmlJSON(any object) -encodes an object to viewable HTML", function() {
459
- /**
460
-
461
- */
462
- var tests = [
463
- {args: ["123#123"], expected: `<pre style='white-space:pre-wrap;'><span style="color:purple">"123#123"</span></pre>`},
464
- {args: [{1:2,3:4,5:{a:1,b:3},c:[2,3,4,{5:"abc"},6]}], expected:
465
- //yay for template strings!
466
- `<pre style='white-space:pre-wrap;'>{
467
- <span style="color:red">"1":</span> <span style="color:green">2</span>,
468
- <span style="color:red">"3":</span> <span style="color:green">4</span>,
469
- <span style="color:red">"5":</span> {
470
- <span style="color:red">"a":</span> <span style="color:green">1</span>,
471
- <span style="color:red">"b":</span> <span style="color:green">3</span>
472
- },
473
- <span style="color:red">"c":</span> [
474
- <span style="color:green">2</span>,
475
- <span style="color:green">3</span>,
476
- <span style="color:green">4</span>,
477
- {
478
- <span style="color:red">"5":</span> <span style="color:purple">"abc"</span>
479
- },
480
- <span style="color:green">6</span>
481
- ]
482
- }</pre>`}
483
- ];
484
-
485
-
486
- tests.forEach(function(test) {
487
- it("bw.htmlJSON " + test.args.length + "args", function() {
488
- var res = bw.htmlJSON.apply(null, test.args);
489
- assert.deepEqual(res, test.expected);
490
- });
491
- });
492
- });
493
- //====================================================================================
494
-
495
- describe("#makeCSS()", function() {
496
- /**
497
- makeCSS
498
- */
499
- `
500
- cssData = "h2 {color:blue;}" // string as full rule (all correctness is on the caller)
501
- cssData = ["h2 {color:blue;}"] // array entry but single string
502
- cssData = ["h2 {color:blue}", "div {width:30px}"] // 2 entries, both strings
503
- cssData = [["h2","color:blue"]] // array of rules (here length 1 rule)
504
- cssData = [["h2","color:blue"], ["h3", "font-color:red"]] // array of rules
505
- cssData = [
506
- [["h2","h4"], "color:blue"], // array or selectors, string for rule
507
- ["h3", "color:red"] // string for selector, string for rule
508
- ]
509
- cssData = [
510
- [["h1","div p"],["color:blue","display:block"]], ==> h1, div p {color: blue; diplay:block;}
511
- "h3 {color:red;}", ==> h3 {color: red;}
512
- [["div",".myClass"],"color : red"], ==> div,.myClass {color: red;}
513
- ["p > .myclass", ["color:red","display:block"]] ==> p > .myClass {color: red; display:block;}
514
- ]
515
- cssData = [
516
- [str, {}]
517
- ]
518
- cssData = [
519
- [[selectors], { dict }]
520
- ]
521
- `
522
-
523
- var tests = [
524
- {args: ["h2 {color:blue;}"], expected:"\nh2 {color:blue;}\n" },
525
- {args: [["h2 {color:blue;}"]], expected:"\nh2 {color:blue;}\n" },
526
- {args: [["h2 {color:blue}", "div {width:30px}"]], expected:"\nh2 {color:blue}\ndiv {width:30px}\n" },
527
- {args: [[["h2","color:blue"]]], expected:"\nh2 {color:blue}\n\n"},
528
- {args: [[[["h2","h4"], "color:blue"],["h3", "color:red"]]], expected: "\nh2, h4 {color:blue}\n\nh3 {color:red}\n\n"},
529
- {args: [
530
- [
531
- [["h1","div p"],["color: blue","display: block"]],
532
- "h3 {color: red;}",
533
- [["div",".myClass"],"color: red;"],
534
- ["p > .myClass", ["color: red","display: block"]]
535
- ]
536
- ], expected: "\nh1, div p {color: blue; display: block;}\n\nh3 {color: red;}\ndiv, .myClass {color: red;}\n\np > .myClass {color: red; display: block;}\n\n"
537
- },
538
- {args: [
539
- [[".myclass", {color:"red", "font-weight":700}]]
540
- ], expected :"\n.myclass {color: red; font-weight: 700;}\n\n" },
541
- {args: [
542
- [[[".myclass","div > p"], {color:"red", "font-weight":700}]]
543
- ], expected :"\n.myclass, div > p {color: red; font-weight: 700;}\n\n" }
544
-
545
- ];
546
-
547
- tests.forEach(function(test) {
548
- it("bw.makeCSS" + test.args.length + "args", function() {
549
- var res = bw.makeCSS.apply(null, test.args);
550
- assert.deepEqual(res,test.expected);
551
- });
552
- });
553
- });
554
- //====================================================================================
555
- describe("#makeCSSRule()",function(){
556
- var tests = [
557
- {args: [
558
- [".myclass", {color:"red", "font-weight":700}],{pretty:false}
559
- ], expected :".myclass{color:red;font-weight:700;}" },
560
- {args: [
561
- [[".myclass","div > p"], {color:"red", "font-weight":700}],{pretty:true}
562
- ], expected :".myclass, div > p\n{\n color: red; \n font-weight: 700; \n}\n" }
563
- ];
564
-
565
- tests.forEach(function(test) {
566
- it("bw.makeCSSRule" + test.args.length + "args", function() {
567
- var res = bw.makeCSSRule.apply(null, test.args);
568
- assert.deepEqual(res,test.expected);
569
- });
570
- });
571
- });
572
-
573
- //====================================================================================
574
- describe("#clearTimer()", function() {
575
- /**
576
- test conversion of RGB style colors to HSL
577
- */
578
- var tests = [
579
- {args: [], expected:true },
580
- {args: ["clearTimerMsg"], expected:true },
581
- ];
582
- bw.logExport({clear:true})
583
-
584
- tests.forEach(function(test) {
585
- it("bw.clearTimer " + test.args.length + "args", function() {
586
- var ref = bw.logExport()[1][1];
587
- var res = bw.clearTimer.apply(null, test.args);
588
- assert.equal((res-ref) < 500,true);
589
- if (test.args[0]=="clearTimerMsg")
590
- assert.equal(test.args[0],bw.logExport()[2][1]);
591
- });
592
- });
593
- });
594
-
595
- // ================================================================
596
- describe("#htmlTable()", function() {
597
- /**
598
- gen HTML table from simple array
599
- */
600
- var tests = [
601
- {args: [[[1,2,3],[2,3,4]]], expected: "<table class=\"bw-table bw-table-stripe\" ><thead><tr><th>1</th><th>2</th><th>3</th></tr></thead><tbody><tr><td>2</td><td>3</td><td>4</td></tr></tbody></table>" }
602
-
603
- ];
604
-
605
- tests.forEach(function(test) {
606
- it("bw.htmlTable " + test.args.length + "args", function() {
607
- var res = bw.htmlTable.apply(null, test.args);
608
- assert.deepEqual(res, test.expected);
609
- });
610
- });
611
-
612
- });
613
- // ================================================================
614
- describe("#naturalCompare()", function() {
615
- /**
616
- sorting function for strings and nums in HTML table other array sorts
617
- */
618
- var tests = [
619
- {args: [-2,2], expected: -1 },
620
- {args: [2,-2], expected: 1 },
621
- {args: ["abc",-2], expected: +1 },
622
- {args: ["abc","def"], expected: -1 },
623
- {args: ["abc","abc"], expected: 0 }
624
- ];
625
-
626
- tests.forEach(function(test) {
627
- it("bw.naturalCompare " + test.args.length + "args", function() {
628
- var res = bw.naturalCompare.apply(null, test.args);
629
- assert.equal(res, test.expected);
630
- });
631
- });
632
-
633
- var test2 = [
634
- {args: [-2,3,"-3","3",0,"1xx","11xx","10xx",9], expected: ["-3", -2, 0, "1xx", 3, "3", 9, "10xx", "11xx"]}
635
- ];
636
-
637
- test2.forEach(function(test) {
638
- it("bw.naturalCompare :: full array " + test.args.length + " args", function() {
639
- assert.deepEqual(test.args.sort(bw.naturalCompare),test.expected)
640
-
641
- });
642
- });
643
-
644
-
645
- });
646
- // ================================================================
647
-
648
- /*
649
-
650
- */
651
- describe("#bw.DOM())", function() {
652
- /**
653
- bw.DOM checks
654
-
655
- const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
656
- console.log(dom.window.document.querySelector("p").textContent);
657
- const { window } = new JSDOM(`...`);
658
- // or even
659
- const { document } = (new JSDOM(`...`)).window;
660
- */
661
- var el = document.createElement("div");
662
- el.innerHTML =
663
- `
664
- <span id="span1">this is a test..</span>
665
- <span class=".myspan">span2 content</span>
666
- `
667
- document.getElementsByTagName("body")[0].appendChild(el);
668
- it("bw.DOM test " , function() {
669
-
670
- var res = bw.DOM("span")[0];
671
- res.innerHTML ="test stuff";
672
- assert.equal(res.innerHTML, document.getElementsByTagName("span")[0].innerHTML);
673
- });
674
-
675
- });
676
-
677
- // ================================================================
678
- describe("#loremIpsum", function() {
679
- /**
680
- test docString raw etractor. Note this function does not parse the doc string it just returns an array of valid doc strings from the supplied string.
681
- This can be used on functions or objects via the toString() operator.
682
-
683
- e.g. var myFunction = function( .... ) { ..... function body }
684
-
685
- bitwrench.docString(myFunction.toString()) ==> returns any doc strings inside.
686
- */
687
- var tests = [
688
- {args: [25], expected: "Lorem ipsum dolor sit ame"},
689
- {args: [25,1], expected: "Orem ipsum dolor sit amet"},
690
- {args: [25,5,1], expected: "Mipsum dolor sit amet, co"},
691
- {args: [25,5,0], expected: " ipsum dolor sit amet, co"},
692
- {args: [2000,5,1], expected: "Mipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo."}
693
-
694
- ];
695
-
696
- tests.forEach(function(test) {
697
- it("bw.loremIpsum " + test.args.length + "args", function() {
698
- var res = bw.loremIpsum.apply(null, test.args);
699
- assert.deepEqual(res, test.expected);
700
- });
701
- });
702
- });
703
-
704
- // ================================================================
705
- describe("#docString", function() {
706
- /**
707
- test docString raw etractor. Note this function does not parse the doc string it just returns an array of valid doc strings from the supplied string.
708
- This can be used on functions or objects via the toString() operator.
709
-
710
- e.g. var myFunction = function( .... ) { ..... function body }
711
-
712
- bitwrench.docString(myFunction.toString()) ==> returns any doc strings inside.
713
- */
714
- var tests = [
715
- {args: ["this is not a docstring"], expected: []},
716
- {args: ["/** this is a test */ /* foo*/ /** another test */"], expected: [" this is a test ", " another test "] }
717
-
718
- ];
719
-
720
- tests.forEach(function(test) {
721
- it("bw.docString (docString extractor) " + test.args.length + "args", function() {
722
- var res = bw.docString.apply(null, test.args);
723
- assert.deepEqual(res, test.expected);
724
- });
725
- });
726
- });
727
- // ================================================================
728
- describe("#docStringParse", function() {
729
- var tests = [
730
- {args: ["/** This is a test \n*/"], expected: [{source: " This is a test ", field: "", types: "", name: "", description: ""}]}
731
- ];
732
-
733
- tests.forEach(function(test) {
734
- it("bw.docStringParse (jsdoc comment parser) " + test.args.length + " args", function() {
735
- var res = bw.docStringParse.apply(null, test.args);
736
- assert.deepEqual(res, test.expected);
737
- });
738
- });
739
-
740
- });
741
- // ================================================================
742
- describe("#isHexStr(str) return whether a string is hexadecimal number (returns number of hex digits if true)", function() {
743
- var tests = [
744
- {args: ["123abc"], expected: 6},
745
- {args: ["123abc-23","#-"], expected: 8},
746
- {args: ["123zabc-23","-"], expected: false}
747
- ];
748
-
749
- tests.forEach(function(test) {
750
- it("bw.isHexStr " + test.args.length + " args", function() {
751
- var res = bw.isHexStr.apply(null, test.args);
752
- assert.deepEqual(res, test.expected);
753
- });
754
- });
755
-
756
- });
757
- // ================================================================
758
- describe("#fixNum(num,sf) trims a number to sf number of digits ", function() {
759
- var tests = [
760
- {args: [123.345,2], expected: 123.34},
761
- {args: [-345.345,1], expected: -345.3},
762
- {args: [345,-1], expected: 340}
763
- ];
764
-
765
- tests.forEach(function(test) {
766
- it("bw.fixNum " + test.args.length + " args", function() {
767
- var res = bw.fixNum.apply(null, test.args);
768
- assert.deepEqual(res, test.expected);
769
- });
770
- });
771
-
772
- });
773
- // ================================================================
774
- describe("#multiArray() creates a multiDim array ", function() {
775
- var tests = [
776
- {args: [2,[2,3]], expected: [[2,2,2],[2,2,2]]},
777
- {args: ["test",[3,2]], expected: [["test","test"],["test","test"],["test","test"]]},
778
- {args: [function(){return 3;},[3,2]], expected: [[3,3],[3,3],[3,3]]}
779
- ];
780
-
781
- tests.forEach(function(test) {
782
- it("bw.multiArray " + test.args.length + " args", function() {
783
- var res = bw.multiArray.apply(null, test.args);
784
- assert.deepEqual(res, test.expected);
785
- });
786
- });
787
-
788
- });
789
- // ================================================================
790
- describe("#clip(x,lo,hi) clips a number between 2 values ", function() {
791
- var tests = [
792
- {args: [2,-4,5], expected: 2},
793
- {args: [-10,-4,5], expected: -4},
794
- {args: [10,-4,5], expected: 5},
795
- {args: [[1,4,8,35], 2, 20], expected: [2,4,8,20]}
796
- ];
797
-
798
- tests.forEach(function(test) {
799
- it("bw.clip " + test.args.length + " args", function() {
800
- var res = bw.clip.apply(null, test.args);
801
- assert.deepEqual(res, test.expected);
802
- });
803
- });
804
- });
805
-
806
- // ================================================================
807
- describe("#mapScale(x,inLo,inHi,outLo,OutHi,opts) scales a number btw 2 values ", function() {
808
- var tests = [
809
- {args: [1,0,10,100,200], expected: 110},
810
- {args: [[1,2,3],0,10,100,200], expected: [110,120,130]},
811
- {args: [22,20,40,200,400,{expScale: 2.0}], expected: 262.005},
812
- {args: [-22,20,40,200,400,{expScale: 3.0,clip:true}], expected: 200.081}
813
- ];
814
-
815
- tests.forEach(function(test) {
816
- it("bw.mapScale " + test.args.length + " args", function() {
817
- var res = bw.mapScale.apply(null, test.args);
818
- res = typeof res == "number" ? bw.fixNum(res,3) : res.map(function(x){return bw.fixNum(x,3)});
819
- assert.deepEqual(res, test.expected);
820
- });
821
- });
822
- });
823
- // ================================================================
824
- describe("#padNum(x,width,padOpts", function() {
825
- var tests = [
826
- {args: [123,5], expected: " 123"},
827
- {args: [1234,5], expected: " 1234"},
828
- {args: [123,5, {pad:"x"}], expected: "xx123"},
829
- {args: ["abc",5, {pad:"x"}], expected: "xxabc"}
830
- ];
831
-
832
- tests.forEach(function(test) {
833
- it("bw.padNum " + test.args.length + " args", function() {
834
- var res = bw.padNum.apply(null, test.args);
835
- assert.deepEqual(res, test.expected);
836
- });
837
- });
838
- });
839
-
840
- // ================================================================
841
- describe("#bw.trim(str,dir)", function() {
842
- var tests = [
843
- {args: [" abc "], expected: "abc"},
844
- {args: [" abc ","left"], expected: "abc "},
845
- {args: [" abc ","right"], expected: " abc"},
846
- {args: [" abc ","both"], expected: "abc"},
847
- {args: [" abc ","none"], expected: " abc "}
848
-
849
- ];
850
-
851
- tests.forEach(function(test) {
852
- it("bw.trim " + test.args.length + " args", function() {
853
- var res = bw.trim.apply(null, test.args);
854
- assert.deepEqual(res, test.expected);
855
- });
856
- });
857
- });
858
- // ================================================================
859
- describe("#padString(x,width,padOpts", function() {
860
- var tests = [
861
- {args: ["this is it",20,"left"] , expected: " this is it"},
862
- {args: ["this is it",20,"right"], expected: "this is it "},
863
- {args: ["this is it",20,"center"], expected: " this is it "},
864
- {args: ["this is it",20,"center",{trimDir:"both",pad:"x"}], expected: "xxxxxthis is itxxxxx"},
865
- ];
866
-
867
- tests.forEach(function(test) {
868
- it("bw.padString " + test.args.length + " args", function() {
869
- var res = bw.padString.apply(null, test.args);
870
- assert.deepEqual(res, test.expected);
871
- });
872
- });
873
- });
874
- // ================================================================
875
- describe("#random(x,lo,hi,opts) - generate a random number between lo, hi", function() {
876
-
877
-
878
- it("bw.random () ", function() {
879
- var res = bw.random();
880
- assert( (res >= 0 && res <=100));
881
- });
882
- it("bw.random (20,30) ", function() {
883
- var res = bw.random(20,30);
884
- assert( (res >= 20 && res <=30));
885
- });
886
- it("bw.random (0,1,{setType:'float'}) ", function() {
887
- var res = bw.random(0,1,{setType:"float"});
888
- assert( (res >= 0 && res <=1));
889
- });
890
- it("bw.random (0,1,{setType:'float'}) ", function() {
891
- var res = bw.random(30,40,{setType:"int",dims:[2,2]});
892
- res = [res[0][0], res[0][1], res[1][0], res[1][1]];
893
- assert( res.filter(x => (x>40) ||(x< 30)).length == 0);
894
- });
895
- });
896
-
897
- // ================================================================
898
-
899
- describe("#prandom(x,lo,hi,opts) - generate a random number between lo, hi, using a seed (repeated able random #s)", function() {
900
-
901
-
902
- it("bw.prandom () ", function() {
903
- var res = bw.random();
904
- assert( res != 73);
905
- });
906
- it("bw.prandom (20,30) ", function() {
907
- var res = bw.prandom(20,30);
908
- assert( (res >= 20 && res <=30));
909
- });
910
- it("bw.prandom (0,1,10,{setType:'float'}) ", function() {
911
- var res = bw.prandom(0,1,{setType:"float"});
912
- assert( (res >= 0 && res <=1));
913
- });
914
- it("bw.random (0,1,{setType:'float'}) ", function() {
915
- var res = bw.prandom(30,40,10,{setType:"int",dims:[2,2]});
916
- res = [res[0][0], res[0][1], res[1][0], res[1][1]];
917
- assert( res.filter(x => (x>40) ||(x< 30)).length == 0);
918
- });
919
- });
920
-
921
- // ================================================================
922
- describe("#hashFnv32a(str, seed, returnAsHexStr) - generate a quick checksum (Fnv32a) of a string", function() {
923
- var tests = [
924
- {args: ["this is it"] , expected: 3562000208},
925
- {args: ["this is it",32] , expected: 2503917409},
926
- {args: ["this is it",33] , expected: 857015836},
927
- {args: ["this is it",32,true] , expected: "953ebf61"}
928
-
929
- ];
930
-
931
- tests.forEach(function(test) {
932
- it("bw.hashFnv32a " + test.args.length + " args", function() {
933
- var res = bw.hashFnv32a.apply(null, test.args);
934
- assert.deepEqual(res, test.expected);
935
- });
936
- });
937
-
938
- });
939
- // ================================================================
940
- describe("#CSSSimpleStyles (appendToHead, options) create the default bitwrench CSS styles, classes", function() {
941
- var tests = [
942
- {args: [] ,
943
- expected:
944
-
945
- `
946
- *{box-sizing:border-box;}
947
- .bw-def-page-setup{height:100%;width:90%;margin:0 auto;padding-left:2%;padding-right:2%;left:0;top:1%;box-sizing:border-box;}
948
- .bw-font-serif{font-family:Times New Roman, Times, serif;}
949
- .bw-font-sans-serif{font-family:Arial, Helvetica, sans-serif;}
950
-
951
- .bw-left{text-align:left;}
952
- .bw-right{text-align:right;}
953
- .bw-center{text-align:center;margin:0 auto;}
954
- .bw-justify{text-align:justify;}
955
- .bw-code{font-family:monospace;white-space:pre-wrap;}
956
- .bw-pad1{padding-left:1%;padding-right:1%;}
957
-
958
- .bw-table{border-collapse:collapse;border-spacing:0;border:1px solid #444;}
959
- .bw-table th{background-color:#bbb;padding:4px;border:1px solid #444;}
960
- .bw-table td{padding:4px;border:1px solid #444;}
961
- .bw-table-stripe tr:nth-child(even){background-color:#f0f0f0;}
962
- .bw-table tr td:first-child{font-weight:700;}
963
- .bw-table-border-round{border-radius:2px;}
964
- .bw-table-sort-upa::after{content:\"\\2191\";}
965
- .bw-table-sort-dna::after{content:\"\\2193\";}
966
- .bw-table-sort-xxa::after{content:\"\\00a0\";}
967
-
968
- .bw-tab-item-list{margin:0;padding-inline-start:0;}
969
- .bw-tab-item{display:inline;padding-top:0.5em;padding-left:0.75em;padding-right:0.75em;border-top-right-radius:7px;border-top-left-radius:7px;}
970
- .bw-tab-active{font-weight:700;}
971
- .bw-tab:hover{cursor:pointer;font-weight:700;}
972
- .bw-tab-content-list{margin:0;padding-top:0.0em;}
973
- .bw-tab-content{display:none;border-radius:0;}
974
- .bw-tab-content, .bw-tab-active{background-color:#ddd;padding:0.5em;}
975
-
976
- .bw-accordian-container > div{padding:0.5em;}
977
-
978
- .bw-container{margin:0 auto;}
979
- .bw-row{width:100%;display:block;}
980
- .bw-row [class^=\"bw-col\"]{float:left;}
981
- .bw-row::after{content:\"\";display:table;clear:both;}
982
- .bw-box-1{padding-top:10px;padding-bottom:10px;border-radius:8px;}
983
-
984
- .bw-sign{position:inherit;display:table;height:100%;width:100%;}
985
- .bw-sign > div{display:table-cell;vertical-align:middle;}
986
- .bw-sign > div > div{text-align:center;}
987
-
988
- .bw-hide{display:none;}
989
- .bw-show{display:block;}
990
- .bw-h1{font-size:2.312rem;}
991
- .bw-h2{font-size:1.965rem;}
992
- .bw-h3{font-size:1.67rem;}
993
- .bw-h4{font-size:1.419rem;}
994
- .bw-h5{font-size:1.206rem;}
995
- .bw-h6{font-size:1.025rem;}
996
-
997
- .bw-col-1{width:8.333%;}
998
- .bw-col-2{width:16.666%;}
999
- .bw-col-3{width:25%;}
1000
- .bw-col-4{width:33.333%;}
1001
- .bw-col-5{width:41.666%;}
1002
- .bw-col-6{width:50%;}
1003
- .bw-col-7{width:58.333%;}
1004
- .bw-col-8{width:66.666%;}
1005
- .bw-col-9{width:75%;}
1006
- .bw-col-10{width:83.333%;}
1007
- .bw-col-11{width:91.666%;}
1008
- .bw-col-12{width:100%;}
1009
-
1010
- .bw-color-color {color:#000}
1011
- .bw-color-background-color {background-color:#ddd}
1012
- .bw-color-active {active:#222}
1013
- .bw-thm-light
1014
- {
1015
- color: #020202 !important;;
1016
- background-color: #e2e2e2 !important;;
1017
- }
1018
- .bw-thm-dark
1019
- {
1020
- color: #e2e2e2 !important;;
1021
- background-color: #020202 !important;;
1022
- }
1023
- @media only screen and (min-width: 540px) { .bw-def-page-setup { width: 96%; }}
1024
- @media only screen and (min-width: 720px) { .bw-def-page-setup { width: 92%; }}
1025
- @media only screen and (min-width: 960px) { .bw-def-page-setup { width: 88%; }}
1026
- @media only screen and (min-width: 1100px){ .bw-def-page-setup { width: 86%; }}
1027
- @media only screen and (min-width: 1600px){ .bw-def-page-setup { width: 84%; }}
1028
- `
1029
-
1030
-
1031
- }
1032
-
1033
- ];
1034
-
1035
- tests.forEach(function(test) {
1036
- it("CSSSimpleStyles " + test.args.length + " args", function() {
1037
- var res = bw.CSSSimpleStyles.apply(null, test.args);
1038
- assert.deepEqual(res, test.expected);
1039
- });
1040
- });
1041
-
1042
- });
1043
-
1044
- // ================================================================
1045
- describe("#CSSSimpleThemes (index, options) simple styles for live use", function() {
1046
- var tests = [
1047
- {args: [1,false,{}] ,
1048
- expected:
1049
- `*{background-color:#f8f8f8;color:#111;font-family:sans-serif;box-sizing:border-box;}
1050
- body{margin-top:1%;}
1051
- th{background-color:#ddd;}
1052
- tbody tr:nth-child(even){background-color:#ddd;}
1053
- table,td,th{border-collapse:collapse;border:1px solid #111;}
1054
- td,th{padding:4px;}
1055
- div,body,button,table,input{border-radius:2px;}`
1056
- }
1057
-
1058
- ];
1059
-
1060
- tests.forEach(function(test) {
1061
- it("CSSSimpleThemes " + test.args.length + " args", function() {
1062
- var res = bw.CSSSimpleThemes.apply(null, test.args);
1063
- assert.deepEqual(res, test.expected);
1064
- });
1065
- });
1066
-
1067
- });
1068
-
1069
- // ================================================================
1070
- describe("#version() returns version info at runtime", function() {
1071
- it("version() " + 0 + " args", function() {
1072
- var res = bw.version();
1073
- assert(res.version.split(".").length>=3);
1074
- assert((res.hasOwnProperty("about")));
1075
- assert((res.hasOwnProperty("copy")));
1076
- assert((res.hasOwnProperty("url")));
1077
- assert.equal(res.license , "BSD-2-Clause");
1078
-
1079
- });
1080
- });
1081
-