Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hasStyle / doesNotHaveStyle: empty expected should throw #555

Closed
buschtoens opened this issue Nov 27, 2019 · 1 comment · Fixed by #608
Closed

hasStyle / doesNotHaveStyle: empty expected should throw #555

buschtoens opened this issue Nov 27, 2019 · 1 comment · Fixed by #608

Comments

@buschtoens
Copy link

buschtoens commented Nov 27, 2019

I've encountered usages like this in the wild:

test('button can toggle color', function(assert) {
  await render(hbs`<ToggleColorButton class=".btn" @on="#00FF00" />`);
  
  // toggle on the button
  await click('.btn');

  // button has `on` color
  assert.dom('btn').hasStyle({ backgroundColor: '#00FF00' });

  // toggle the button off again
  await click('.btn');

  // `on` color has been removed
  assert.dom('btn').hasStyle({});
});

The last LOC incorrectly assumes, that hasStyle({}) asserts that all "custom" styles have been removed. In reality hasStyle({}) does not assert anything:

https://github.com/simplabs/qunit-dom/blob/2a73e56344829a6f1fd3b28cd5df6b4ee1d00b75/lib/assertions.ts#L583-L586

I would suggest to throw an error or fail the assertion, when an empty object is passed to hasStyle, as this can never be a valid assertion and is most likely a mistake of the author of the test.

@Turbo87
Copy link
Collaborator

Turbo87 commented Nov 27, 2019

agreed, seems reasonable to show a helpful error message in those cases 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants