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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +46 -23
- data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +8 -2
- data/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js +101 -21
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +9 -2
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +0 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +4 -6
- data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +36 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +14 -14
- data/app/assets/stylesheets/govuk_publishing_components/components/_highlight-boxes.scss +23 -23
- data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +8 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/_lead-paragraph.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +8 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +10 -10
- data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +11 -14
- data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +14 -14
- data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +8 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +7 -7
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +20 -16
- data/app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss +5 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-list.scss +5 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +8 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss +1 -1
- data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +33 -25
- data/app/views/govuk_publishing_components/components/_error_summary.html.erb +4 -2
- data/app/views/govuk_publishing_components/components/_notice.html.erb +4 -1
- data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +2 -0
- data/app/views/govuk_publishing_components/components/docs/error_summary.yml +6 -0
- data/app/views/govuk_publishing_components/components/docs/notice.yml +6 -0
- data/app/views/govuk_publishing_components/components/docs/success_alert.yml +1 -1
- data/lib/govuk_publishing_components/presenters/cookie_banner_helper.rb +0 -4
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js +1 -1
- data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js.map +1 -1
- data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.preact.min.js +1 -1
- data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.preact.min.js.map +1 -1
- data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.react.min.js +1 -1
- data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.react.min.js.map +1 -1
- data/node_modules/accessible-autocomplete/package.json +3 -3
- data/node_modules/accessible-autocomplete/src/autocomplete.js +4 -2
- data/node_modules/accessible-autocomplete/src/wrapper.js +5 -1
- data/node_modules/d/CHANGELOG.md +9 -0
- data/node_modules/d/CHANGES +4 -0
- data/node_modules/d/LICENSE +12 -16
- data/node_modules/d/README.md +49 -19
- data/node_modules/d/auto-bind.js +11 -10
- data/node_modules/d/index.js +23 -24
- data/node_modules/d/lazy.js +21 -23
- data/node_modules/d/package.json +63 -16
- data/node_modules/d/test/auto-bind.js +6 -7
- data/node_modules/d/test/index.js +78 -51
- data/node_modules/d/test/lazy.js +65 -50
- data/node_modules/es6-weak-map/CHANGELOG.md +5 -0
- data/node_modules/es6-weak-map/LICENSE +12 -16
- data/node_modules/es6-weak-map/README.md +34 -19
- data/node_modules/es6-weak-map/implement.js +9 -5
- data/node_modules/es6-weak-map/index.js +2 -2
- data/node_modules/es6-weak-map/is-implemented.js +10 -9
- data/node_modules/es6-weak-map/is-native-implemented.js +3 -3
- data/node_modules/es6-weak-map/is-weak-map.js +8 -8
- data/node_modules/es6-weak-map/package.json +30 -19
- data/node_modules/es6-weak-map/polyfill.js +31 -32
- data/node_modules/es6-weak-map/test/implement.js +4 -2
- data/node_modules/es6-weak-map/test/index.js +4 -3
- data/node_modules/es6-weak-map/test/is-implemented.js +9 -8
- data/node_modules/es6-weak-map/test/is-native-implemented.js +4 -2
- data/node_modules/es6-weak-map/test/is-weak-map.js +4 -4
- data/node_modules/es6-weak-map/test/polyfill.js +13 -13
- data/node_modules/es6-weak-map/test/valid-weak-map.js +22 -9
- data/node_modules/es6-weak-map/valid-weak-map.js +5 -5
- data/node_modules/resolve/lib/async.js +1 -1
- data/node_modules/resolve/lib/node-modules-paths.js +1 -1
- data/node_modules/resolve/lib/sync.js +0 -2
- data/node_modules/resolve/package.json +13 -13
- data/node_modules/resolve/test/node-modules-paths.js +0 -22
- data/node_modules/resolve/test/resolver.js +11 -0
- data/node_modules/resolve/test/resolver_sync.js +11 -0
- data/node_modules/standard/node_modules/ms/index.js +2 -2
- data/node_modules/standard/node_modules/ms/package.json +205 -16
- data/node_modules/standard/node_modules/ms/readme.md +1 -1
- data/node_modules/type/CHANGELOG.md +62 -0
- data/node_modules/type/README.md +743 -0
- data/node_modules/type/array-length/coerce.js +10 -0
- data/node_modules/type/array-length/ensure.js +10 -0
- data/node_modules/type/array-like/ensure.js +9 -0
- data/node_modules/type/array-like/is.js +21 -0
- data/node_modules/type/array/ensure.js +9 -0
- data/node_modules/type/array/is.js +27 -0
- data/node_modules/type/date/ensure.js +9 -0
- data/node_modules/type/date/is.js +26 -0
- data/node_modules/type/error/ensure.js +9 -0
- data/node_modules/type/error/is.js +24 -0
- data/node_modules/type/finite/coerce.js +8 -0
- data/node_modules/type/finite/ensure.js +10 -0
- data/node_modules/type/function/ensure.js +9 -0
- data/node_modules/type/function/is.js +19 -0
- data/node_modules/type/integer/coerce.js +11 -0
- data/node_modules/type/integer/ensure.js +10 -0
- data/node_modules/type/iterable/ensure.js +9 -0
- data/node_modules/type/iterable/is.js +20 -0
- data/node_modules/type/lib/is-to-string-tag-supported.js +3 -0
- data/node_modules/type/lib/resolve-exception.js +21 -0
- data/node_modules/type/lib/safe-to-string.js +10 -0
- data/node_modules/type/lib/to-short-string.js +29 -0
- data/node_modules/type/natural-number/coerce.js +10 -0
- data/node_modules/type/natural-number/ensure.js +10 -0
- data/node_modules/type/number/coerce.js +14 -0
- data/node_modules/type/number/ensure.js +10 -0
- data/node_modules/type/object/ensure.js +9 -0
- data/node_modules/type/object/is.js +11 -0
- data/node_modules/type/package.json +159 -0
- data/node_modules/type/plain-function/ensure.js +9 -0
- data/node_modules/type/plain-function/is.js +11 -0
- data/node_modules/type/plain-object/ensure.js +9 -0
- data/node_modules/type/plain-object/is.js +28 -0
- data/node_modules/type/promise/ensure.js +9 -0
- data/node_modules/type/promise/is.js +27 -0
- data/node_modules/type/prototype/is.js +13 -0
- data/node_modules/type/reg-exp/ensure.js +9 -0
- data/node_modules/type/reg-exp/is.js +37 -0
- data/node_modules/type/safe-integer/coerce.js +13 -0
- data/node_modules/type/safe-integer/ensure.js +10 -0
- data/node_modules/type/string/coerce.js +23 -0
- data/node_modules/type/string/ensure.js +10 -0
- data/node_modules/type/test/_lib/arrow-function-if-supported.js +4 -0
- data/node_modules/type/test/_lib/class-if-supported.js +4 -0
- data/node_modules/type/test/array-length/coerce.js +47 -0
- data/node_modules/type/test/array-length/ensure.js +19 -0
- data/node_modules/type/test/array-like/ensure.js +24 -0
- data/node_modules/type/test/array-like/is.js +47 -0
- data/node_modules/type/test/array/ensure.js +20 -0
- data/node_modules/type/test/array/is.js +41 -0
- data/node_modules/type/test/date/ensure.js +20 -0
- data/node_modules/type/test/date/is.js +46 -0
- data/node_modules/type/test/error/ensure.js +20 -0
- data/node_modules/type/test/error/is.js +42 -0
- data/node_modules/type/test/finite/coerce.js +40 -0
- data/node_modules/type/test/finite/ensure.js +17 -0
- data/node_modules/type/test/function/ensure.js +20 -0
- data/node_modules/type/test/function/is.js +46 -0
- data/node_modules/type/test/integer/coerce.js +49 -0
- data/node_modules/type/test/integer/ensure.js +17 -0
- data/node_modules/type/test/iterable/ensure.js +24 -0
- data/node_modules/type/test/iterable/is.js +50 -0
- data/node_modules/type/test/lib/is-to-string-tag-supported.js +10 -0
- data/node_modules/type/test/lib/resolve-exception.js +39 -0
- data/node_modules/type/test/lib/safe-to-string.js +32 -0
- data/node_modules/type/test/lib/to-short-string.js +41 -0
- data/node_modules/type/test/natural-number/coerce.js +47 -0
- data/node_modules/type/test/natural-number/ensure.js +19 -0
- data/node_modules/type/test/number/coerce.js +40 -0
- data/node_modules/type/test/number/ensure.js +17 -0
- data/node_modules/type/test/object/ensure.js +20 -0
- data/node_modules/type/test/object/is.js +30 -0
- data/node_modules/type/test/plain-function/ensure.js +20 -0
- data/node_modules/type/test/plain-function/is.js +56 -0
- data/node_modules/type/test/plain-object/ensure.js +20 -0
- data/node_modules/type/test/plain-object/is.js +47 -0
- data/node_modules/type/test/promise/ensure.js +20 -0
- data/node_modules/type/test/promise/is.js +39 -0
- data/node_modules/type/test/prototype/is.js +39 -0
- data/node_modules/type/test/reg-exp/ensure.js +20 -0
- data/node_modules/type/test/reg-exp/is.js +47 -0
- data/node_modules/type/test/safe-integer/coerce.js +49 -0
- data/node_modules/type/test/safe-integer/ensure.js +19 -0
- data/node_modules/type/test/string/coerce.js +36 -0
- data/node_modules/type/test/string/ensure.js +17 -0
- data/node_modules/type/test/thenable/ensure.js +20 -0
- data/node_modules/type/test/thenable/is.js +44 -0
- data/node_modules/type/test/time-value/coerce.js +47 -0
- data/node_modules/type/test/time-value/ensure.js +17 -0
- data/node_modules/type/test/value/ensure.js +20 -0
- data/node_modules/type/test/value/is.js +29 -0
- data/node_modules/type/thenable/ensure.js +9 -0
- data/node_modules/type/thenable/is.js +9 -0
- data/node_modules/type/time-value/coerce.js +12 -0
- data/node_modules/type/time-value/ensure.js +10 -0
- data/node_modules/type/value/ensure.js +9 -0
- data/node_modules/type/value/is.js +6 -0
- metadata +118 -21
- data/app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-navigation.scss +0 -94
- data/node_modules/resolve/reaf +0 -0
- data/node_modules/resolve/test/shadowed_core.js +0 -38
- data/node_modules/resolve/test/shadowed_core/node_modules/util/index.js +0 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, ensureDate = require("../../date/ensure");
|
5
|
+
|
6
|
+
describe("date/ensure", function () {
|
7
|
+
it("Should return input value", function () {
|
8
|
+
var value = new Date();
|
9
|
+
assert.equal(ensureDate(value), value);
|
10
|
+
});
|
11
|
+
it("Should crash on invalid value", function () {
|
12
|
+
try {
|
13
|
+
ensureDate(null);
|
14
|
+
throw new Error("Unexpected");
|
15
|
+
} catch (error) {
|
16
|
+
assert.equal(error.name, "TypeError");
|
17
|
+
assert(error.message.includes("is not a date object"));
|
18
|
+
}
|
19
|
+
});
|
20
|
+
});
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, isDate = require("../../date/is");
|
5
|
+
|
6
|
+
describe("date/is", function () {
|
7
|
+
it("Should return true on date", function () { assert.equal(isDate(new Date()), true); });
|
8
|
+
it("Should return false on invalid date", function () {
|
9
|
+
assert.equal(isDate(new Date("foo")), false);
|
10
|
+
});
|
11
|
+
|
12
|
+
it("Should return false on native date with no common API exposed", function () {
|
13
|
+
var value = new Date();
|
14
|
+
value.getFullYear = null;
|
15
|
+
assert.equal(isDate(value), false);
|
16
|
+
});
|
17
|
+
it("Should return false on Date.prototype", function () {
|
18
|
+
assert.equal(isDate(Date.prototype), false);
|
19
|
+
});
|
20
|
+
it("Should return false on time value", function () { assert.equal(isDate(12312313), false); });
|
21
|
+
|
22
|
+
it("Should return false on plain object", function () { assert.equal(isDate({}), false); });
|
23
|
+
it("Should return false on function", function () {
|
24
|
+
assert.equal(isDate(function () { return true; }), false);
|
25
|
+
});
|
26
|
+
|
27
|
+
it("Should return false on array", function () { assert.equal(isDate([]), false); });
|
28
|
+
if (typeof Object.create === "function") {
|
29
|
+
it("Should return false on object with no prototype", function () {
|
30
|
+
assert.equal(isDate(Object.create(null)), false);
|
31
|
+
});
|
32
|
+
}
|
33
|
+
it("Should return false on string", function () { assert.equal(isDate("foo"), false); });
|
34
|
+
it("Should return false on empty string", function () { assert.equal(isDate(""), false); });
|
35
|
+
it("Should return false on number", function () { assert.equal(isDate(123), false); });
|
36
|
+
it("Should return false on NaN", function () { assert.equal(isDate(NaN), false); });
|
37
|
+
it("Should return false on boolean", function () { assert.equal(isDate(true), false); });
|
38
|
+
if (typeof Symbol === "function") {
|
39
|
+
it("Should return false on symbol", function () {
|
40
|
+
assert.equal(isDate(Symbol("foo")), false);
|
41
|
+
});
|
42
|
+
}
|
43
|
+
|
44
|
+
it("Should return false on null", function () { assert.equal(isDate(null), false); });
|
45
|
+
it("Should return false on undefined", function () { assert.equal(isDate(void 0), false); });
|
46
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, ensureError = require("../../error/ensure");
|
5
|
+
|
6
|
+
describe("error/ensure", function () {
|
7
|
+
it("Should return input value", function () {
|
8
|
+
var value = new Error();
|
9
|
+
assert.equal(ensureError(value), value);
|
10
|
+
});
|
11
|
+
it("Should crash on invalid value", function () {
|
12
|
+
try {
|
13
|
+
ensureError(null);
|
14
|
+
throw new Error("Unexpected");
|
15
|
+
} catch (error) {
|
16
|
+
assert.equal(error.name, "TypeError");
|
17
|
+
assert(error.message.includes("is not an error object"));
|
18
|
+
}
|
19
|
+
});
|
20
|
+
});
|
@@ -0,0 +1,42 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, isError = require("../../error/is");
|
5
|
+
|
6
|
+
describe("error/is", function () {
|
7
|
+
it("Should return true on error", function () { assert.equal(isError(new Error()), true); });
|
8
|
+
|
9
|
+
it("Should return false on native error with no common API exposed", function () {
|
10
|
+
var value = new Error();
|
11
|
+
value.message = null;
|
12
|
+
assert.equal(isError(value), false);
|
13
|
+
});
|
14
|
+
it("Should return false on Error.prototype", function () {
|
15
|
+
assert.equal(isError(Error.prototype), false);
|
16
|
+
});
|
17
|
+
|
18
|
+
it("Should return false on plain object", function () { assert.equal(isError({}), false); });
|
19
|
+
it("Should return false on function", function () {
|
20
|
+
assert.equal(isError(function () { return true; }), false);
|
21
|
+
});
|
22
|
+
|
23
|
+
it("Should return false on array", function () { assert.equal(isError([]), false); });
|
24
|
+
if (typeof Object.create === "function") {
|
25
|
+
it("Should return false on object with no prototype", function () {
|
26
|
+
assert.equal(isError(Object.create(null)), false);
|
27
|
+
});
|
28
|
+
}
|
29
|
+
it("Should return false on string", function () { assert.equal(isError("foo"), false); });
|
30
|
+
it("Should return false on empty string", function () { assert.equal(isError(""), false); });
|
31
|
+
it("Should return false on number", function () { assert.equal(isError(123), false); });
|
32
|
+
it("Should return false on NaN", function () { assert.equal(isError(NaN), false); });
|
33
|
+
it("Should return false on boolean", function () { assert.equal(isError(true), false); });
|
34
|
+
if (typeof Symbol === "function") {
|
35
|
+
it("Should return false on symbol", function () {
|
36
|
+
assert.equal(isError(Symbol("foo")), false);
|
37
|
+
});
|
38
|
+
}
|
39
|
+
|
40
|
+
it("Should return false on null", function () { assert.equal(isError(null), false); });
|
41
|
+
it("Should return false on undefined", function () { assert.equal(isError(void 0), false); });
|
42
|
+
});
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, coerceToFinite = require("../../finite/coerce");
|
5
|
+
|
6
|
+
describe("finite/coerce", function () {
|
7
|
+
it("Should return input number", function () {
|
8
|
+
assert.equal(coerceToFinite(123.123), 123.123);
|
9
|
+
});
|
10
|
+
it("Should coerce string", function () { assert.equal(coerceToFinite("12"), 12); });
|
11
|
+
it("Should coerce booleans", function () { assert.equal(coerceToFinite(true), 1); });
|
12
|
+
it("Should coerce number objects", function () {
|
13
|
+
assert.equal(coerceToFinite(new Number(343)), 343);
|
14
|
+
});
|
15
|
+
it("Should coerce objects", function () {
|
16
|
+
assert.equal(coerceToFinite({ valueOf: function () { return 23; } }), 23);
|
17
|
+
});
|
18
|
+
|
19
|
+
it("Should reject infinite number", function () {
|
20
|
+
assert.equal(coerceToFinite(Infinity), null);
|
21
|
+
});
|
22
|
+
it("Should reject NaN", function () { assert.equal(coerceToFinite(NaN), null); });
|
23
|
+
|
24
|
+
if (typeof Object.create === "function") {
|
25
|
+
it("Should not coerce objects with no number representation", function () {
|
26
|
+
assert.equal(coerceToFinite(Object.create(null)), null);
|
27
|
+
});
|
28
|
+
}
|
29
|
+
|
30
|
+
it("Should not coerce null", function () { assert.equal(coerceToFinite(null), null); });
|
31
|
+
it("Should not coerce undefined", function () {
|
32
|
+
assert.equal(coerceToFinite(undefined), null);
|
33
|
+
});
|
34
|
+
|
35
|
+
if (typeof Symbol === "function") {
|
36
|
+
it("Should not coerce symbols", function () {
|
37
|
+
assert.equal(coerceToFinite(Symbol("foo")), null);
|
38
|
+
});
|
39
|
+
}
|
40
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, ensureFinite = require("../../finite/ensure");
|
5
|
+
|
6
|
+
describe("finite/ensure", function () {
|
7
|
+
it("Should return coerced value", function () { assert.equal(ensureFinite("12.23"), 12.23); });
|
8
|
+
it("Should crash on no value", function () {
|
9
|
+
try {
|
10
|
+
ensureFinite(null);
|
11
|
+
throw new Error("Unexpected");
|
12
|
+
} catch (error) {
|
13
|
+
assert.equal(error.name, "TypeError");
|
14
|
+
assert.equal(error.message, "null is not a finite number");
|
15
|
+
}
|
16
|
+
});
|
17
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, ensureFunction = require("../../function/ensure");
|
5
|
+
|
6
|
+
describe("function/ensure", function () {
|
7
|
+
it("Should return input value", function () {
|
8
|
+
var value = function () { return true; };
|
9
|
+
assert.equal(ensureFunction(value), value);
|
10
|
+
});
|
11
|
+
it("Should crash on invalid value", function () {
|
12
|
+
try {
|
13
|
+
ensureFunction(null);
|
14
|
+
throw new Error("Unexpected");
|
15
|
+
} catch (error) {
|
16
|
+
assert.equal(error.name, "TypeError");
|
17
|
+
assert(error.message.includes("is not a function"));
|
18
|
+
}
|
19
|
+
});
|
20
|
+
});
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, isFunction = require("../../function/is")
|
5
|
+
, arrowFunctionIfSupported = require("../_lib/arrow-function-if-supported")
|
6
|
+
, classIfSupported = require("../_lib/class-if-supported");
|
7
|
+
|
8
|
+
describe("function/is", function () {
|
9
|
+
it("Should return true on function", function () {
|
10
|
+
assert.equal(isFunction(function () { return true; }), true);
|
11
|
+
});
|
12
|
+
if (arrowFunctionIfSupported) {
|
13
|
+
it("Should return true on arrow function", function () {
|
14
|
+
assert.equal(isFunction(arrowFunctionIfSupported), true);
|
15
|
+
});
|
16
|
+
}
|
17
|
+
if (classIfSupported) {
|
18
|
+
it("Should return true on class", function () {
|
19
|
+
assert.equal(isFunction(classIfSupported), true);
|
20
|
+
});
|
21
|
+
}
|
22
|
+
it("Should return false on reg-exp", function () { assert.equal(isFunction(/foo/), false); });
|
23
|
+
|
24
|
+
it("Should return false on plain object", function () { assert.equal(isFunction({}), false); });
|
25
|
+
it("Should return false on array", function () { assert.equal(isFunction([]), false); });
|
26
|
+
if (typeof Object.create === "function") {
|
27
|
+
it("Should return false on object with no prototype", function () {
|
28
|
+
assert.equal(isFunction(Object.create(null)), false);
|
29
|
+
});
|
30
|
+
}
|
31
|
+
it("Should return false on string", function () { assert.equal(isFunction("foo"), false); });
|
32
|
+
it("Should return false on empty string", function () { assert.equal(isFunction(""), false); });
|
33
|
+
it("Should return false on number", function () { assert.equal(isFunction(123), false); });
|
34
|
+
it("Should return false on NaN", function () { assert.equal(isFunction(NaN), false); });
|
35
|
+
it("Should return false on boolean", function () { assert.equal(isFunction(true), false); });
|
36
|
+
if (typeof Symbol === "function") {
|
37
|
+
it("Should return false on symbol", function () {
|
38
|
+
assert.equal(isFunction(Symbol("foo")), false);
|
39
|
+
});
|
40
|
+
}
|
41
|
+
|
42
|
+
it("Should return false on null", function () { assert.equal(isFunction(null), false); });
|
43
|
+
it("Should return false on undefined", function () {
|
44
|
+
assert.equal(isFunction(void 0), false);
|
45
|
+
});
|
46
|
+
});
|
@@ -0,0 +1,49 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, coerceToInteger = require("../../integer/coerce");
|
5
|
+
|
6
|
+
describe("integer/coerce", function () {
|
7
|
+
it("Should coerce float to integer", function () {
|
8
|
+
assert.equal(coerceToInteger(123.123), 123);
|
9
|
+
assert.equal(coerceToInteger(123.823), 123);
|
10
|
+
assert.equal(coerceToInteger(-123.123), -123);
|
11
|
+
assert.equal(coerceToInteger(-123.823), -123);
|
12
|
+
});
|
13
|
+
it("Should coerce string", function () { assert.equal(coerceToInteger("12.123"), 12); });
|
14
|
+
it("Should coerce booleans", function () { assert.equal(coerceToInteger(true), 1); });
|
15
|
+
it("Should coerce number objects", function () {
|
16
|
+
assert.equal(coerceToInteger(new Number(343)), 343);
|
17
|
+
});
|
18
|
+
it("Should coerce objects", function () {
|
19
|
+
assert.equal(coerceToInteger({ valueOf: function () { return 23; } }), 23);
|
20
|
+
});
|
21
|
+
it("Should coerce number beyond Number.MAX_SAFE_INTEGER", function () {
|
22
|
+
assert.equal(coerceToInteger(9007199254740992), 9007199254740992);
|
23
|
+
});
|
24
|
+
it("Should coerce number beyond Number.MIN_SAFE_INTEGER", function () {
|
25
|
+
assert.equal(coerceToInteger(-9007199254740992), -9007199254740992);
|
26
|
+
});
|
27
|
+
|
28
|
+
it("Should reject infinite number", function () {
|
29
|
+
assert.equal(coerceToInteger(Infinity), null);
|
30
|
+
});
|
31
|
+
it("Should reject NaN", function () { assert.equal(coerceToInteger(NaN), null); });
|
32
|
+
|
33
|
+
if (typeof Object.create === "function") {
|
34
|
+
it("Should not coerce objects with no number representation", function () {
|
35
|
+
assert.equal(coerceToInteger(Object.create(null)), null);
|
36
|
+
});
|
37
|
+
}
|
38
|
+
|
39
|
+
it("Should not coerce null", function () { assert.equal(coerceToInteger(null), null); });
|
40
|
+
it("Should not coerce undefined", function () {
|
41
|
+
assert.equal(coerceToInteger(undefined), null);
|
42
|
+
});
|
43
|
+
|
44
|
+
if (typeof Symbol === "function") {
|
45
|
+
it("Should not coerce symbols", function () {
|
46
|
+
assert.equal(coerceToInteger(Symbol("foo")), null);
|
47
|
+
});
|
48
|
+
}
|
49
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, ensureInteger = require("../../integer/ensure");
|
5
|
+
|
6
|
+
describe("integer/ensure", function () {
|
7
|
+
it("Should return coerced value", function () { assert.equal(ensureInteger("12.23"), 12); });
|
8
|
+
it("Should crash on no value", function () {
|
9
|
+
try {
|
10
|
+
ensureInteger(null);
|
11
|
+
throw new Error("Unexpected");
|
12
|
+
} catch (error) {
|
13
|
+
assert.equal(error.name, "TypeError");
|
14
|
+
assert.equal(error.message, "null is not an integer");
|
15
|
+
}
|
16
|
+
});
|
17
|
+
});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, ensureIterable = require("../../iterable/ensure");
|
5
|
+
|
6
|
+
describe("iterable/ensure", function () {
|
7
|
+
it("Should return input value", function () {
|
8
|
+
var value = [];
|
9
|
+
assert.equal(ensureIterable(value), value);
|
10
|
+
});
|
11
|
+
it("Should allow strings with allowString option", function () {
|
12
|
+
var value = "foo";
|
13
|
+
assert.equal(ensureIterable(value, { allowString: true }), value);
|
14
|
+
});
|
15
|
+
it("Should crash on invalid value", function () {
|
16
|
+
try {
|
17
|
+
ensureIterable("foo");
|
18
|
+
throw new Error("Unexpected");
|
19
|
+
} catch (error) {
|
20
|
+
assert.equal(error.name, "TypeError");
|
21
|
+
assert(error.message.includes("is not an iterable value"));
|
22
|
+
}
|
23
|
+
});
|
24
|
+
});
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, isIterable = require("../../iterable/is");
|
5
|
+
|
6
|
+
describe("iterable/is", function () {
|
7
|
+
it("Should return true on array", function () { assert.equal(isIterable([]), true); });
|
8
|
+
it("Should return true on arguments", function () {
|
9
|
+
assert.equal(isIterable((function () { return arguments; })()), true);
|
10
|
+
});
|
11
|
+
it("Should by default return false on string", function () {
|
12
|
+
assert.equal(isIterable("foo"), false);
|
13
|
+
});
|
14
|
+
it("Should accept strings if specified", function () {
|
15
|
+
assert.equal(isIterable("foo", { allowString: true }), true);
|
16
|
+
});
|
17
|
+
|
18
|
+
if (typeof Set === "function") {
|
19
|
+
it("Should return true on set", function () { assert.equal(isIterable(new Set()), true); });
|
20
|
+
}
|
21
|
+
if (typeof Map === "function") {
|
22
|
+
it("Should return true on set", function () { assert.equal(isIterable(new Map()), true); });
|
23
|
+
}
|
24
|
+
|
25
|
+
it("Should return false on plain object", function () { assert.equal(isIterable({}), false); });
|
26
|
+
it("Should return false on function", function () {
|
27
|
+
assert.equal(isIterable(function () { return true; }), false);
|
28
|
+
});
|
29
|
+
|
30
|
+
if (typeof Object.create === "function") {
|
31
|
+
it("Should return false on object with no prototype", function () {
|
32
|
+
assert.equal(isIterable(Object.create(null)), false);
|
33
|
+
});
|
34
|
+
}
|
35
|
+
it("Should return false on string", function () { assert.equal(isIterable("foo"), false); });
|
36
|
+
it("Should return false on empty string", function () { assert.equal(isIterable(""), false); });
|
37
|
+
it("Should return false on number", function () { assert.equal(isIterable(123), false); });
|
38
|
+
it("Should return false on NaN", function () { assert.equal(isIterable(NaN), false); });
|
39
|
+
it("Should return false on boolean", function () { assert.equal(isIterable(true), false); });
|
40
|
+
if (typeof Symbol === "function") {
|
41
|
+
it("Should return false on symbol", function () {
|
42
|
+
assert.equal(isIterable(Symbol("foo")), false);
|
43
|
+
});
|
44
|
+
}
|
45
|
+
|
46
|
+
it("Should return false on null", function () { assert.equal(isIterable(null), false); });
|
47
|
+
it("Should return false on undefined", function () {
|
48
|
+
assert.equal(isIterable(void 0), false);
|
49
|
+
});
|
50
|
+
});
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, isToStringTagSupported = require("../../lib/is-to-string-tag-supported");
|
5
|
+
|
6
|
+
describe("lib/is-to-string-tag-supported", function () {
|
7
|
+
it("Should return boolean", function () {
|
8
|
+
assert(typeof isToStringTagSupported === "boolean");
|
9
|
+
});
|
10
|
+
});
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, handleException = require("../../lib/resolve-exception");
|
5
|
+
|
6
|
+
describe("lib/handle-exception", function () {
|
7
|
+
it("Should throw TypeError", function () {
|
8
|
+
try {
|
9
|
+
handleException(12, "Invalid value");
|
10
|
+
throw new Error("Unexpected");
|
11
|
+
} catch (error) {
|
12
|
+
assert.equal(error.name, "TypeError");
|
13
|
+
assert.equal(error.message, "Invalid value");
|
14
|
+
}
|
15
|
+
});
|
16
|
+
it("Should resolve value in default message", function () {
|
17
|
+
try {
|
18
|
+
handleException(12, "%v is invalid", {});
|
19
|
+
throw new Error("Unexpected");
|
20
|
+
} catch (error) {
|
21
|
+
assert.equal(error.message, "12 is invalid");
|
22
|
+
}
|
23
|
+
});
|
24
|
+
it("Should support optional values via inputOptions.isOptional", function () {
|
25
|
+
assert.equal(handleException(null, "%v is invalid", { isOptional: true }, null));
|
26
|
+
});
|
27
|
+
it("Should support optional values via inputOptions.default", function () {
|
28
|
+
// prettier-ignore
|
29
|
+
assert.equal(handleException(null, "%v is invalid", { "default": "bar" }), "bar");
|
30
|
+
});
|
31
|
+
it("Should support custome error message via inputOptions.errorMessage", function () {
|
32
|
+
try {
|
33
|
+
handleException(null, "%v is invalid", { errorMessage: "%v is not supported age" });
|
34
|
+
throw new Error("Unexpected");
|
35
|
+
} catch (error) {
|
36
|
+
assert.equal(error.message, "null is not supported age");
|
37
|
+
}
|
38
|
+
});
|
39
|
+
});
|