Visitar URL original
USWDS 2.13.2 by thisisdano · Pull Request #4560 · uswds/uswds · GitHub
Skip to content
Merged
Changes from 2 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b49ceb2
Update behavior spec to test expected behavior
aduth Oct 5, 2021
d9d4b91
Merge pull request #4473 from uswds/main
thisisdano Jan 20, 2022
52c5809
change aria-owns to aria-controls attribute
Jan 25, 2022
a46dbc3
Update CONTRIBUTING.md
jkjustjoshing Jan 25, 2022
590dc42
Bump cached-path-relative from 1.0.2 to 1.1.0
dependabot[bot] Jan 27, 2022
30a8a1b
added aria-owns to input
Jan 27, 2022
1241afd
reset to test preview link
Jan 27, 2022
7ac4e71
add aria-controls
Jan 27, 2022
23a8a1c
Remove inline style in GitHub icon
aduth Jan 29, 2022
61a0d99
Merge pull request #4482 from uswds/dependabot/npm_and_yarn/cached-pa…
Jan 31, 2022
70b8614
Bump node-fetch from 2.6.6 to 2.6.7
dependabot[bot] Jan 31, 2022
5b75542
Merge pull request #4489 from uswds/dependabot/npm_and_yarn/node-fetc…
Feb 8, 2022
d735036
Bump simple-get from 3.1.0 to 3.1.1
dependabot[bot] Feb 8, 2022
c0b0b4d
Merge pull request #4505 from uswds/dependabot/npm_and_yarn/simple-ge…
Feb 8, 2022
169e948
Repeat style fix for other copies of GitHub icon
aduth Feb 8, 2022
6a3eb1a
Bump follow-redirects from 1.14.7 to 1.14.8
dependabot[bot] Feb 15, 2022
60c0af4
Merge pull request #4522 from uswds/dependabot/npm_and_yarn/follow-re…
Feb 15, 2022
9a0c465
Merge pull request #4480 from jkjustjoshing/patch-1
thisisdano Feb 15, 2022
f0cde87
Merge pull request #4348 from aduth/aduth-behavior-spec
thisisdano Feb 15, 2022
30fab63
Merge pull request #4483 from uswds/al-combobox-508
thisisdano Feb 15, 2022
86636ea
Merge pull request #4487 from aduth/aduth-rm-icon-inline-style
thisisdano Feb 15, 2022
fe336de
adjust max-width for switch to collapsable footer, change cursor beha…
Feb 23, 2022
5c458e9
run prettier
Feb 23, 2022
12c1fdd
Change fractal output directory to standard Federalist setup.
Feb 24, 2022
f10b397
Point to new `_site` directory.
Feb 24, 2022
4945467
Merge pull request #4532 from uswds/jm-update-federalist-develop
thisisdano Feb 24, 2022
b1c1f20
Merge pull request #4531 from uswds/al-collapsible-480-bug
thisisdano Mar 1, 2022
a2037e7
Use partial pixel to support high dpi
thisisdano Mar 1, 2022
11e7344
Merge pull request #4551 from uswds/dw-update-breakpoint
thisisdano Mar 3, 2022
b54b7e2
Update dependencies
thisisdano Mar 7, 2022
43e1a50
Update refs to 2.13.2
thisisdano Mar 7, 2022
aea4019
Use current snyk orb
thisisdano Mar 7, 2022
cd80845
Update csso
thisisdano Mar 7, 2022
cdfb7b5
2.13.2
thisisdano Mar 7, 2022
98e0479
Create uswds-2.13.2-zip-hash.txt
thisisdano Mar 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 25 additions & 49 deletions spec/unit/utils/behavior.spec.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,58 @@
/* eslint-disable */
// TODO: many of these dont test anything, use spies to ensure the methods are being called
const sinon = require("sinon");
const assert = require("assert");
const Behavior = require("../../../src/js/utils/behavior");
const behavior = require("../../../src/js/utils/behavior");

describe("behavior", () => {
it("returns an object", () => {
const behavior = Behavior({});
assert(behavior && typeof behavior === "object");
const component = behavior({});
assert(component && typeof component === "object");
});

it("has on() and off() methods", () => {
const behavior = Behavior({});
assert.strictEqual(typeof behavior.on, "function");
assert.strictEqual(typeof behavior.off, "function");
const component = behavior({});
assert.strictEqual(typeof component.on, "function");
assert.strictEqual(typeof component.off, "function");
});

describe("behavior.on()", () => {
it("calls init()", () => {
const behavior = Behavior({
init() {
done();
},
});
behavior.on();
const init = sinon.spy();
behavior({}, { init }).on();
assert(init.calledOnce);
});

it("passes document.body if no target is provided", () => {
const behavior = Behavior({
init(target) {
assert.strictEqual(target, document.body);
done();
},
});
behavior.on();
const init = sinon.spy();
behavior({}, { init }).on();
assert(init.calledWithExactly(document.body));
});

it("passes the right element if a target is provided", () => {
const init = sinon.spy();
const el = document.createElement("div");
const behavior = Behavior({
init(target) {
assert.strictEqual(target, el);
done();
},
});
behavior.on(el);
behavior({}, { init }).on(el);
assert(init.calledWithExactly(el));
});
});

describe("behavior.off()", () => {
it("calls teardown()", () => {
const behavior = Behavior({
teardown() {
done();
},
});
behavior.off();
const teardown = sinon.spy();
behavior({}, { teardown }).off();
assert(teardown.calledOnce);
});

it("passes document.body if no target is provided", () => {
const behavior = Behavior({
teardown(target) {
assert.strictEqual(target, document.body);
done();
},
});
behavior.off();
const teardown = sinon.spy();
behavior({}, { teardown }).off();
assert(teardown.calledWithExactly(document.body));
});

it("passes the right element if a target is provided", () => {
const teardown = sinon.spy();
const el = document.createElement("div");
const behavior = Behavior({
teardown(target) {
assert.strictEqual(target, el);
done();
},
});
behavior.off(el);
behavior({}, { teardown }).off(el);
assert(teardown.calledWithExactly(el));
});
});
});
/** eslint-enable */