Skip to content

Commit add9d3d

Browse files
committed
test(tabs): refactor tests
1 parent c68ed26 commit add9d3d

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

elements/pfe-tabs/test/pfe-tabs.spec.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('<pfe-tabs>', function() {
7777
tab!.setAttribute('active', '');
7878
await nextFrame();
7979
expect(tab!.hasAttribute('active')).to.equal(true);
80-
expect(tab!.getAttribute('aria-selected')).to.equal('true');
80+
expect(tab!.ariaSelected).to.equal('true');
8181
});
8282

8383
it('should activate tab when activeIndex property is changed', async function() {
@@ -88,7 +88,7 @@ describe('<pfe-tabs>', function() {
8888
await nextFrame();
8989
const tab = el.querySelector('pfe-tab:first-of-type');
9090
expect(tab!.hasAttribute('active')).to.equal(true);
91-
expect(tab!.getAttribute('aria-selected')).to.equal('true');
91+
expect(tab!.ariaSelected).to.equal('true');
9292
});
9393

9494
it('should open panel at same index of selected tab', async function() {
@@ -119,16 +119,16 @@ describe('<pfe-tabs>', function() {
119119
await setViewport({ width: 320, height: 640 });
120120
});
121121

122-
it('should aria-disable the tab', async function() {
122+
it('should aria-disable the tab if disabled', async function() {
123123
const el = await createFixture<PfeTabs>(TEMPLATE);
124124
const disabledTab = el.querySelector('pfe-tab:nth-of-type(2)')! as BaseTab;
125125
disabledTab.disabled = true;
126126
await nextFrame();
127-
const ariaDisabled = disabledTab!.hasAttribute('aria-disabled');
128-
expect(ariaDisabled).to.equal(true);
127+
const { ariaDisabled } = disabledTab!;
128+
expect(ariaDisabled).to.equal('true');
129129
});
130130

131-
it('should have disabled styles', async function() {
131+
it('should have disabled css styles if disabled', async function() {
132132
const el = await createFixture<PfeTabs>(TEMPLATE);
133133
const disabledTab = el.querySelector('pfe-tab:first-of-type')!;
134134
disabledTab.setAttribute('disabled', 'disabled');
@@ -138,7 +138,7 @@ describe('<pfe-tabs>', function() {
138138
expect(disabledStyles).to.equal('rgb(245, 245, 245)');
139139
});
140140

141-
it('should have disabled styles if aria-disabled attribute is true', async function() {
141+
it('should have disabled css styles if aria-disabled attribute is true', async function() {
142142
const el = await createFixture<PfeTabs>(TEMPLATE);
143143
const disabledTab = el.querySelector('pfe-tab:first-of-type')!;
144144
disabledTab.setAttribute('aria-disabled', 'true');
@@ -163,7 +163,9 @@ describe('<pfe-tabs>', function() {
163163

164164
it('should have visible scroll buttons if overflowed', async function() {
165165
const el = await createFixture<PfeTabs>(TEMPLATE);
166-
await aTimeout(BaseTabs.scrollTimeoutDelay);
166+
// Property 'scrollTimeoutDelay' is protected and only accessible within class 'PfeTabs' and its subclasses.
167+
// using 150 as a static representation.
168+
await aTimeout(150);
167169
const previousTab = el.shadowRoot!.querySelector('#previousTab')!;
168170
const nextTab = el.shadowRoot!.querySelector('#nextTab')!;
169171
const prevDisplayStyle = getComputedStyle(previousTab).display;

0 commit comments

Comments
 (0)