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,32 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , safeToString = require("../../lib/safe-to-string");
5
+
6
+ describe("lib/safe-to-string", function () {
7
+ it("Should return input string", function () { assert.equal(safeToString("foo"), "foo"); });
8
+ it("Should coerce numbers", function () { assert.equal(safeToString(12), "12"); });
9
+ it("Should coerce booleans", function () { assert.equal(safeToString(true), "true"); });
10
+ it("Should coerce string objects", function () {
11
+ assert.equal(safeToString(new String("bar")), "bar");
12
+ });
13
+ it("Should coerce objects", function () {
14
+ assert.equal(
15
+ safeToString({ toString: function () { return "Some object"; } }), "Some object"
16
+ );
17
+ });
18
+ it("Should coerce null", function () { assert.equal(safeToString(null), "null"); });
19
+ it("Should coerce undefined", function () {
20
+ assert.equal(safeToString(undefined), "undefined");
21
+ });
22
+
23
+ if (typeof Symbol === "function") {
24
+ it("Should coerce symbols", function () {
25
+ // eslint-disable-next-line no-undef
26
+ assert.equal(safeToString(Symbol()), "Symbol()");
27
+ });
28
+ }
29
+ it("Should return null for non coercible values", function () {
30
+ assert.equal(safeToString({ toString: null }), null);
31
+ });
32
+ });
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , toShortString = require("../../lib/to-short-string");
5
+
6
+ describe("lib/to-short-string", function () {
7
+ it("Should return input string", function () { assert.equal(toShortString("foo"), "foo"); });
8
+ it("Should coerce numbers", function () { assert.equal(toShortString(12), "12"); });
9
+ it("Should coerce booleans", function () { assert.equal(toShortString(true), "true"); });
10
+ it("Should coerce string objects", function () {
11
+ assert.equal(toShortString(new String("bar")), "bar");
12
+ });
13
+ it("Should coerce objects", function () {
14
+ assert.equal(
15
+ toShortString({ toString: function () { return "Some object"; } }), "Some object"
16
+ );
17
+ });
18
+ it("Should coerce null", function () { assert.equal(toShortString(null), "null"); });
19
+ it("Should coerce undefined", function () {
20
+ assert.equal(toShortString(undefined), "undefined");
21
+ });
22
+
23
+ if (typeof Symbol === "function") {
24
+ it("Should coerce symbols", function () {
25
+ // eslint-disable-next-line no-undef
26
+ assert.equal(toShortString(Symbol()), "Symbol()");
27
+ });
28
+ }
29
+ it("Should return replacement non coercible values", function () {
30
+ assert.equal(toShortString({ toString: null }), "<Non-coercible to string value>");
31
+ });
32
+
33
+ it("Should replace new line characters", function () {
34
+ assert.equal(toShortString("foo\n\r\u2028\u2029bar"), "foo\\n\\r\\u2028\\u2029bar");
35
+ });
36
+ it("Should truncate long string", function () {
37
+ var str = Math.random().toString(36);
38
+ while (str.length < 200) str += str;
39
+ assert.equal(toShortString(str).length, 100);
40
+ });
41
+ });
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , coerceToNaturalNumber = require("../../natural-number/coerce");
5
+
6
+ describe("natural-number/coerce", function () {
7
+ it("Should coerce float to integer", function () {
8
+ assert.equal(coerceToNaturalNumber(123.123), 123);
9
+ assert.equal(coerceToNaturalNumber(123.823), 123);
10
+ });
11
+ it("Should coerce string", function () { assert.equal(coerceToNaturalNumber("12.123"), 12); });
12
+ it("Should coerce booleans", function () { assert.equal(coerceToNaturalNumber(true), 1); });
13
+ it("Should coerce number objects", function () {
14
+ assert.equal(coerceToNaturalNumber(new Number(343)), 343);
15
+ });
16
+ it("Should coerce objects", function () {
17
+ assert.equal(coerceToNaturalNumber({ valueOf: function () { return 23; } }), 23);
18
+ });
19
+ it("Should coerce number beyond Number.MAX_SAFE_INTEGER", function () {
20
+ assert.equal(coerceToNaturalNumber(9007199254740992), 9007199254740992);
21
+ });
22
+
23
+ it("Should reject negative number", function () {
24
+ assert.equal(coerceToNaturalNumber(-1), null);
25
+ });
26
+ it("Should reject infinite number", function () {
27
+ assert.equal(coerceToNaturalNumber(Infinity), null);
28
+ });
29
+ it("Should reject NaN", function () { assert.equal(coerceToNaturalNumber(NaN), null); });
30
+
31
+ if (typeof Object.create === "function") {
32
+ it("Should not coerce objects with no number representation", function () {
33
+ assert.equal(coerceToNaturalNumber(Object.create(null)), null);
34
+ });
35
+ }
36
+
37
+ it("Should not coerce null", function () { assert.equal(coerceToNaturalNumber(null), null); });
38
+ it("Should not coerce undefined", function () {
39
+ assert.equal(coerceToNaturalNumber(undefined), null);
40
+ });
41
+
42
+ if (typeof Symbol === "function") {
43
+ it("Should not coerce symbols", function () {
44
+ assert.equal(coerceToNaturalNumber(Symbol("foo")), null);
45
+ });
46
+ }
47
+ });
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , ensureNaturalNumber = require("../../natural-number/ensure");
5
+
6
+ describe("natural-number/ensure", function () {
7
+ it("Should return coerced value", function () {
8
+ assert.equal(ensureNaturalNumber("12.23"), 12);
9
+ });
10
+ it("Should crash on no value", function () {
11
+ try {
12
+ ensureNaturalNumber(-20);
13
+ throw new Error("Unexpected");
14
+ } catch (error) {
15
+ assert.equal(error.name, "TypeError");
16
+ assert.equal(error.message, "-20 is not a natural number");
17
+ }
18
+ });
19
+ });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , coerceToNumber = require("../../number/coerce");
5
+
6
+ describe("number/coerce", function () {
7
+ it("Should return input number", function () {
8
+ assert.equal(coerceToNumber(123.123), 123.123);
9
+ });
10
+ it("Should return input infinite number", function () {
11
+ assert.equal(coerceToNumber(Infinity), Infinity);
12
+ });
13
+ it("Should coerce string", function () { assert.equal(coerceToNumber("12"), 12); });
14
+ it("Should coerce booleans", function () { assert.equal(coerceToNumber(true), 1); });
15
+ it("Should coerce number objects", function () {
16
+ assert.equal(coerceToNumber(new Number(343)), 343);
17
+ });
18
+ it("Should coerce objects", function () {
19
+ assert.equal(coerceToNumber({ valueOf: function () { return 23; } }), 23);
20
+ });
21
+
22
+ it("Should reject NaN", function () { assert.equal(coerceToNumber(NaN), null); });
23
+
24
+ if (typeof Object.create === "function") {
25
+ it("Should not coerce objects with no number representation", function () {
26
+ assert.equal(coerceToNumber(Object.create(null)), null);
27
+ });
28
+ }
29
+
30
+ it("Should not coerce null", function () { assert.equal(coerceToNumber(null), null); });
31
+ it("Should not coerce undefined", function () {
32
+ assert.equal(coerceToNumber(undefined), null);
33
+ });
34
+
35
+ if (typeof Symbol === "function") {
36
+ it("Should not coerce symbols", function () {
37
+ assert.equal(coerceToNumber(Symbol("foo")), null);
38
+ });
39
+ }
40
+ });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , ensureNumber = require("../../number/ensure");
5
+
6
+ describe("number/ensure", function () {
7
+ it("Should return coerced value", function () { assert.equal(ensureNumber("12.23"), 12.23); });
8
+ it("Should crash on no value", function () {
9
+ try {
10
+ ensureNumber(null);
11
+ throw new Error("Unexpected");
12
+ } catch (error) {
13
+ assert.equal(error.name, "TypeError");
14
+ assert.equal(error.message, "null is not a number");
15
+ }
16
+ });
17
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , ensureObject = require("../../object/ensure");
5
+
6
+ describe("object/ensure", function () {
7
+ it("Should return input value", function () {
8
+ var value = {};
9
+ assert.equal(ensureObject(value), value);
10
+ });
11
+ it("Should crash on no value", function () {
12
+ try {
13
+ ensureObject(null);
14
+ throw new Error("Unexpected");
15
+ } catch (error) {
16
+ assert.equal(error.name, "TypeError");
17
+ assert.equal(error.message, "null is not an object");
18
+ }
19
+ });
20
+ });
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , isObject = require("../../object/is");
5
+
6
+ describe("object/is", function () {
7
+ it("Should return true on object", function () { assert.equal(isObject({}), true); });
8
+ it("Should return true on function", function () {
9
+ assert.equal(isObject(function () { return true; }), true);
10
+ });
11
+ it("Should return true on array", function () { assert.equal(isObject([]), true); });
12
+ if (typeof Object.create === "function") {
13
+ it("Should return true on object with no prototype", function () {
14
+ assert.equal(isObject(Object.create(null)), true);
15
+ });
16
+ }
17
+ it("Should return false on string", function () { assert.equal(isObject("foo"), false); });
18
+ it("Should return false on empty string", function () { assert.equal(isObject(""), false); });
19
+ it("Should return false on number", function () { assert.equal(isObject(123), false); });
20
+ it("Should return false on NaN", function () { assert.equal(isObject(NaN), false); });
21
+ it("Should return false on boolean", function () { assert.equal(isObject(true), false); });
22
+ if (typeof Symbol === "function") {
23
+ it("Should return false on symbol", function () {
24
+ assert.equal(isObject(Symbol("foo")), false);
25
+ });
26
+ }
27
+
28
+ it("Should return false on null", function () { assert.equal(isObject(null), false); });
29
+ it("Should return false on undefined", function () { assert.equal(isObject(void 0), false); });
30
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , ensurePlainFunction = require("../../plain-function/ensure");
5
+
6
+ describe("plain-function/ensure", function () {
7
+ it("Should return input value", function () {
8
+ var value = function () { return true; };
9
+ assert.equal(ensurePlainFunction(value), value);
10
+ });
11
+ it("Should crash on invalid value", function () {
12
+ try {
13
+ ensurePlainFunction(null);
14
+ throw new Error("Unexpected");
15
+ } catch (error) {
16
+ assert.equal(error.name, "TypeError");
17
+ assert(error.message.includes("is not a plain function"));
18
+ }
19
+ });
20
+ });
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , isPlainFunction = require("../../plain-function/is")
5
+ , arrowFunctionIfSupported = require("../_lib/arrow-function-if-supported")
6
+ , classIfSupported = require("../_lib/class-if-supported");
7
+
8
+ describe("plain-function/is", function () {
9
+ it("Should return true on function", function () {
10
+ assert.equal(isPlainFunction(function () { return true; }), true);
11
+ });
12
+ if (arrowFunctionIfSupported) {
13
+ it("Should return true on arrow function", function () {
14
+ assert.equal(isPlainFunction(arrowFunctionIfSupported), true);
15
+ });
16
+ }
17
+ if (classIfSupported) {
18
+ it("Should return false on class", function () {
19
+ assert.equal(isPlainFunction(classIfSupported), false);
20
+ });
21
+ }
22
+ it("Should return false on reg-exp", function () {
23
+ assert.equal(isPlainFunction(/foo/), false);
24
+ });
25
+
26
+ it("Should return false on plain object", function () {
27
+ assert.equal(isPlainFunction({}), false);
28
+ });
29
+ it("Should return false on array", function () { assert.equal(isPlainFunction([]), false); });
30
+ if (typeof Object.create === "function") {
31
+ it("Should return false on object with no prototype", function () {
32
+ assert.equal(isPlainFunction(Object.create(null)), false);
33
+ });
34
+ }
35
+ it("Should return false on string", function () {
36
+ assert.equal(isPlainFunction("foo"), false);
37
+ });
38
+ it("Should return false on empty string", function () {
39
+ assert.equal(isPlainFunction(""), false);
40
+ });
41
+ it("Should return false on number", function () { assert.equal(isPlainFunction(123), false); });
42
+ it("Should return false on NaN", function () { assert.equal(isPlainFunction(NaN), false); });
43
+ it("Should return false on boolean", function () {
44
+ assert.equal(isPlainFunction(true), false);
45
+ });
46
+ if (typeof Symbol === "function") {
47
+ it("Should return false on symbol", function () {
48
+ assert.equal(isPlainFunction(Symbol("foo")), false);
49
+ });
50
+ }
51
+
52
+ it("Should return false on null", function () { assert.equal(isPlainFunction(null), false); });
53
+ it("Should return false on undefined", function () {
54
+ assert.equal(isPlainFunction(void 0), false);
55
+ });
56
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , ensurePlainObject = require("../../plain-object/ensure");
5
+
6
+ describe("plain-object/ensure", function () {
7
+ it("Should return input value", function () {
8
+ var value = {};
9
+ assert.equal(ensurePlainObject(value), value);
10
+ });
11
+ it("Should crash on invalid value", function () {
12
+ try {
13
+ ensurePlainObject(null);
14
+ throw new Error("Unexpected");
15
+ } catch (error) {
16
+ assert.equal(error.name, "TypeError");
17
+ assert(error.message.includes("is not a plain object"));
18
+ }
19
+ });
20
+ });
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , isPlainObject = require("../../plain-object/is");
5
+
6
+ describe("plain-object/is", function () {
7
+ it("Should return true on plain object", function () {
8
+ assert.equal(isPlainObject({}), true);
9
+ });
10
+ if (typeof Object.create === "function") {
11
+ it("Should return true on object with no prototype", function () {
12
+ assert.equal(isPlainObject(Object.create(null)), true);
13
+ });
14
+ it(
15
+ "Should return false on object that inherits from object with no prototype",
16
+ function () { assert.equal(isPlainObject(Object.create(Object.create(null))), false); }
17
+ );
18
+ }
19
+ it("Should return false on Object.prototype", function () {
20
+ assert.equal(isPlainObject(Object.prototype), false);
21
+ });
22
+ it("Should return false on prototype that derives from Object.prototype", function () {
23
+ assert.equal(isPlainObject(RegExp.prototype), false);
24
+ });
25
+
26
+ it("Should return false on function", function () {
27
+ assert.equal(isPlainObject(function () { return true; }), false);
28
+ });
29
+
30
+ it("Should return false on string", function () { assert.equal(isPlainObject("foo"), false); });
31
+ it("Should return false on empty string", function () {
32
+ assert.equal(isPlainObject(""), false);
33
+ });
34
+ it("Should return false on number", function () { assert.equal(isPlainObject(123), false); });
35
+ it("Should return false on NaN", function () { assert.equal(isPlainObject(NaN), false); });
36
+ it("Should return false on boolean", function () { assert.equal(isPlainObject(true), false); });
37
+ if (typeof Symbol === "function") {
38
+ it("Should return false on symbol", function () {
39
+ assert.equal(isPlainObject(Symbol("foo")), false);
40
+ });
41
+ }
42
+
43
+ it("Should return false on null", function () { assert.equal(isPlainObject(null), false); });
44
+ it("Should return false on undefined", function () {
45
+ assert.equal(isPlainObject(void 0), false);
46
+ });
47
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , ensurePromise = require("../../promise/ensure");
5
+
6
+ describe("promise/ensure", function () {
7
+ it("Should return input value", function () {
8
+ var value = Promise.resolve();
9
+ assert.equal(ensurePromise(value), value);
10
+ });
11
+ it("Should crash on no value", function () {
12
+ try {
13
+ ensurePromise({});
14
+ throw new Error("Unexpected");
15
+ } catch (error) {
16
+ assert.equal(error.name, "TypeError");
17
+ assert.equal(error.message, "[object Object] is not a promise");
18
+ }
19
+ });
20
+ });
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ var assert = require("chai").assert
4
+ , isPromise = require("../../promise/is");
5
+
6
+ describe("promise/is", function () {
7
+ if (typeof Promise === "function") {
8
+ it("Should return true on promise", function () {
9
+ assert.equal(isPromise(Promise.resolve()), true);
10
+ });
11
+ }
12
+ it("Should return false on non-promise thenable", function () {
13
+ assert.equal(isPromise({ then: function () { return true; } }), false);
14
+ });
15
+
16
+ it("Should return false on plain object", function () { assert.equal(isPromise({}), false); });
17
+ it("Should return false on function", function () {
18
+ assert.equal(isPromise(function () { return true; }), false);
19
+ });
20
+ it("Should return false on array", function () { assert.equal(isPromise([]), false); });
21
+ if (typeof Object.create === "function") {
22
+ it("Should return false on object with no prototype", function () {
23
+ assert.equal(isPromise(Object.create(null)), false);
24
+ });
25
+ }
26
+ it("Should return false on string", function () { assert.equal(isPromise("foo"), false); });
27
+ it("Should return false on empty string", function () { assert.equal(isPromise(""), false); });
28
+ it("Should return false on number", function () { assert.equal(isPromise(123), false); });
29
+ it("Should return false on NaN", function () { assert.equal(isPromise(NaN), false); });
30
+ it("Should return false on boolean", function () { assert.equal(isPromise(true), false); });
31
+ if (typeof Symbol === "function") {
32
+ it("Should return false on symbol", function () {
33
+ assert.equal(isPromise(Symbol("foo")), false);
34
+ });
35
+ }
36
+
37
+ it("Should return false on null", function () { assert.equal(isPromise(null), false); });
38
+ it("Should return false on undefined", function () { assert.equal(isPromise(void 0), false); });
39
+ });