-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
9 changed files
with
108 additions
and
12 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
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 |
---|---|---|
|
@@ -4,6 +4,8 @@ import { module } from 'qunit'; | |
import sinon from 'sinon'; | ||
import compute from 'ember-macro-test-helpers/compute'; | ||
import namedTest from '../helpers/named-test'; | ||
import ArrayProxy from '@ember/array/proxy'; | ||
import { A as emberA } from '@ember/array'; | ||
|
||
const getReturnValue = 'get return value test'; | ||
const setReturnValue = 'set return value test'; | ||
|
@@ -186,6 +188,18 @@ namedTest('computed', 'function syntax: resolves array [] keys', function(assert | |
assert.deepEqual(getCallback.args[1], ['123']); | ||
}); | ||
|
||
namedTest('computed', 'function syntax: resolves ArrayProxy []', function(assert) { | ||
compute({ | ||
baseClass: ArrayProxy, | ||
computed: computed('[]', getCallback), | ||
properties: { | ||
content: emberA(['123']) | ||
} | ||
}); | ||
|
||
assert.deepEqual(getCallback.args[1][0].toArray(), ['123']); | ||
}); | ||
|
||
namedTest('computed', 'function syntax: resolves array @each keys', function(assert) { | ||
compute({ | ||
computed: computed('[email protected]', getCallback), | ||
|
@@ -197,6 +211,18 @@ namedTest('computed', 'function syntax: resolves array @each keys', function(ass | |
assert.deepEqual(getCallback.args[1], ['123']); | ||
}); | ||
|
||
namedTest('computed', 'function syntax: resolves ArrayProxy @each', function(assert) { | ||
compute({ | ||
baseClass: ArrayProxy, | ||
computed: computed('@each.key1', getCallback), | ||
properties: { | ||
content: emberA([{ key1: '123' }]) | ||
} | ||
}); | ||
|
||
assert.deepEqual(getCallback.args[1][0].toArray(), [{ key1: '123' }]); | ||
}); | ||
|
||
namedTest('computed', 'function syntax: expands properties', function(assert) { | ||
compute({ | ||
computed: computed('{key1,key2}', getCallback), | ||
|
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 |
---|---|---|
|
@@ -17,20 +17,41 @@ test('it collapses array.[]', function(assert) { | |
); | ||
}); | ||
|
||
test('it collapses []', function(assert) { | ||
assert.deepEqual( | ||
collapseKey('[]'), | ||
[''] | ||
); | ||
}); | ||
|
||
test('it collapses array.@each', function(assert) { | ||
assert.deepEqual( | ||
collapseKey('[email protected]'), | ||
['foo'] | ||
); | ||
}); | ||
|
||
test('it collapses @each', function(assert) { | ||
assert.deepEqual( | ||
collapseKey('@each.bar'), | ||
[''] | ||
); | ||
}); | ||
|
||
test('it collapses array.@each with brace expansion', function(assert) { | ||
assert.deepEqual( | ||
collapseKey('foo.@each.{bar,baz}'), | ||
['foo'] | ||
); | ||
}); | ||
|
||
test('it collapses @each with brace expansion', function(assert) { | ||
assert.deepEqual( | ||
collapseKey('@each.{bar,baz}'), | ||
[''] | ||
); | ||
}); | ||
|
||
test('it ignores string without brace expansion', function(assert) { | ||
assert.deepEqual( | ||
collapseKey('foo'), | ||
|
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 |
---|---|---|
|
@@ -57,6 +57,18 @@ test('it does not alter array.[] with empty keys', function(assert) { | |
assert.strictEqual(result, 'foo.bar.[]'); | ||
}); | ||
|
||
test('it does not alter []', function(assert) { | ||
let result = normalizeArrayKey('[]'); | ||
|
||
assert.strictEqual(result, '[]'); | ||
}); | ||
|
||
test('it does not alter [] with empty keys', function(assert) { | ||
let result = normalizeArrayKey('[]', []); | ||
|
||
assert.strictEqual(result, '[]'); | ||
}); | ||
|
||
test('it does not alter [email protected]', function(assert) { | ||
let result = normalizeArrayKey('[email protected]'); | ||
|
||
|
@@ -69,6 +81,18 @@ test('it does not alter [email protected] with empty keys', function(assert) { | |
assert.strictEqual(result, '[email protected]'); | ||
}); | ||
|
||
test('it does not alter @each.prop', function(assert) { | ||
let result = normalizeArrayKey('@each.prop'); | ||
|
||
assert.strictEqual(result, '@each.prop'); | ||
}); | ||
|
||
test('it does not alter @each.prop with empty keys', function(assert) { | ||
let result = normalizeArrayKey('@each.prop', []); | ||
|
||
assert.strictEqual(result, '@each.prop'); | ||
}); | ||
|
||
test('it watches array prop when raw array', function(assert) { | ||
let result = normalizeArrayKey('foo.bar', ['prop']); | ||
|
||
|