Skip to content

Commit

Permalink
fix(accordion): adding unit tests
Browse files Browse the repository at this point in the history
• branches in accordion-panel were only 50% covered
• these tests bring them up to 100% coverage

Signed-off-by: Scott Mathis <[email protected]>
  • Loading branch information
Scott Mathis authored and mathisscott committed Nov 3, 2020
1 parent a82c3d5 commit 96b184d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 18 additions & 0 deletions packages/core/src/accordion/accordion-panel.element.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,22 @@ describe('accordion-panel element', () => {
expect(button).toBeDefined();
button.click();
});

it('should add the open class to the accordion header wrapper when expanded', async () => {
await componentIsStable(component);
const accordionHeaderWrapper = component.shadowRoot.querySelector('.accordion-header');
expect(accordionHeaderWrapper.classList.contains('open')).toBe(false);
component.expanded = true;
await componentIsStable(component);
expect(accordionHeaderWrapper.classList.contains('open')).toBe(true);
});

it('should add the disabled class to the accordion header wrapper when disabled', async () => {
await componentIsStable(component);
const accordionHeaderWrapper = component.shadowRoot.querySelector('.accordion-header');
expect(accordionHeaderWrapper.classList.contains('disabled')).toBe(false);
component.disabled = true;
await componentIsStable(component);
expect(accordionHeaderWrapper.classList.contains('disabled')).toBe(true);
});
});
1 change: 0 additions & 1 deletion packages/core/src/internal/base/button.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export class CdsBaseButton extends LitElement {
super.updated(props);
this.updateButtonAttributes();

// TODO: TESTME!
if (props.has('disabled')) {
const isDisabled = this.disabled;
if (isDisabled !== (this.ariaDisabled === 'true')) {
Expand Down

0 comments on commit 96b184d

Please sign in to comment.