Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ngClass[Odd/Even] overhaul #15228

Closed
wants to merge 15 commits into from
Closed
Changes from 1 commit
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
56 changes: 56 additions & 0 deletions test/ng/directive/ngClassSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,62 @@ fdescribe('ngClass', function() {
})
);

it('should do value stabilization as expected when one-time binding',
inject(function($rootScope, $compile) {
element = $compile('<div ng-class="::className"></div>')($rootScope);
$rootScope.$digest();

$rootScope.className = 'foo';
$rootScope.$digest();
expect(element).toHaveClass('foo');

$rootScope.className = 'bar';
$rootScope.$digest();
expect(element).toHaveClass('foo');
})
);

it('should remove the watcher when static array one-time binding',
inject(function($rootScope, $compile) {
element = $compile('<div ng-class="::[className]"></div>')($rootScope);
$rootScope.$digest();

$rootScope.$apply('className = "foo"');
expect(element).toHaveClass('foo');

$rootScope.$apply('className = "bar"');
expect(element).toHaveClass('foo');
expect(element).not.toHaveClass('bar');
})
);

it('should do value remove the watcher when static map one-time binding',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test description here seems like a hybrid of the two tests above :-)

inject(function($rootScope, $compile) {
element = $compile('<div ng-class="::{foo: fooPresent}"></div>')($rootScope);
$rootScope.$digest();

$rootScope.fooPresent = true;
$rootScope.$digest();
expect(element).toHaveClass('foo');

$rootScope.fooPresent = false;
$rootScope.$digest();
expect(element).toHaveClass('foo');
})
);

it('should track changes of mutating object inside an array',
inject(function($rootScope, $compile) {
$rootScope.classVar = [{orange: true}];
element = $compile('<div ng-class="classVar"></div>')($rootScope);
$rootScope.$digest();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding an expectation that it should have the class "orange" here?


$rootScope.classVar[0].orange = false;
$rootScope.$digest();

expect(element).not.toHaveClass('orange');
})
);
});

describe('ngClass animations', function() {
Expand Down