-
-
Notifications
You must be signed in to change notification settings - Fork 805
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'christoshrousis-test/badge' into next
- Loading branch information
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { expect, fixture, html } from '@open-wc/testing'; | ||
|
||
import '../../../dist/shoelace.js'; | ||
import type SlBadge from './badge'; | ||
|
||
describe('<sl-badge>', () => { | ||
let el; | ||
|
||
describe('when provided no parameters', async () => { | ||
before(async () => { | ||
el = await fixture<SlBadge>(html` <sl-badge>Badge</sl-badge> `); | ||
}); | ||
|
||
it('should render a component that passes accessibility test, with a role of status on the base part.', async () => { | ||
await expect(el).to.be.accessible(); | ||
|
||
const part = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; | ||
expect(part.getAttribute('role')).to.eq('status'); | ||
}); | ||
|
||
it('should render the child content provided', async () => { | ||
expect(el.innerText).to.eq('Badge'); | ||
}); | ||
|
||
it('should default to square styling, with the primary color', async () => { | ||
const part = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; | ||
expect(part.classList.value).to.eq('badge badge--primary'); | ||
}); | ||
}); | ||
|
||
describe('when provided a pill parameter', async () => { | ||
before(async () => { | ||
el = await fixture<SlBadge>(html` <sl-badge pill>Badge</sl-badge> `); | ||
}); | ||
|
||
it('should render a component that passes accessibility test', async () => { | ||
await expect(el).to.be.accessible(); | ||
}); | ||
|
||
it('should append the pill class to the classlist to render a pill', async () => { | ||
const part = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; | ||
expect(part.classList.value).to.eq('badge badge--primary badge--pill'); | ||
}); | ||
}); | ||
|
||
describe('when provided a pulse parameter', async () => { | ||
before(async () => { | ||
el = await fixture<SlBadge>(html` <sl-badge pulse>Badge</sl-badge> `); | ||
}); | ||
|
||
it('should render a component that passes accessibility test', async () => { | ||
await expect(el).to.be.accessible(); | ||
}); | ||
|
||
it('should append the pulse class to the classlist to render a pulse', async () => { | ||
const part = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; | ||
expect(part.classList.value).to.eq('badge badge--primary badge--pulse'); | ||
}); | ||
}); | ||
|
||
['primary', 'success', 'neutral', 'warning', 'danger'].forEach(type => { | ||
describe(`when passed a type attribute ${type}`, () => { | ||
before(async () => { | ||
el = await fixture<SlBadge>(html`<sl-badge type="${type}">Badge</sl-badge>`); | ||
}); | ||
|
||
it('should render a component that passes accessibility test', async () => { | ||
await expect(el).to.be.accessible(); | ||
}); | ||
|
||
it('should default to square styling, with the primary color', async () => { | ||
const part = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; | ||
expect(part.classList.value).to.eq(`badge badge--${type}`); | ||
}); | ||
}); | ||
}); | ||
}); |