diff --git a/packages/qunit-dom/lib/__tests__/has-style.ts b/packages/qunit-dom/lib/__tests__/has-style.ts index c02282e3a..d6f3af590 100644 --- a/packages/qunit-dom/lib/__tests__/has-style.ts +++ b/packages/qunit-dom/lib/__tests__/has-style.ts @@ -139,4 +139,20 @@ describe('assert.dom(...).hasStyle()', () => { expect(assert.results.length).toEqual(2); }); + + test('succeeds for checking styles using camelCase property as argument', () => { + assert.dom('.foo').hasStyle({ + opacity: '1', + width: '200px', + textAlign: 'center', + }); + expect(assert.results).toEqual([ + { + actual: { opacity: '1', width: '200px', textAlign: 'center' }, + expected: { opacity: '1', width: '200px', textAlign: 'center' }, + message: 'Element .foo has style "{"opacity":"1","width":"200px","textAlign":"center"}"', + result: true, + }, + ]); + }); }); diff --git a/packages/qunit-dom/lib/assertions.ts b/packages/qunit-dom/lib/assertions.ts index b75069617..68e646b93 100644 --- a/packages/qunit-dom/lib/assertions.ts +++ b/packages/qunit-dom/lib/assertions.ts @@ -774,12 +774,16 @@ export default class DOMAssertions { } let result = expectedProperties.every( - property => computedStyle.getPropertyValue(property.toString()) === expected[property] + property => + (computedStyle.getPropertyValue(property.toString()) || computedStyle[property]) === + expected[property] ); let actual: ActualCSSStyleDeclaration = {}; expectedProperties.forEach( - property => (actual[property] = computedStyle.getPropertyValue(property.toString())) + property => + (actual[property] = + computedStyle.getPropertyValue(property.toString()) || computedStyle[property]) ); if (!message) {