Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

test(dccd): Add a test for swapping references #1253

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions test/change_detection/dirty_checking_change_detector_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,33 @@ void testWithGetterFactory(FieldGetterFactory getterFactory) {
removals: []));
});

it('should support switching refs - gh 1158', async(() {
var list = [0];

var record = detector.watch(list, null, null);
if (detector.collectChanges().moveNext()) {
detector.collectChanges();
}

record.object = [1, 0];
var iterator = detector.collectChanges()..moveNext();
expect(iterator.current.currentValue, toEqualCollectionRecord(
collection: ['1[null -> 0]', '0[0 -> 1]'],
previous: ['0[0 -> 1]'],
additions: ['1[null -> 0]'],
moves: ['0[0 -> 1]'],
removals: []));

record.object = [2, 1, 0];
iterator = detector.collectChanges()..moveNext();
expect(iterator.current.currentValue, toEqualCollectionRecord(
collection: ['2[null -> 0]', '1[null -> 1]', '0[0 -> 2]'],
previous: ['0[0 -> 2]'],
additions: ['2[null -> 0]', '1[null -> 1]'],
moves: ['0[0 -> 2]'],
removals: []));
}));

it('should handle swapping elements correctly', () {
var list = [1, 2];
var record = detector.watch(list, null, null);
Expand Down