-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9328c0
commit baf0796
Showing
5 changed files
with
67 additions
and
0 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
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,3 @@ | ||
import { normalizeString2 } from './-utils'; | ||
|
||
export default normalizeString2('match'); |
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,44 @@ | ||
import { match } from 'ember-awesome-macros/string'; | ||
import { raw } from 'ember-awesome-macros'; | ||
import { computed } from '@ember/object'; | ||
import { module, test } from 'qunit'; | ||
import compute from 'ember-macro-test-helpers/compute'; | ||
import sinon from 'sinon'; | ||
|
||
module('Integration | Macro | string | match'); | ||
|
||
test('it calls match on string', function(assert) { | ||
compute({ | ||
assert, | ||
computed: match('string', 'regex'), | ||
properties: { | ||
string: 'abcxyz', | ||
regex: /abc/ | ||
}, | ||
deepEqual: ['abc'] | ||
}); | ||
}); | ||
|
||
test('doesn\'t calculate when unnecessary', function(assert) { | ||
let callback = sinon.spy(); | ||
|
||
compute({ | ||
computed: match( | ||
undefined, | ||
computed(callback) | ||
) | ||
}); | ||
|
||
assert.notOk(callback.called); | ||
}); | ||
|
||
test('composable: it calls match on string', function(assert) { | ||
compute({ | ||
assert, | ||
computed: match( | ||
raw('abcxyz'), | ||
raw(/abc/) | ||
), | ||
deepEqual: ['abc'] | ||
}); | ||
}); |