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

Commit 774a336

Browse files
test(compile): add test for ng-attr-data-src
1 parent 76f3bb0 commit 774a336

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/ng/compileSpec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12118,6 +12118,32 @@ describe('$compile', function() {
1211812118
expect(element.attr('dash-test4')).toBe('JamieMason');
1211912119
}));
1212012120

12121+
it('should work with img[src]', inject(function() {
12122+
$rootScope.name = 'some-image.png';
12123+
element = $compile('<img ng-attr-src="{{name}}">')($rootScope);
12124+
expect(element.attr('src')).toBeUndefined();
12125+
12126+
$rootScope.$digest();
12127+
expect(element.attr('src')).toBe('some-image.png');
12128+
12129+
$rootScope.name = 'other-image.png';
12130+
$rootScope.$digest();
12131+
expect(element.attr('src')).toBe('other-image.png');
12132+
}));
12133+
12134+
it('should work with img[data-src]', inject(function() {
12135+
$rootScope.name = 'some-image.png';
12136+
element = $compile('<img ng-attr-data-src="{{name}}">')($rootScope);
12137+
expect(element.attr('data-src')).toBeUndefined();
12138+
12139+
$rootScope.$digest();
12140+
expect(element.attr('data-src')).toBe('some-image.png');
12141+
12142+
$rootScope.name = 'other-image.png';
12143+
$rootScope.$digest();
12144+
expect(element.attr('data-src')).toBe('other-image.png');
12145+
}));
12146+
1212112147
it('should keep attributes ending with -start single-element directives', function() {
1212212148
module(function($compileProvider) {
1212312149
$compileProvider.directive('dashStarter', function(log) {

0 commit comments

Comments
 (0)