-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUGFIX beta] fix for lastObject/firstObject update issue #15510
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,4 +54,26 @@ suite.test('[A,B,C].pushObject(X) => [A,B,C,X] + notify', function() { | |
equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); | ||
}); | ||
|
||
suite.test('[A,B,C,C].pushObject(A) => [A,B,C,C] + notify', function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 We'll need a test for removing the tail from a negative index There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added that, you could take another shot when you have time, thanks |
||
let before = this.newFixture(3); | ||
let item = before[2]; // note same object as current tail. should end up twice | ||
let after = [before[0], before[1], before[2], item]; | ||
let obj = this.newObject(before); | ||
let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); | ||
|
||
obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ | ||
|
||
obj.pushObject(item); | ||
|
||
deepEqual(this.toArray(obj), after, 'post item results'); | ||
equal(get(obj, 'length'), after.length, 'length'); | ||
|
||
equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); | ||
equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); | ||
equal(observer.timesCalled('length'), 1, 'should have notified length once'); | ||
|
||
equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject'); | ||
equal(observer.validate('lastObject'), true, 'should have notified lastObject'); | ||
}); | ||
|
||
export default suite; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,27 @@ suite.test('[A,B,C,D].replace(2,2) => [A,B] + notify', function() { | |
equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); | ||
}); | ||
|
||
suite.test('[A,B,C,D].replace(-1,1) => [A,B,C] + notify', function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
let before = this.newFixture(4); | ||
let after = [before[0], before[1], before[2]]; | ||
|
||
let obj = this.newObject(before); | ||
let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); | ||
|
||
obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ | ||
|
||
obj.replace(-1, 1); | ||
|
||
deepEqual(this.toArray(obj), after, 'post item results'); | ||
|
||
equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); | ||
equal(observer.timesCalled('@each'), 0, 'should not have notified @each once'); | ||
equal(observer.timesCalled('length'), 1, 'should have notified length once'); | ||
equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); | ||
|
||
equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once'); | ||
}); | ||
|
||
suite.test('Adding object should notify enumerable observer', function() { | ||
let fixtures = this.newFixture(4); | ||
let obj = this.newObject(fixtures); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍