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

Simplify testSelector() import #43

Merged
merged 1 commit into from
Jan 11, 2017
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
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,10 @@ and integration tests:
* `testSelector('post-title')`: Returns a selector `[data-test-post-title]`
* `testSelector('resource-id', '2')`: Returns a selector `[data-test-resource-id="2"]`

The test helpers can be imported from the `helpers/ember-test-selectors`
module:
The test helpers can be imported from the `ember-test-selectors` module:

```javascript
import testSelector from '<app-name>/tests/helpers/ember-test-selectors';
import testSelector from 'ember-test-selectors';
```

### Acceptance Test Usage
Expand Down
5 changes: 5 additions & 0 deletions addon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Ember from 'ember';

export default function testSelector(key, value) {
return Ember.isNone(value) ? `[data-test-${key}]` : `[data-test-${key}="${value}"]`;
}
16 changes: 10 additions & 6 deletions test-support/helpers/ember-test-selectors.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import Ember from 'ember';
import testSelector from 'ember-test-selectors';

const {
isNone
} = Ember;
let message = 'Importing testSelector() from "<appname>/tests/helpers/ember-test-selectors" is deprecated. ' +
'Please import testSelector() from "ember-test-selectors" instead.';

export default function testSelector(key, value) {
return isNone(value) ? `[data-test-${key}]` : `[data-test-${key}="${value}"]`;
}
Ember.deprecate(message, false, {
id: 'ember-test-selectors.test-selector-import',
until: '0.1.0',
url: 'https://github.com/simplabs/ember-test-selectors#test-helpers',
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we're pre 1.0.0 we can (and I think should for simplicity's sake) just remove this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so far we haven't introduced any breaking changes and removing this would be a breaking change without any deprecation first. I'm not a fan of breaking API without deprecations if deprecations are possible in a simple way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, cool - I just want to make sure we get rid of this until 1.0.0.


export default testSelector;
14 changes: 14 additions & 0 deletions tests/unit/test-selector-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { module, test } from 'qunit';

import testSelector from 'ember-test-selectors';

module('Unit | testSelector() from "ember-test-selectors"');

test('expands a selector name and attribute value corretly', function(assert) {
assert.equal(testSelector('selector', 'welcome-text'), '[data-test-selector="welcome-text"]');
assert.equal(testSelector('selector', 0), '[data-test-selector="0"]');
});

test('expands a selector name without attribute value corretly', function(assert) {
assert.equal(testSelector('selector'), '[data-test-selector]');
});