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,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
|
+
});
|