-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from Turbo87/helper
Simplify testSelector() import
- Loading branch information
Showing
4 changed files
with
31 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"]`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}); | ||
|
||
export default testSelector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]'); | ||
}); |