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,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, isPrototype = require("../../prototype/is");
|
5
|
+
|
6
|
+
describe("prototype/is", function () {
|
7
|
+
it("Should return true on prototype", function () {
|
8
|
+
assert.equal(isPrototype(Object.prototype), true);
|
9
|
+
});
|
10
|
+
it("Should return false on plain object", function () {
|
11
|
+
assert.equal(isPrototype({}), false);
|
12
|
+
});
|
13
|
+
it("Should return false on function", function () {
|
14
|
+
assert.equal(isPrototype(function () { return true; }), false);
|
15
|
+
});
|
16
|
+
it("Should return false on array", function () { assert.equal(isPrototype([]), false); });
|
17
|
+
if (typeof Object.create === "function") {
|
18
|
+
it("Should return false on object with no prototype", function () {
|
19
|
+
assert.equal(isPrototype(Object.create(null)), false);
|
20
|
+
});
|
21
|
+
}
|
22
|
+
it("Should return false on string", function () { assert.equal(isPrototype("foo"), false); });
|
23
|
+
it("Should return false on empty string", function () {
|
24
|
+
assert.equal(isPrototype(""), false);
|
25
|
+
});
|
26
|
+
it("Should return false on number", function () { assert.equal(isPrototype(123), false); });
|
27
|
+
it("Should return false on NaN", function () { assert.equal(isPrototype(NaN), false); });
|
28
|
+
it("Should return false on boolean", function () { assert.equal(isPrototype(true), false); });
|
29
|
+
if (typeof Symbol === "function") {
|
30
|
+
it("Should return false on symbol", function () {
|
31
|
+
assert.equal(isPrototype(Symbol("foo")), false);
|
32
|
+
});
|
33
|
+
}
|
34
|
+
|
35
|
+
it("Should return false on null", function () { assert.equal(isPrototype(null), false); });
|
36
|
+
it("Should return false on undefined", function () {
|
37
|
+
assert.equal(isPrototype(void 0), false);
|
38
|
+
});
|
39
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, ensureRegExp = require("../../reg-exp/ensure");
|
5
|
+
|
6
|
+
describe("reg-exp/ensure", function () {
|
7
|
+
it("Should return input value", function () {
|
8
|
+
var value = /foo/;
|
9
|
+
assert.equal(ensureRegExp(value), value);
|
10
|
+
});
|
11
|
+
it("Should crash on invalid value", function () {
|
12
|
+
try {
|
13
|
+
ensureRegExp(null);
|
14
|
+
throw new Error("Unexpected");
|
15
|
+
} catch (error) {
|
16
|
+
assert.equal(error.name, "TypeError");
|
17
|
+
assert(error.message.includes("is not a regular expression object"));
|
18
|
+
}
|
19
|
+
});
|
20
|
+
});
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, isRegExp = require("../../reg-exp/is");
|
5
|
+
|
6
|
+
describe("reg-exp/is", function () {
|
7
|
+
it("Should return true on regular expression", function () {
|
8
|
+
assert.equal(isRegExp(/foo/), true);
|
9
|
+
});
|
10
|
+
|
11
|
+
it("Should return false on native regular expression with no common API exposed", function () {
|
12
|
+
var re = /foo/;
|
13
|
+
re.test = null;
|
14
|
+
assert.equal(isRegExp(re), false);
|
15
|
+
});
|
16
|
+
it("Should return false on RegExp.prototype", function () {
|
17
|
+
assert.equal(isRegExp(RegExp.prototype), false);
|
18
|
+
});
|
19
|
+
it("Should return false on regexp like string", function () {
|
20
|
+
assert.equal(isRegExp("/foo/"), false);
|
21
|
+
});
|
22
|
+
|
23
|
+
it("Should return false on plain object", function () { assert.equal(isRegExp({}), false); });
|
24
|
+
it("Should return false on function", function () {
|
25
|
+
assert.equal(isRegExp(function () { return true; }), false);
|
26
|
+
});
|
27
|
+
|
28
|
+
it("Should return false on array", function () { assert.equal(isRegExp([]), false); });
|
29
|
+
if (typeof Object.create === "function") {
|
30
|
+
it("Should return false on object with no prototype", function () {
|
31
|
+
assert.equal(isRegExp(Object.create(null)), false);
|
32
|
+
});
|
33
|
+
}
|
34
|
+
it("Should return false on string", function () { assert.equal(isRegExp("foo"), false); });
|
35
|
+
it("Should return false on empty string", function () { assert.equal(isRegExp(""), false); });
|
36
|
+
it("Should return false on number", function () { assert.equal(isRegExp(123), false); });
|
37
|
+
it("Should return false on NaN", function () { assert.equal(isRegExp(NaN), false); });
|
38
|
+
it("Should return false on boolean", function () { assert.equal(isRegExp(true), false); });
|
39
|
+
if (typeof Symbol === "function") {
|
40
|
+
it("Should return false on symbol", function () {
|
41
|
+
assert.equal(isRegExp(Symbol("foo")), false);
|
42
|
+
});
|
43
|
+
}
|
44
|
+
|
45
|
+
it("Should return false on null", function () { assert.equal(isRegExp(null), false); });
|
46
|
+
it("Should return false on undefined", function () { assert.equal(isRegExp(void 0), false); });
|
47
|
+
});
|
@@ -0,0 +1,49 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, coerceToSafeInteger = require("../../safe-integer/coerce");
|
5
|
+
|
6
|
+
describe("safe-integer/coerce", function () {
|
7
|
+
it("Should coerce float to integer", function () {
|
8
|
+
assert.equal(coerceToSafeInteger(123.123), 123);
|
9
|
+
assert.equal(coerceToSafeInteger(123.823), 123);
|
10
|
+
assert.equal(coerceToSafeInteger(-123.123), -123);
|
11
|
+
assert.equal(coerceToSafeInteger(-123.823), -123);
|
12
|
+
});
|
13
|
+
it("Should coerce string", function () { assert.equal(coerceToSafeInteger("12.123"), 12); });
|
14
|
+
it("Should coerce booleans", function () { assert.equal(coerceToSafeInteger(true), 1); });
|
15
|
+
it("Should coerce number objects", function () {
|
16
|
+
assert.equal(coerceToSafeInteger(new Number(343)), 343);
|
17
|
+
});
|
18
|
+
it("Should coerce objects", function () {
|
19
|
+
assert.equal(coerceToSafeInteger({ valueOf: function () { return 23; } }), 23);
|
20
|
+
});
|
21
|
+
it("Should reject infinite number", function () {
|
22
|
+
assert.equal(coerceToSafeInteger(Infinity), null);
|
23
|
+
});
|
24
|
+
it("Should reject number beyond Number.MAX_SAFE_INTEGER", function () {
|
25
|
+
assert.equal(coerceToSafeInteger(9007199254740992), null);
|
26
|
+
});
|
27
|
+
it("Should reject number beyond Number.MIN_SAFE_INTEGER", function () {
|
28
|
+
assert.equal(coerceToSafeInteger(-9007199254740992), null);
|
29
|
+
});
|
30
|
+
|
31
|
+
it("Should reject NaN", function () { assert.equal(coerceToSafeInteger(NaN), null); });
|
32
|
+
|
33
|
+
if (typeof Object.create === "function") {
|
34
|
+
it("Should not coerce objects with no number representation", function () {
|
35
|
+
assert.equal(coerceToSafeInteger(Object.create(null)), null);
|
36
|
+
});
|
37
|
+
}
|
38
|
+
|
39
|
+
it("Should not coerce null", function () { assert.equal(coerceToSafeInteger(null), null); });
|
40
|
+
it("Should not coerce undefined", function () {
|
41
|
+
assert.equal(coerceToSafeInteger(undefined), null);
|
42
|
+
});
|
43
|
+
|
44
|
+
if (typeof Symbol === "function") {
|
45
|
+
it("Should not coerce symbols", function () {
|
46
|
+
assert.equal(coerceToSafeInteger(Symbol("foo")), null);
|
47
|
+
});
|
48
|
+
}
|
49
|
+
});
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, ensureSafeInteger = require("../../safe-integer/ensure");
|
5
|
+
|
6
|
+
describe("safe-integer/ensure", function () {
|
7
|
+
it("Should return coerced value", function () {
|
8
|
+
assert.equal(ensureSafeInteger("12.23"), 12);
|
9
|
+
});
|
10
|
+
it("Should crash on no value", function () {
|
11
|
+
try {
|
12
|
+
ensureSafeInteger(null);
|
13
|
+
throw new Error("Unexpected");
|
14
|
+
} catch (error) {
|
15
|
+
assert.equal(error.name, "TypeError");
|
16
|
+
assert.equal(error.message, "null is not a safe integer");
|
17
|
+
}
|
18
|
+
});
|
19
|
+
});
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, coerceToString = require("../../string/coerce");
|
5
|
+
|
6
|
+
describe("string/coerce", function () {
|
7
|
+
it("Should return input string", function () { assert.equal(coerceToString("foo"), "foo"); });
|
8
|
+
it("Should coerce numbers", function () { assert.equal(coerceToString(12), "12"); });
|
9
|
+
it("Should coerce booleans", function () { assert.equal(coerceToString(true), "true"); });
|
10
|
+
it("Should coerce string objects", function () {
|
11
|
+
assert.equal(coerceToString(new String("bar")), "bar");
|
12
|
+
});
|
13
|
+
it("Should coerce objects", function () {
|
14
|
+
assert.equal(
|
15
|
+
coerceToString({ toString: function () { return "Some object"; } }), "Some object"
|
16
|
+
);
|
17
|
+
});
|
18
|
+
if (typeof Object.create === "function") {
|
19
|
+
it("Should not coerce objects with no toString", function () {
|
20
|
+
assert.equal(coerceToString(Object.create(null)), null);
|
21
|
+
});
|
22
|
+
}
|
23
|
+
it("Should not coerce objects with no custom toString", function () {
|
24
|
+
assert.equal(coerceToString({}), null);
|
25
|
+
});
|
26
|
+
it("Should not coerce null", function () { assert.equal(coerceToString(null), null); });
|
27
|
+
it("Should not coerce undefined", function () {
|
28
|
+
assert.equal(coerceToString(undefined), null);
|
29
|
+
});
|
30
|
+
|
31
|
+
if (typeof Symbol === "function") {
|
32
|
+
it("Should not coerce symbols", function () {
|
33
|
+
assert.equal(coerceToString(Symbol("foo")), null);
|
34
|
+
});
|
35
|
+
}
|
36
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, ensureString = require("../../string/ensure");
|
5
|
+
|
6
|
+
describe("string/ensure", function () {
|
7
|
+
it("Should return coerced value", function () { assert.equal(ensureString(12), "12"); });
|
8
|
+
it("Should crash on no value", function () {
|
9
|
+
try {
|
10
|
+
ensureString(null);
|
11
|
+
throw new Error("Unexpected");
|
12
|
+
} catch (error) {
|
13
|
+
assert.equal(error.name, "TypeError");
|
14
|
+
assert.equal(error.message, "null is not a string");
|
15
|
+
}
|
16
|
+
});
|
17
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, ensureThenable = require("../../thenable/ensure");
|
5
|
+
|
6
|
+
describe("thenable/ensure", function () {
|
7
|
+
it("Should return input value", function () {
|
8
|
+
var value = { then: function () { return true; } };
|
9
|
+
assert.equal(ensureThenable(value), value);
|
10
|
+
});
|
11
|
+
it("Should crash on no value", function () {
|
12
|
+
try {
|
13
|
+
ensureThenable({});
|
14
|
+
throw new Error("Unexpected");
|
15
|
+
} catch (error) {
|
16
|
+
assert.equal(error.name, "TypeError");
|
17
|
+
assert.equal(error.message, "[object Object] is not a thenable object");
|
18
|
+
}
|
19
|
+
});
|
20
|
+
});
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, isThenable = require("../../thenable/is");
|
5
|
+
|
6
|
+
describe("thenable/is", function () {
|
7
|
+
it("Should return true on object with `then` method", function () {
|
8
|
+
assert.equal(isThenable({ then: function () { return true; } }), true);
|
9
|
+
});
|
10
|
+
if (typeof Promise === "function") {
|
11
|
+
it("Should return true on promise", function () {
|
12
|
+
assert.equal(isThenable(Promise.resolve()), true);
|
13
|
+
});
|
14
|
+
}
|
15
|
+
it("Should return false on object with `then` non callable property", function () {
|
16
|
+
assert.equal(isThenable({ then: {} }), false);
|
17
|
+
});
|
18
|
+
|
19
|
+
it("Should return false on plain object", function () { assert.equal(isThenable({}), false); });
|
20
|
+
it("Should return false on function", function () {
|
21
|
+
assert.equal(isThenable(function () { return true; }), false);
|
22
|
+
});
|
23
|
+
it("Should return false on array", function () { assert.equal(isThenable([]), false); });
|
24
|
+
if (typeof Object.create === "function") {
|
25
|
+
it("Should return false on object with no prototype", function () {
|
26
|
+
assert.equal(isThenable(Object.create(null)), false);
|
27
|
+
});
|
28
|
+
}
|
29
|
+
it("Should return false on string", function () { assert.equal(isThenable("foo"), false); });
|
30
|
+
it("Should return false on empty string", function () { assert.equal(isThenable(""), false); });
|
31
|
+
it("Should return false on number", function () { assert.equal(isThenable(123), false); });
|
32
|
+
it("Should return false on NaN", function () { assert.equal(isThenable(NaN), false); });
|
33
|
+
it("Should return false on boolean", function () { assert.equal(isThenable(true), false); });
|
34
|
+
if (typeof Symbol === "function") {
|
35
|
+
it("Should return false on symbol", function () {
|
36
|
+
assert.equal(isThenable(Symbol("foo")), false);
|
37
|
+
});
|
38
|
+
}
|
39
|
+
|
40
|
+
it("Should return false on null", function () { assert.equal(isThenable(null), false); });
|
41
|
+
it("Should return false on undefined", function () {
|
42
|
+
assert.equal(isThenable(void 0), false);
|
43
|
+
});
|
44
|
+
});
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, coerceToTimeValue = require("../../time-value/coerce");
|
5
|
+
|
6
|
+
describe("time-value/coerce", function () {
|
7
|
+
it("Should coerce float to time value", function () {
|
8
|
+
assert.equal(coerceToTimeValue(123.123), 123);
|
9
|
+
assert.equal(coerceToTimeValue(123.823), 123);
|
10
|
+
assert.equal(coerceToTimeValue(-123.123), -123);
|
11
|
+
assert.equal(coerceToTimeValue(-123.823), -123);
|
12
|
+
});
|
13
|
+
it("Should coerce string", function () { assert.equal(coerceToTimeValue("12.123"), 12); });
|
14
|
+
it("Should coerce booleans", function () { assert.equal(coerceToTimeValue(true), 1); });
|
15
|
+
it("Should coerce number objects", function () {
|
16
|
+
assert.equal(coerceToTimeValue(new Number(343)), 343);
|
17
|
+
});
|
18
|
+
it("Should coerce objects", function () {
|
19
|
+
assert.equal(coerceToTimeValue({ valueOf: function () { return 23; } }), 23);
|
20
|
+
});
|
21
|
+
it("Should reject infinite number", function () {
|
22
|
+
assert.equal(coerceToTimeValue(Infinity), null);
|
23
|
+
});
|
24
|
+
it("Should reject number beyond 100,000,000 days from unix epox", function () {
|
25
|
+
assert.equal(coerceToTimeValue(8.64e15 + 1), null);
|
26
|
+
assert.equal(coerceToTimeValue(-8.64e15 - 1), null);
|
27
|
+
});
|
28
|
+
|
29
|
+
it("Should reject NaN", function () { assert.equal(coerceToTimeValue(NaN), null); });
|
30
|
+
|
31
|
+
if (typeof Object.create === "function") {
|
32
|
+
it("Should not coerce objects with no number representation", function () {
|
33
|
+
assert.equal(coerceToTimeValue(Object.create(null)), null);
|
34
|
+
});
|
35
|
+
}
|
36
|
+
|
37
|
+
it("Should not coerce null", function () { assert.equal(coerceToTimeValue(null), null); });
|
38
|
+
it("Should not coerce undefined", function () {
|
39
|
+
assert.equal(coerceToTimeValue(undefined), null);
|
40
|
+
});
|
41
|
+
|
42
|
+
if (typeof Symbol === "function") {
|
43
|
+
it("Should not coerce symbols", function () {
|
44
|
+
assert.equal(coerceToTimeValue(Symbol("foo")), null);
|
45
|
+
});
|
46
|
+
}
|
47
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, ensureTimeValue = require("../../time-value/ensure");
|
5
|
+
|
6
|
+
describe("time-value/ensure", function () {
|
7
|
+
it("Should return coerced value", function () { assert.equal(ensureTimeValue("12.23"), 12); });
|
8
|
+
it("Should crash on no value", function () {
|
9
|
+
try {
|
10
|
+
ensureTimeValue("foo");
|
11
|
+
throw new Error("Unexpected");
|
12
|
+
} catch (error) {
|
13
|
+
assert.equal(error.name, "TypeError");
|
14
|
+
assert.equal(error.message, "foo is not a time value");
|
15
|
+
}
|
16
|
+
});
|
17
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, ensureValue = require("../../value/ensure");
|
5
|
+
|
6
|
+
describe("value/ensure", function () {
|
7
|
+
it("Should return input value", function () {
|
8
|
+
var value = {};
|
9
|
+
assert.equal(ensureValue(value), value);
|
10
|
+
});
|
11
|
+
it("Should crash on no value", function () {
|
12
|
+
try {
|
13
|
+
ensureValue(null);
|
14
|
+
throw new Error("Unexpected");
|
15
|
+
} catch (error) {
|
16
|
+
assert.equal(error.name, "TypeError");
|
17
|
+
assert.equal(error.message, "Cannot use null");
|
18
|
+
}
|
19
|
+
});
|
20
|
+
});
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var assert = require("chai").assert
|
4
|
+
, isValue = require("../../value/is");
|
5
|
+
|
6
|
+
describe("value/is", function () {
|
7
|
+
it("Should return true on object", function () { assert.equal(isValue({}), true); });
|
8
|
+
it("Should return true on function", function () {
|
9
|
+
assert.equal(isValue(function () { return true; }), true);
|
10
|
+
});
|
11
|
+
it("Should return true on array", function () { assert.equal(isValue([]), true); });
|
12
|
+
if (typeof Object.create === "function") {
|
13
|
+
it("Should return true on object with no prototype", function () {
|
14
|
+
assert.equal(isValue(Object.create(null)), true);
|
15
|
+
});
|
16
|
+
}
|
17
|
+
it("Should return true on string", function () { assert.equal(isValue("foo"), true); });
|
18
|
+
it("Should return true on empty string", function () { assert.equal(isValue(""), true); });
|
19
|
+
it("Should return true on number", function () { assert.equal(isValue(123), true); });
|
20
|
+
it("Should return true on NaN", function () { assert.equal(isValue(NaN), true); });
|
21
|
+
it("Should return true on boolean", function () { assert.equal(isValue(false), true); });
|
22
|
+
if (typeof Symbol === "function") {
|
23
|
+
// eslint-disable-next-line no-undef
|
24
|
+
it("Should return true on symbol", function () { assert.equal(isValue(Symbol()), true); });
|
25
|
+
}
|
26
|
+
|
27
|
+
it("Should return false on null", function () { assert.equal(isValue(null), false); });
|
28
|
+
it("Should return false on undefined", function () { assert.equal(isValue(void 0), false); });
|
29
|
+
});
|
@@ -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 thenable object", arguments[1]);
|
9
|
+
};
|