Skip to content

Commit 2d5b2f9

Browse files
committed
Reworked the scoped styles acceptance test to stop comparing the entire text-decoration shorthand (which can vary across browsers) and instead assert the specific textDecorationLine and textDecorationColor values using getComputedStyle.
Added explicit existence checks before reading computed styles so the test fails loudly if expected elements go missing. Adjusted the negative expectation to ensure the non-addon component isn’t styled with underline rgb(0, 0, 0). With these changes the test now captures the intent (“underline in black”) while avoiding brittle string comparisons.
1 parent 19299bd commit 2d5b2f9

1 file changed

Lines changed: 33 additions & 7 deletions

File tree

test-app/tests/acceptance/scoped-css-test.ts

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,45 @@ module('Acceptance | scoped css', function (hooks) {
130130
test('an addon can use scoped styles', async function (assert) {
131131
await visit('/');
132132

133-
assert.dom('[data-scoped-underline-addon-component]').hasStyle({
134-
textDecoration: 'underline solid rgb(0, 0, 0)',
135-
});
133+
let underlineComponent = find('[data-scoped-underline-addon-component]');
134+
if (!underlineComponent) {
135+
throw new Error(
136+
'[data-scoped-underline-addon-component] element not found'
137+
);
138+
}
139+
let underlineComponentStyles = getComputedStyle(underlineComponent);
140+
assert.strictEqual(
141+
underlineComponentStyles.textDecorationLine,
142+
'underline'
143+
);
144+
assert.strictEqual(
145+
underlineComponentStyles.textDecorationColor,
146+
'rgb(0, 0, 0)'
147+
);
136148

137149
assert
138150
.dom('[data-test-underline-component-outside-addon]')
139151
.doesNotHaveStyle({
140-
textDecoration: 'underline solid rgb(0, 0, 0)',
152+
textDecoration: 'underline rgb(0, 0, 0)',
141153
});
142154

143-
assert.dom('[data-test-paragraph-with-class-styled-by-addon]').hasStyle({
144-
textDecoration: 'underline solid rgb(0, 0, 0)',
145-
});
155+
let classStyledParagraph = find(
156+
'[data-test-paragraph-with-class-styled-by-addon]'
157+
);
158+
if (!classStyledParagraph) {
159+
throw new Error(
160+
'[data-test-paragraph-with-class-styled-by-addon] element not found'
161+
);
162+
}
163+
let classStyledParagraphStyles = getComputedStyle(classStyledParagraph);
164+
assert.strictEqual(
165+
classStyledParagraphStyles.textDecorationLine,
166+
'underline'
167+
);
168+
assert.strictEqual(
169+
classStyledParagraphStyles.textDecorationColor,
170+
'rgb(0, 0, 0)'
171+
);
146172
});
147173

148174
test('unscoped styles can use interpolation', async function (assert) {

0 commit comments

Comments
 (0)