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

Add context argument assertions to the find and findAll helpers #358

Merged
merged 1 commit into from
Apr 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions addon-test-support/@ember/test-helpers/dom/find-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ export default function find(selector) {
throw new Error('Must pass a selector to `findAll`.');
}

if (arguments.length > 1) {
throw new Error('The `findAll` test helper only takes a single argument.');
}

return toArray(getElements(selector));
}
4 changes: 4 additions & 0 deletions addon-test-support/@ember/test-helpers/dom/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ export default function find(selector) {
throw new Error('Must pass a selector to `find`.');
}

if (arguments.length > 1) {
throw new Error('The `find` test helper only takes a single argument.');
}

return getElement(selector);
}
6 changes: 6 additions & 0 deletions tests/unit/dom/find-all-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,10 @@ module('DOM Helper: findAll', function(hooks) {
findAll('#foo');
}, /Must setup rendering context before attempting to interact with elements/);
});

test('throws if context argument is passed in', function(assert) {
assert.throws(() => {
findAll('#foo', document.querySelector('#ember-testing'));
}, /The `findAll` test helper only takes a single argument./);
});
});
6 changes: 6 additions & 0 deletions tests/unit/dom/find-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,10 @@ module('DOM Helper: find', function(hooks) {
find('#foo');
}, /Must setup rendering context before attempting to interact with elements/);
});

test('throws if context argument is passed in', function(assert) {
assert.throws(() => {
find('#foo', document.querySelector('#ember-testing'));
}, /The `find` test helper only takes a single argument./);
});
});