govuk_publishing_components 16.29.0 → 17.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +46 -23
  3. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +8 -2
  4. data/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js +101 -21
  5. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +9 -2
  6. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +0 -1
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +4 -6
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +36 -5
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +14 -14
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_highlight-boxes.scss +23 -23
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +8 -8
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_lead-paragraph.scss +2 -2
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +8 -8
  14. data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +10 -10
  15. data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +11 -14
  16. data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +14 -14
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +8 -8
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +7 -7
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +20 -16
  20. data/app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss +4 -4
  21. data/app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss +5 -5
  22. data/app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-list.scss +5 -5
  23. data/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +8 -8
  24. data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss +1 -1
  25. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +33 -25
  26. data/app/views/govuk_publishing_components/components/_error_summary.html.erb +4 -2
  27. data/app/views/govuk_publishing_components/components/_notice.html.erb +4 -1
  28. data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +2 -0
  29. data/app/views/govuk_publishing_components/components/docs/error_summary.yml +6 -0
  30. data/app/views/govuk_publishing_components/components/docs/notice.yml +6 -0
  31. data/app/views/govuk_publishing_components/components/docs/success_alert.yml +1 -1
  32. data/lib/govuk_publishing_components/presenters/cookie_banner_helper.rb +0 -4
  33. data/lib/govuk_publishing_components/version.rb +1 -1
  34. data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js +1 -1
  35. data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js.map +1 -1
  36. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.preact.min.js +1 -1
  37. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.preact.min.js.map +1 -1
  38. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.react.min.js +1 -1
  39. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.react.min.js.map +1 -1
  40. data/node_modules/accessible-autocomplete/package.json +3 -3
  41. data/node_modules/accessible-autocomplete/src/autocomplete.js +4 -2
  42. data/node_modules/accessible-autocomplete/src/wrapper.js +5 -1
  43. data/node_modules/d/CHANGELOG.md +9 -0
  44. data/node_modules/d/CHANGES +4 -0
  45. data/node_modules/d/LICENSE +12 -16
  46. data/node_modules/d/README.md +49 -19
  47. data/node_modules/d/auto-bind.js +11 -10
  48. data/node_modules/d/index.js +23 -24
  49. data/node_modules/d/lazy.js +21 -23
  50. data/node_modules/d/package.json +63 -16
  51. data/node_modules/d/test/auto-bind.js +6 -7
  52. data/node_modules/d/test/index.js +78 -51
  53. data/node_modules/d/test/lazy.js +65 -50
  54. data/node_modules/es6-weak-map/CHANGELOG.md +5 -0
  55. data/node_modules/es6-weak-map/LICENSE +12 -16
  56. data/node_modules/es6-weak-map/README.md +34 -19
  57. data/node_modules/es6-weak-map/implement.js +9 -5
  58. data/node_modules/es6-weak-map/index.js +2 -2
  59. data/node_modules/es6-weak-map/is-implemented.js +10 -9
  60. data/node_modules/es6-weak-map/is-native-implemented.js +3 -3
  61. data/node_modules/es6-weak-map/is-weak-map.js +8 -8
  62. data/node_modules/es6-weak-map/package.json +30 -19
  63. data/node_modules/es6-weak-map/polyfill.js +31 -32
  64. data/node_modules/es6-weak-map/test/implement.js +4 -2
  65. data/node_modules/es6-weak-map/test/index.js +4 -3
  66. data/node_modules/es6-weak-map/test/is-implemented.js +9 -8
  67. data/node_modules/es6-weak-map/test/is-native-implemented.js +4 -2
  68. data/node_modules/es6-weak-map/test/is-weak-map.js +4 -4
  69. data/node_modules/es6-weak-map/test/polyfill.js +13 -13
  70. data/node_modules/es6-weak-map/test/valid-weak-map.js +22 -9
  71. data/node_modules/es6-weak-map/valid-weak-map.js +5 -5
  72. data/node_modules/resolve/lib/async.js +1 -1
  73. data/node_modules/resolve/lib/node-modules-paths.js +1 -1
  74. data/node_modules/resolve/lib/sync.js +0 -2
  75. data/node_modules/resolve/package.json +13 -13
  76. data/node_modules/resolve/test/node-modules-paths.js +0 -22
  77. data/node_modules/resolve/test/resolver.js +11 -0
  78. data/node_modules/resolve/test/resolver_sync.js +11 -0
  79. data/node_modules/standard/node_modules/ms/index.js +2 -2
  80. data/node_modules/standard/node_modules/ms/package.json +205 -16
  81. data/node_modules/standard/node_modules/ms/readme.md +1 -1
  82. data/node_modules/type/CHANGELOG.md +62 -0
  83. data/node_modules/type/README.md +743 -0
  84. data/node_modules/type/array-length/coerce.js +10 -0
  85. data/node_modules/type/array-length/ensure.js +10 -0
  86. data/node_modules/type/array-like/ensure.js +9 -0
  87. data/node_modules/type/array-like/is.js +21 -0
  88. data/node_modules/type/array/ensure.js +9 -0
  89. data/node_modules/type/array/is.js +27 -0
  90. data/node_modules/type/date/ensure.js +9 -0
  91. data/node_modules/type/date/is.js +26 -0
  92. data/node_modules/type/error/ensure.js +9 -0
  93. data/node_modules/type/error/is.js +24 -0
  94. data/node_modules/type/finite/coerce.js +8 -0
  95. data/node_modules/type/finite/ensure.js +10 -0
  96. data/node_modules/type/function/ensure.js +9 -0
  97. data/node_modules/type/function/is.js +19 -0
  98. data/node_modules/type/integer/coerce.js +11 -0
  99. data/node_modules/type/integer/ensure.js +10 -0
  100. data/node_modules/type/iterable/ensure.js +9 -0
  101. data/node_modules/type/iterable/is.js +20 -0
  102. data/node_modules/type/lib/is-to-string-tag-supported.js +3 -0
  103. data/node_modules/type/lib/resolve-exception.js +21 -0
  104. data/node_modules/type/lib/safe-to-string.js +10 -0
  105. data/node_modules/type/lib/to-short-string.js +29 -0
  106. data/node_modules/type/natural-number/coerce.js +10 -0
  107. data/node_modules/type/natural-number/ensure.js +10 -0
  108. data/node_modules/type/number/coerce.js +14 -0
  109. data/node_modules/type/number/ensure.js +10 -0
  110. data/node_modules/type/object/ensure.js +9 -0
  111. data/node_modules/type/object/is.js +11 -0
  112. data/node_modules/type/package.json +159 -0
  113. data/node_modules/type/plain-function/ensure.js +9 -0
  114. data/node_modules/type/plain-function/is.js +11 -0
  115. data/node_modules/type/plain-object/ensure.js +9 -0
  116. data/node_modules/type/plain-object/is.js +28 -0
  117. data/node_modules/type/promise/ensure.js +9 -0
  118. data/node_modules/type/promise/is.js +27 -0
  119. data/node_modules/type/prototype/is.js +13 -0
  120. data/node_modules/type/reg-exp/ensure.js +9 -0
  121. data/node_modules/type/reg-exp/is.js +37 -0
  122. data/node_modules/type/safe-integer/coerce.js +13 -0
  123. data/node_modules/type/safe-integer/ensure.js +10 -0
  124. data/node_modules/type/string/coerce.js +23 -0
  125. data/node_modules/type/string/ensure.js +10 -0
  126. data/node_modules/type/test/_lib/arrow-function-if-supported.js +4 -0
  127. data/node_modules/type/test/_lib/class-if-supported.js +4 -0
  128. data/node_modules/type/test/array-length/coerce.js +47 -0
  129. data/node_modules/type/test/array-length/ensure.js +19 -0
  130. data/node_modules/type/test/array-like/ensure.js +24 -0
  131. data/node_modules/type/test/array-like/is.js +47 -0
  132. data/node_modules/type/test/array/ensure.js +20 -0
  133. data/node_modules/type/test/array/is.js +41 -0
  134. data/node_modules/type/test/date/ensure.js +20 -0
  135. data/node_modules/type/test/date/is.js +46 -0
  136. data/node_modules/type/test/error/ensure.js +20 -0
  137. data/node_modules/type/test/error/is.js +42 -0
  138. data/node_modules/type/test/finite/coerce.js +40 -0
  139. data/node_modules/type/test/finite/ensure.js +17 -0
  140. data/node_modules/type/test/function/ensure.js +20 -0
  141. data/node_modules/type/test/function/is.js +46 -0
  142. data/node_modules/type/test/integer/coerce.js +49 -0
  143. data/node_modules/type/test/integer/ensure.js +17 -0
  144. data/node_modules/type/test/iterable/ensure.js +24 -0
  145. data/node_modules/type/test/iterable/is.js +50 -0
  146. data/node_modules/type/test/lib/is-to-string-tag-supported.js +10 -0
  147. data/node_modules/type/test/lib/resolve-exception.js +39 -0
  148. data/node_modules/type/test/lib/safe-to-string.js +32 -0
  149. data/node_modules/type/test/lib/to-short-string.js +41 -0
  150. data/node_modules/type/test/natural-number/coerce.js +47 -0
  151. data/node_modules/type/test/natural-number/ensure.js +19 -0
  152. data/node_modules/type/test/number/coerce.js +40 -0
  153. data/node_modules/type/test/number/ensure.js +17 -0
  154. data/node_modules/type/test/object/ensure.js +20 -0
  155. data/node_modules/type/test/object/is.js +30 -0
  156. data/node_modules/type/test/plain-function/ensure.js +20 -0
  157. data/node_modules/type/test/plain-function/is.js +56 -0
  158. data/node_modules/type/test/plain-object/ensure.js +20 -0
  159. data/node_modules/type/test/plain-object/is.js +47 -0
  160. data/node_modules/type/test/promise/ensure.js +20 -0
  161. data/node_modules/type/test/promise/is.js +39 -0
  162. data/node_modules/type/test/prototype/is.js +39 -0
  163. data/node_modules/type/test/reg-exp/ensure.js +20 -0
  164. data/node_modules/type/test/reg-exp/is.js +47 -0
  165. data/node_modules/type/test/safe-integer/coerce.js +49 -0
  166. data/node_modules/type/test/safe-integer/ensure.js +19 -0
  167. data/node_modules/type/test/string/coerce.js +36 -0
  168. data/node_modules/type/test/string/ensure.js +17 -0
  169. data/node_modules/type/test/thenable/ensure.js +20 -0
  170. data/node_modules/type/test/thenable/is.js +44 -0
  171. data/node_modules/type/test/time-value/coerce.js +47 -0
  172. data/node_modules/type/test/time-value/ensure.js +17 -0
  173. data/node_modules/type/test/value/ensure.js +20 -0
  174. data/node_modules/type/test/value/is.js +29 -0
  175. data/node_modules/type/thenable/ensure.js +9 -0
  176. data/node_modules/type/thenable/is.js +9 -0
  177. data/node_modules/type/time-value/coerce.js +12 -0
  178. data/node_modules/type/time-value/ensure.js +10 -0
  179. data/node_modules/type/value/ensure.js +9 -0
  180. data/node_modules/type/value/is.js +6 -0
  181. metadata +118 -21
  182. data/app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-navigation.scss +0 -94
  183. data/node_modules/resolve/reaf +0 -0
  184. data/node_modules/resolve/test/shadowed_core.js +0 -38
  185. data/node_modules/resolve/test/shadowed_core/node_modules/util/index.js +0 -0
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ var resolveException = require("../lib/resolve-exception")
4
+ , is = require("./is");
5
+
6
+ module.exports = function (value/*, options*/) {
7
+ if (is(value)) return value;
8
+ return resolveException(value, "%v is not a plain function", arguments[1]);
9
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ var isFunction = require("../function/is");
4
+
5
+ var classRe = /^\s*class[\s{/}]/, functionToString = Function.prototype.toString;
6
+
7
+ module.exports = function (value) {
8
+ if (!isFunction(value)) return false;
9
+ if (classRe.test(functionToString.call(value))) return false;
10
+ return true;
11
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ var resolveException = require("../lib/resolve-exception")
4
+ , is = require("./is");
5
+
6
+ module.exports = function (value/*, options*/) {
7
+ if (is(value)) return value;
8
+ return resolveException(value, "%v is not a plain object", arguments[1]);
9
+ };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var isObject = require("../object/is")
4
+ , isPrototype = require("../prototype/is");
5
+
6
+ var getPrototypeOf;
7
+ if (typeof Object.getPrototypeOf === "function") {
8
+ getPrototypeOf = Object.getPrototypeOf;
9
+ } else if ({}.__proto__ === Object.prototype) {
10
+ getPrototypeOf = function (object) { return object.__proto__; };
11
+ }
12
+
13
+ module.exports = function (value) {
14
+ if (!isObject(value)) return false;
15
+ var prototype;
16
+ if (getPrototypeOf) {
17
+ prototype = getPrototypeOf(value);
18
+ } else {
19
+ try {
20
+ var valueConstructor = value.constructor;
21
+ if (valueConstructor) prototype = valueConstructor.prototype;
22
+ } catch (error) {
23
+ return false;
24
+ }
25
+ }
26
+ if (prototype && !hasOwnProperty.call(prototype, "propertyIsEnumerable")) return false;
27
+ return !isPrototype(value);
28
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ var resolveException = require("../lib/resolve-exception")
4
+ , is = require("./is");
5
+
6
+ module.exports = function (value/*, options*/) {
7
+ if (is(value)) return value;
8
+ return resolveException(value, "%v is not a promise", arguments[1]);
9
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var isPrototype = require("../prototype/is");
4
+
5
+ // In theory we could rely on Symbol.toStringTag directly,
6
+ // still early native implementation (e.g. in FF) predated symbols
7
+ var objectToString = Object.prototype.toString
8
+ , objectTaggedString = objectToString.call(Promise.resolve());
9
+
10
+ module.exports = function (value) {
11
+ if (!value) return false;
12
+
13
+ // Sanity check (reject objects which do not expose common Promise interface)
14
+ try {
15
+ if (typeof value.then !== "function") return false;
16
+ if (typeof value["catch"] !== "function") return false;
17
+ } catch (error) {
18
+ return false;
19
+ }
20
+
21
+ // Ensure its native Promise object (has [[PromiseState]] slot)
22
+ // Note: it's not 100% precise as string tag may be overriden
23
+ // and other objects could be hacked to expose it
24
+ if (objectToString.call(value) !== objectTaggedString) return false;
25
+
26
+ return !isPrototype(value);
27
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var isObject = require("../object/is");
4
+
5
+ module.exports = function (value) {
6
+ if (!isObject(value)) return false;
7
+ try {
8
+ if (!value.constructor) return false;
9
+ return value.constructor.prototype === value;
10
+ } catch (error) {
11
+ return false;
12
+ }
13
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ var resolveException = require("../lib/resolve-exception")
4
+ , is = require("./is");
5
+
6
+ module.exports = function (value/*, options*/) {
7
+ if (is(value)) return value;
8
+ return resolveException(value, "%v is not a regular expression object", arguments[1]);
9
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var isToStringTagSupported = require("../lib/is-to-string-tag-supported")
4
+ , isPrototype = require("../prototype/is");
5
+
6
+ var regExpTest = RegExp.prototype.test
7
+ , objectToString = Object.prototype.toString
8
+ , objectTaggedString = objectToString.call(/a/);
9
+
10
+ module.exports = function (value) {
11
+ if (!value) return false;
12
+
13
+ // Sanity check (reject objects which do not expose common RegExp interface)
14
+ if (!hasOwnProperty.call(value, "lastIndex")) return false;
15
+ try {
16
+ if (typeof value.lastIndex !== "number") return false;
17
+ if (typeof value.test !== "function") return false;
18
+ if (typeof value.exec !== "function") return false;
19
+ } catch (error) {
20
+ return false;
21
+ }
22
+
23
+ // Ensure its native RegExp object (has [[RegExpMatcher]] slot)
24
+ if (isToStringTagSupported && typeof value[Symbol.toStringTag] === "string") {
25
+ // Edge case (possibly a regExp with custom Symbol.toStringTag)
26
+ try {
27
+ var lastIndex = value.lastIndex;
28
+ regExpTest.call(value, "");
29
+ if (value.lastIndex !== lastIndex) value.lastIndex = lastIndex;
30
+ return true;
31
+ } catch (error) {
32
+ return false;
33
+ }
34
+ }
35
+ if (objectToString.call(value) !== objectTaggedString) return false;
36
+ return !isPrototype(value);
37
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var coerceToInteger = require("../integer/coerce");
4
+
5
+ var MAX_SAFE_INTEGER = 9007199254740991, MIN_SAFE_INTEGER = -9007199254740991;
6
+
7
+ module.exports = function (value) {
8
+ value = coerceToInteger(value);
9
+ if (!value) return value;
10
+ if (value > MAX_SAFE_INTEGER) return null;
11
+ if (value < MIN_SAFE_INTEGER) return null;
12
+ return value;
13
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ var resolveException = require("../lib/resolve-exception")
4
+ , coerce = require("./coerce");
5
+
6
+ module.exports = function (value/*, options*/) {
7
+ var coerced = coerce(value);
8
+ if (coerced !== null) return coerced;
9
+ return resolveException(value, "%v is not a safe integer", arguments[1]);
10
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var isValue = require("../value/is")
4
+ , isObject = require("../object/is");
5
+
6
+ var objectToString = Object.prototype.toString;
7
+
8
+ module.exports = function (value) {
9
+ if (!isValue(value)) return null;
10
+ if (isObject(value)) {
11
+ // Reject Object.prototype.toString coercion
12
+ var valueToString = value.toString;
13
+ if (typeof valueToString !== "function") return null;
14
+ if (valueToString === objectToString) return null;
15
+ // Note: It can be object coming from other realm, still as there's no ES3 and CSP compliant
16
+ // way to resolve its realm's Object.prototype.toString it's left as not addressed edge case
17
+ }
18
+ try {
19
+ return "" + value; // Ensure implicit coercion
20
+ } catch (error) {
21
+ return null;
22
+ }
23
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ var resolveException = require("../lib/resolve-exception")
4
+ , coerce = require("./coerce");
5
+
6
+ module.exports = function (value/*, options*/) {
7
+ var coerced = coerce(value);
8
+ if (coerced !== null) return coerced;
9
+ return resolveException(value, "%v is not a string", arguments[1]);
10
+ };
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ try { module.exports = eval("(() => {})"); }
4
+ catch (error) {}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ try { module.exports = eval("(class {})"); }
4
+ catch (error) {}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , coerceToArrayLength = require("../../array-length/coerce");
5
+
6
+ describe("array-length/coerce", function () {
7
+ it("Should coerce float", function () {
8
+ assert.equal(coerceToArrayLength(123.123), 123);
9
+ assert.equal(coerceToArrayLength(123.823), 123);
10
+ });
11
+ it("Should coerce string", function () { assert.equal(coerceToArrayLength("12.123"), 12); });
12
+ it("Should coerce booleans", function () { assert.equal(coerceToArrayLength(true), 1); });
13
+ it("Should coerce number objects", function () {
14
+ assert.equal(coerceToArrayLength(new Number(343)), 343);
15
+ });
16
+ it("Should coerce objects", function () {
17
+ assert.equal(coerceToArrayLength({ valueOf: function () { return 23; } }), 23);
18
+ });
19
+ it("Should reject infinite number", function () {
20
+ assert.equal(coerceToArrayLength(Infinity), null);
21
+ });
22
+ it("Should reject number beyond Number.MAX_SAFE_INTEGER", function () {
23
+ assert.equal(coerceToArrayLength(9007199254740992), null);
24
+ });
25
+ it("Should reject negative number", function () {
26
+ assert.equal(coerceToArrayLength(-9), null);
27
+ });
28
+
29
+ it("Should reject NaN", function () { assert.equal(coerceToArrayLength(NaN), null); });
30
+
31
+ if (typeof Object.create === "function") {
32
+ it("Should not coerce objects with no number representation", function () {
33
+ assert.equal(coerceToArrayLength(Object.create(null)), null);
34
+ });
35
+ }
36
+
37
+ it("Should not coerce null", function () { assert.equal(coerceToArrayLength(null), null); });
38
+ it("Should not coerce undefined", function () {
39
+ assert.equal(coerceToArrayLength(undefined), null);
40
+ });
41
+
42
+ if (typeof Symbol === "function") {
43
+ it("Should not coerce symbols", function () {
44
+ assert.equal(coerceToArrayLength(Symbol("foo")), null);
45
+ });
46
+ }
47
+ });
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , ensureArrayLength = require("../../array-length/ensure");
5
+
6
+ describe("array-length/ensure", function () {
7
+ it("Should return coerced value", function () {
8
+ assert.equal(ensureArrayLength("12.23"), 12);
9
+ });
10
+ it("Should crash on no value", function () {
11
+ try {
12
+ ensureArrayLength(-20);
13
+ throw new Error("Unexpected");
14
+ } catch (error) {
15
+ assert.equal(error.name, "TypeError");
16
+ assert.equal(error.message, "-20 is not a valid array length");
17
+ }
18
+ });
19
+ });
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , ensureArrayLike = require("../../array-like/ensure");
5
+
6
+ describe("array-like/ensure", function () {
7
+ it("Should return input value", function () {
8
+ var value = [];
9
+ assert.equal(ensureArrayLike(value), value);
10
+ });
11
+ it("Should allow strings with allowString option", function () {
12
+ var value = "foo";
13
+ assert.equal(ensureArrayLike(value, { allowString: true }), value);
14
+ });
15
+ it("Should crash on invalid value", function () {
16
+ try {
17
+ ensureArrayLike("foo");
18
+ throw new Error("Unexpected");
19
+ } catch (error) {
20
+ assert.equal(error.name, "TypeError");
21
+ assert(error.message.includes("is not an array like value"));
22
+ }
23
+ });
24
+ });
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , isArrayLike = require("../../array-like/is");
5
+
6
+ describe("array-like/is", function () {
7
+ it("Should return true on array", function () { assert.equal(isArrayLike([]), true); });
8
+ it("Should return true on array-like object", function () {
9
+ assert.equal(isArrayLike({ length: 1 }), true);
10
+ });
11
+ it("Should by default return false on string", function () {
12
+ assert.equal(isArrayLike("foo"), false);
13
+ });
14
+ it("Should accept strings if specified", function () {
15
+ assert.equal(isArrayLike("foo", { allowString: true }), true);
16
+ });
17
+
18
+ it("Should return false on objects with negative length", function () {
19
+ assert.equal(isArrayLike({ length: -1 }), false);
20
+ });
21
+
22
+ it("Should return false on plain object", function () {
23
+ assert.equal(isArrayLike({}), false);
24
+ });
25
+ it("Should return false on function", function () {
26
+ assert.equal(isArrayLike(function () { return true; }), false);
27
+ });
28
+
29
+ if (typeof Object.create === "function") {
30
+ it("Should return false on object with no prototype", function () {
31
+ assert.equal(isArrayLike(Object.create(null)), false);
32
+ });
33
+ }
34
+ it("Should return false on number", function () { assert.equal(isArrayLike(123), false); });
35
+ it("Should return false on NaN", function () { assert.equal(isArrayLike(NaN), false); });
36
+ it("Should return false on boolean", function () { assert.equal(isArrayLike(true), false); });
37
+ if (typeof Symbol === "function") {
38
+ it("Should return false on symbol", function () {
39
+ assert.equal(isArrayLike(Symbol("foo")), false);
40
+ });
41
+ }
42
+
43
+ it("Should return false on null", function () { assert.equal(isArrayLike(null), false); });
44
+ it("Should return false on undefined", function () {
45
+ assert.equal(isArrayLike(void 0), false);
46
+ });
47
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , ensureArray = require("../../array/ensure");
5
+
6
+ describe("array/ensure", function () {
7
+ it("Should return input value", function () {
8
+ var value = [];
9
+ assert.equal(ensureArray(value), value);
10
+ });
11
+ it("Should crash on invalid value", function () {
12
+ try {
13
+ ensureArray(null);
14
+ throw new Error("Unexpected");
15
+ } catch (error) {
16
+ assert.equal(error.name, "TypeError");
17
+ assert(error.message.includes("is not an array object"));
18
+ }
19
+ });
20
+ });
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , isArray = require("../../array/is");
5
+
6
+ describe("array/is", function () {
7
+ it("Should return true on array", function () { assert.equal(isArray([]), true); });
8
+
9
+ it("Should return false on array with no common API exposed", function () {
10
+ var value = [];
11
+ value.push = null;
12
+ assert.equal(isArray(value), false);
13
+ });
14
+ it("Should return false on Array.prototype", function () {
15
+ assert.equal(isArray(Array.prototype), false);
16
+ });
17
+
18
+ it("Should return false on plain object", function () { assert.equal(isArray({}), false); });
19
+ it("Should return false on function", function () {
20
+ assert.equal(isArray(function () { return true; }), false);
21
+ });
22
+
23
+ if (typeof Object.create === "function") {
24
+ it("Should return false on object with no prototype", function () {
25
+ assert.equal(isArray(Object.create(null)), false);
26
+ });
27
+ }
28
+ it("Should return false on string", function () { assert.equal(isArray("foo"), false); });
29
+ it("Should return false on empty string", function () { assert.equal(isArray(""), false); });
30
+ it("Should return false on number", function () { assert.equal(isArray(123), false); });
31
+ it("Should return false on NaN", function () { assert.equal(isArray(NaN), false); });
32
+ it("Should return false on boolean", function () { assert.equal(isArray(true), false); });
33
+ if (typeof Symbol === "function") {
34
+ it("Should return false on symbol", function () {
35
+ assert.equal(isArray(Symbol("foo")), false);
36
+ });
37
+ }
38
+
39
+ it("Should return false on null", function () { assert.equal(isArray(null), false); });
40
+ it("Should return false on undefined", function () { assert.equal(isArray(void 0), false); });
41
+ });