-
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
Kelly Selden
committed
Nov 6, 2016
1 parent
fd6d9a7
commit 5e09c4b
Showing
6 changed files
with
120 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,10 @@ | ||
import computed from './computed'; | ||
|
||
export default function(...keys) { | ||
return computed(...keys, (object, constructor) => { | ||
if (constructor === undefined) { | ||
return undefined; | ||
} | ||
return object instanceof constructor; | ||
}); | ||
} |
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,7 @@ | ||
import computed from './computed'; | ||
|
||
export default function(...keys) { | ||
return computed(...keys, object => { | ||
return typeof object; | ||
}); | ||
} |
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,45 @@ | ||
import { instanceOf, raw } from 'ember-awesome-macros'; | ||
import { module, test } from 'qunit'; | ||
import compute from '../helpers/compute'; | ||
|
||
module('Integration | Macro | instance of'); | ||
|
||
test('lookup: object is instance of Object', function(assert) { | ||
compute({ | ||
assert, | ||
computed: instanceOf('key1', 'key2'), | ||
properties: { | ||
key1: {}, | ||
key2: Object | ||
}, | ||
expected: true | ||
}); | ||
}); | ||
|
||
test('lookup: object is not instance of String', function(assert) { | ||
compute({ | ||
assert, | ||
computed: instanceOf('key1', 'key2'), | ||
properties: { | ||
key1: {}, | ||
key2: String | ||
}, | ||
expected: false | ||
}); | ||
}); | ||
|
||
test('value: object is instance of Object', function(assert) { | ||
compute({ | ||
assert, | ||
computed: instanceOf({}, Object), | ||
expected: true | ||
}); | ||
}); | ||
|
||
test('composing: object is instance of Object', function(assert) { | ||
compute({ | ||
assert, | ||
computed: instanceOf(raw({}), raw(Object)), | ||
expected: true | ||
}); | ||
}); |
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,32 @@ | ||
import { typeOf, raw } from 'ember-awesome-macros'; | ||
import { module, test } from 'qunit'; | ||
import compute from '../helpers/compute'; | ||
|
||
module('Integration | Macro | type of'); | ||
|
||
test('lookup: object is type of object', function(assert) { | ||
compute({ | ||
assert, | ||
computed: typeOf('key1'), | ||
properties: { | ||
key1: {} | ||
}, | ||
expected: 'object' | ||
}); | ||
}); | ||
|
||
test('value: object is type of object', function(assert) { | ||
compute({ | ||
assert, | ||
computed: typeOf({}), | ||
expected: 'object' | ||
}); | ||
}); | ||
|
||
test('composing: object is type of object', function(assert) { | ||
compute({ | ||
assert, | ||
computed: typeOf(raw({})), | ||
expected: 'object' | ||
}); | ||
}); |