Skip to content

Commit

Permalink
Add behavior specs
Browse files Browse the repository at this point in the history
  • Loading branch information
anselmbradford committed Nov 7, 2024
1 parent 811f4a1 commit dd956be
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ body = """
{% if previous.version %}\
## [{{ version | trim_start_matches(pat="v") }}](<REPO>/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(timezone="America/New_York", format="%Y-%m-%d") }}
{% endif %}\
{% else %}\
## [unreleased]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('atomic-helpers', () => {
'Check that element is a DOM node with ' +
`class ".${testClass}"`;
/**
*
* Mock error function.
*/
function errFunc() {
checkDom(null, testClass);
Expand All @@ -68,7 +68,7 @@ describe('atomic-helpers', () => {
it('should throw an error if element class not found', () => {
const errMsg = 'mock-class not found on or in passed DOM node.';
/**
*
* Mock error function.
*/
function errFunc() {
checkDom(componentDom, 'mock-class');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { checkBehaviorDom, behaviorFind } from './behavior.js';

let containerDom;

const HTML_SNIPPET = `
<div id="container" data-js-hook="behavior_flyout-menu">
<button data-js-hook="behavior_flyout-menu_trigger">
<div data-js-hook="behavior_flyout-menu_content">…</div>
</div>
`;

describe('behaviors', () => {
beforeEach(() => {
document.body.innerHTML = HTML_SNIPPET;
containerDom = document.querySelector('#container');
});

describe('.checkBehaviorDom()', () => {
it('should return an HTML element', () => {
expect(
checkBehaviorDom(
containerDom,
'behavior_flyout-menu_content',
).getAttribute('data-js-hook'),
).toBe('behavior_flyout-menu_content');
});
});

describe('.behaviorFind()', () => {
it('should return an array with two items when selectors are found', () => {
const result = behaviorFind('flyout-menu', containerDom);
expect(result).toBeInstanceOf(NodeList);
expect(result.length).toBe(2);
});
});
});

0 comments on commit dd956be

Please sign in to comment.