Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get Array tests running again and fix duplicate notifications.
- Loading branch information
Showing
14 changed files
with
228 additions
and
163 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
58 changes: 58 additions & 0 deletions
58
packages/ember-runtime/tests/suites/mutable_array/addObject.js
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,58 @@ | ||
// ========================================================================== | ||
// Project: Ember Runtime | ||
// Copyright: ©2011 Strobe Inc. and contributors. | ||
// License: Licensed under MIT license (see license.js) | ||
// ========================================================================== | ||
|
||
require('ember-runtime/~tests/suites/mutable_array'); | ||
|
||
var suite = Ember.MutableArrayTests; | ||
|
||
suite.module('addObject'); | ||
|
||
suite.test("should return receiver", function() { | ||
var before, obj; | ||
before = this.newFixture(3); | ||
obj = this.newObject(before); | ||
equal(obj.addObject(before[1]), obj, 'should return receiver'); | ||
}); | ||
|
||
suite.test("[A,B].addObject(C) => [A,B,C] + notify", function() { | ||
var obj, before, after, observer, item; | ||
|
||
before = this.newFixture(2); | ||
item = this.newFixture(1)[0]; | ||
after = [before[0], before[1], item]; | ||
obj = this.newObject(before); | ||
observer = this.newObserver(obj, '@each', 'length'); | ||
|
||
obj.addObject(item); | ||
|
||
deepEqual(this.toArray(obj), after, 'post item results'); | ||
equal(Ember.get(obj, 'length'), after.length, 'length'); | ||
|
||
if (observer.isEnabled) { | ||
equal(observer.timesCalled('@each'), 1, 'should have notified @each once'); | ||
equal(observer.timesCalled('length'), 1, 'should have notified length once'); | ||
} | ||
}); | ||
|
||
suite.test("[A,B,C].addObject(A) => [A,B,C] + NO notify", function() { | ||
var obj, before, after, observer, item; | ||
|
||
before = this.newFixture(3); | ||
after = before; | ||
item = before[0]; | ||
obj = this.newObject(before); | ||
observer = this.newObserver(obj, '@each', 'length'); | ||
|
||
obj.addObject(item); // note: item in set | ||
|
||
deepEqual(this.toArray(obj), after, 'post item results'); | ||
equal(Ember.get(obj, 'length'), after.length, 'length'); | ||
|
||
if (observer.isEnabled) { | ||
equal(observer.validate('@each'), false, 'should NOT have notified @each'); | ||
equal(observer.validate('length'), false, 'should NOT have notified length'); | ||
} | ||
}); |
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
Oops, something went wrong.