forked from emberjs/ember.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX beta] Add a failing test for emberjs#12212
Demonstrates issues with Ember.computed.sort used on class with multiple instances.
- Loading branch information
Showing
1 changed file
with
27 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1224,13 +1224,15 @@ QUnit.test('sorts correctly as only one property changes', function() { | |
}); | ||
|
||
|
||
var klass; | ||
QUnit.module('sort - concurrency', { | ||
setup() { | ||
obj = EmberObject.extend({ | ||
klass = EmberObject.extend({ | ||
sortProps: ['count'], | ||
sortedItems: sort('items', 'sortProps'), | ||
customSortedItems: sort('[email protected]', (a, b) => a.count - b.count) | ||
}).create({ | ||
}); | ||
obj = klass.create({ | ||
items: emberA([ | ||
{ name: 'A', count: 1 }, | ||
{ name: 'B', count: 2 }, | ||
|
@@ -1255,7 +1257,7 @@ QUnit.test('sorts correctly after mutation to the sort properties', function() { | |
deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); | ||
}); | ||
|
||
QUnit.test('sort correctl after mutation to the sor ', function() { | ||
QUnit.test('sort correctly after mutation to the sort', function() { | ||
deepEqual(obj.get('customSortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); | ||
|
||
set(obj.get('items')[1], 'count', 5); | ||
|
@@ -1266,6 +1268,28 @@ QUnit.test('sort correctl after mutation to the sor ', function() { | |
deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); | ||
}); | ||
|
||
QUnit.test('sort correctly on multiple instances of the same class', function() { | ||
var obj2 = klass.create({ | ||
items: Ember.A([ | ||
{ name: 'W', count: 23 }, | ||
{ name: 'X', count: 24 }, | ||
{ name: 'Y', count: 25 }, | ||
{ name: 'Z', count: 26 } | ||
]) | ||
}); | ||
|
||
deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); | ||
deepEqual(obj2.get('sortedItems').mapBy('name'), ['W', 'X', 'Y', 'Z'], 'initial'); | ||
|
||
set(obj.get('items')[1], 'count', 5); | ||
set(obj.get('items')[2], 'count', 6); | ||
set(obj2.get('items')[1], 'count', 27); | ||
set(obj2.get('items')[2], 'count', 28); | ||
|
||
deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'D', 'B', 'C'], 'final'); | ||
deepEqual(obj2.get('sortedItems').mapBy('name'), ['W', 'Z', 'X', 'Y'], 'final'); | ||
}); | ||
|
||
QUnit.module('max', { | ||
setup() { | ||
obj = EmberObject.extend({ | ||
|