Skip to content

Commit

Permalink
Add a failing test that checks if classNames in DOM reflect the compo…
Browse files Browse the repository at this point in the history
…nents classNames
  • Loading branch information
fpauser committed Aug 18, 2015
1 parent 2cd9ef7 commit 4d587dd
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -786,13 +786,15 @@ QUnit.test('non-block with each rendering child components', function() {
});

QUnit.test('specifying classNames results in correct class', function(assert) {
expect(1);
expect(3);

let clickyThing;
registry.register('component:some-clicky-thing', Component.extend({
tagName: 'button',
classNames: ['foo', 'bar'],
click() {
assert.ok(true, 'click was fired!');
init() {
this._super(...arguments);
clickyThing = this;
}
}));

Expand All @@ -805,6 +807,12 @@ QUnit.test('specifying classNames results in correct class', function(assert) {

let button = view.$('button');
ok(button.is('.foo.bar.baz.ember-view'), 'the element has the correct classes: ' + button.attr('class'));

let expectedClassNames = ['ember-view', 'foo', 'bar', 'baz'];
assert.deepEqual(clickyThing.get('classNames'), expectedClassNames, 'classNames are properly combined');

let buttonClassNames = button.attr('class');
assert.deepEqual(buttonClassNames.split(' '), expectedClassNames, 'all classes are set 1:1 in DOM');
});

QUnit.test('specifying custom concatenatedProperties avoids clobbering', function(assert) {
Expand Down Expand Up @@ -1310,4 +1318,3 @@ function equalsElement(element, tagName, attributes, content) {

QUnit.push(element.innerHTML === content, element.innerHTML, content, `The element had '${content}' as its content`);
}

0 comments on commit 4d587dd

Please sign in to comment.