mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-10 15:54:42 +00:00
test: rename / remove duplicate unit tests
This commit is contained in:
parent
eefcdad013
commit
b89a4e49b9
8 changed files with 16 additions and 85 deletions
|
|
@ -88,9 +88,9 @@ describe('angular', function() {
|
||||||
expect(dst.a).not.toBe(src.a);
|
expect(dst.a).not.toBe(src.a);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should deeply copy an object into an existing object", function() {
|
it("should deeply copy an object into a non-existing object", function() {
|
||||||
var src = {a:{name:"value"}};
|
var src = {a:{name:"value"}};
|
||||||
var dst = copy(src, dst);
|
var dst = copy(src, undefined);
|
||||||
expect(src).toEqual({a:{name:"value"}});
|
expect(src).toEqual({a:{name:"value"}});
|
||||||
expect(dst).toEqual(src);
|
expect(dst).toEqual(src);
|
||||||
expect(dst).not.toBe(src);
|
expect(dst).not.toBe(src);
|
||||||
|
|
|
||||||
|
|
@ -1488,16 +1488,6 @@ describe('$compile', function() {
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
it('should not allow more then one isolate scope creation per element', inject(
|
|
||||||
function($rootScope, $compile) {
|
|
||||||
expect(function(){
|
|
||||||
$compile('<div class="iscope-a; iscope-b"></div>');
|
|
||||||
}).toThrowMinErr('$compile', 'multidir', 'Multiple directives [iscopeA, iscopeB] asking for isolated scope on: ' +
|
|
||||||
'<div class="iscope-a; iscope-b ng-isolate-scope ng-scope">');
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
it('should create new scope even at the root of the template', inject(
|
it('should create new scope even at the root of the template', inject(
|
||||||
function($rootScope, $compile, log) {
|
function($rootScope, $compile, log) {
|
||||||
element = $compile('<div scope-a></div>')($rootScope);
|
element = $compile('<div scope-a></div>')($rootScope);
|
||||||
|
|
@ -1824,24 +1814,6 @@ describe('$compile', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow setting of attributes', function() {
|
|
||||||
module(function() {
|
|
||||||
directive({
|
|
||||||
setter: valueFn(function(scope, element, attr) {
|
|
||||||
attr.$set('name', 'abc');
|
|
||||||
attr.$set('disabled', true);
|
|
||||||
expect(attr.name).toBe('abc');
|
|
||||||
expect(attr.disabled).toBe(true);
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
|
||||||
inject(function($rootScope, $compile) {
|
|
||||||
element = $compile('<div setter></div>')($rootScope);
|
|
||||||
expect(element.attr('name')).toEqual('abc');
|
|
||||||
expect(element.attr('disabled')).toEqual('disabled');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should create new instance of attr for each template stamping', function() {
|
it('should create new instance of attr for each template stamping', function() {
|
||||||
module(function($provide) {
|
module(function($provide) {
|
||||||
|
|
@ -2055,8 +2027,10 @@ describe('$compile', function() {
|
||||||
|
|
||||||
$rootScope.name = 'misko';
|
$rootScope.name = 'misko';
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
expect(componentScope.ref).toBe($rootScope.name);
|
|
||||||
expect(componentScope.refAlias).toBe($rootScope.name);
|
expect($rootScope.name).toBe('misko');
|
||||||
|
expect(componentScope.ref).toBe('misko');
|
||||||
|
expect(componentScope.refAlias).toBe('misko');
|
||||||
|
|
||||||
$rootScope.name = {};
|
$rootScope.name = {};
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
|
|
@ -2065,25 +2039,6 @@ describe('$compile', function() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should update local when origin changes', inject(function() {
|
|
||||||
compile('<div><span my-component ref="name">');
|
|
||||||
expect(componentScope.ref).toBe(undefined);
|
|
||||||
expect(componentScope.refAlias).toBe(componentScope.ref);
|
|
||||||
|
|
||||||
componentScope.ref = 'misko';
|
|
||||||
$rootScope.$apply();
|
|
||||||
expect($rootScope.name).toBe('misko');
|
|
||||||
expect(componentScope.ref).toBe('misko');
|
|
||||||
expect($rootScope.name).toBe(componentScope.ref);
|
|
||||||
expect(componentScope.refAlias).toBe(componentScope.ref);
|
|
||||||
|
|
||||||
componentScope.name = {};
|
|
||||||
$rootScope.$apply();
|
|
||||||
expect($rootScope.name).toBe(componentScope.ref);
|
|
||||||
expect(componentScope.refAlias).toBe(componentScope.ref);
|
|
||||||
}));
|
|
||||||
|
|
||||||
|
|
||||||
it('should update local when both change', inject(function() {
|
it('should update local when both change', inject(function() {
|
||||||
compile('<div><span my-component ref="name">');
|
compile('<div><span my-component ref="name">');
|
||||||
$rootScope.name = {mark:123};
|
$rootScope.name = {mark:123};
|
||||||
|
|
@ -3379,7 +3334,7 @@ describe('$compile', function() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should group on nested groups', inject(function($compile, $rootScope) {
|
it('should group on nested groups of same directive', inject(function($compile, $rootScope) {
|
||||||
$rootScope.show = false;
|
$rootScope.show = false;
|
||||||
element = $compile(
|
element = $compile(
|
||||||
'<div></div>' +
|
'<div></div>' +
|
||||||
|
|
@ -3427,7 +3382,7 @@ describe('$compile', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should throw error if unterminated', function () {
|
it('should throw error if unterminated (containing termination as a child)', function () {
|
||||||
module(function($compileProvider) {
|
module(function($compileProvider) {
|
||||||
$compileProvider.directive('foo', function() {
|
$compileProvider.directive('foo', function() {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -376,7 +376,7 @@ describe('$httpBackend', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should convert 0 to 200 if content - relative url', function() {
|
it('should convert 0 to 404 if no content - relative url', function() {
|
||||||
$backend = createHttpBackend($browser, MockXhr, null, null, null, 'file');
|
$backend = createHttpBackend($browser, MockXhr, null, null, null, 'file');
|
||||||
|
|
||||||
$backend('GET', '/whatever/index.html', null, callback);
|
$backend('GET', '/whatever/index.html', null, callback);
|
||||||
|
|
|
||||||
|
|
@ -717,17 +717,6 @@ describe('parser', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should call the function once when it is not part of the context', function() {
|
|
||||||
var count = 0;
|
|
||||||
scope.fn = function() {
|
|
||||||
count++;
|
|
||||||
return function() { return 'lucas'; };
|
|
||||||
};
|
|
||||||
expect(scope.$eval('fn()()')).toBe('lucas');
|
|
||||||
expect(count).toBe(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should call the function once when it is part of the context on assignments', function() {
|
it('should call the function once when it is part of the context on assignments', function() {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var element = {};
|
var element = {};
|
||||||
|
|
@ -766,7 +755,7 @@ describe('parser', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should call the function once when it is part of the context on array lookup function', function() {
|
it('should call the function once when it is part of the context on property lookup function', function() {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var element = {name: {anotherFn: function() { return 'lucas';} } };
|
var element = {name: {anotherFn: function() { return 'lucas';} } };
|
||||||
scope.fn = function() {
|
scope.fn = function() {
|
||||||
|
|
|
||||||
|
|
@ -1467,15 +1467,6 @@ describe('q', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should still reject the promise, when exception is thrown in success handler, even if exceptionHandler rethrows', function() {
|
|
||||||
deferred.promise.then(function() { throw 'reject'; }).then(null, errorSpy);
|
|
||||||
deferred.resolve('resolve');
|
|
||||||
mockNextTick.flush();
|
|
||||||
expect(exceptionExceptionSpy).toHaveBeenCalled();
|
|
||||||
expect(errorSpy).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should still reject the promise, when exception is thrown in success handler, even if exceptionHandler rethrows', function() {
|
it('should still reject the promise, when exception is thrown in success handler, even if exceptionHandler rethrows', function() {
|
||||||
deferred.promise.then(null, function() { throw 'reject again'; }).then(null, errorSpy);
|
deferred.promise.then(null, function() { throw 'reject again'; }).then(null, errorSpy);
|
||||||
deferred.reject('reject');
|
deferred.reject('reject');
|
||||||
|
|
|
||||||
|
|
@ -139,10 +139,6 @@ describe('SCE', function() {
|
||||||
expect($sce.trustAsHtml("")).toBe("");
|
expect($sce.trustAsHtml("")).toBe("");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should unwrap null into null', inject(function($sce) {
|
|
||||||
expect($sce.getTrusted($sce.HTML, null)).toBe(null);
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should unwrap "" into ""', inject(function($sce) {
|
it('should unwrap "" into ""', inject(function($sce) {
|
||||||
expect($sce.getTrusted($sce.HTML, "")).toBe("");
|
expect($sce.getTrusted($sce.HTML, "")).toBe("");
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
10
test/ngMock/angular-mocksSpec.js
vendored
10
test/ngMock/angular-mocksSpec.js
vendored
|
|
@ -168,7 +168,7 @@ describe('ngMock', function() {
|
||||||
$log.reset();
|
$log.reset();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it("should skip debugging output if disabled", inject(function($log) {
|
it("should skip debugging output if disabled (" + debugEnabled + ")", inject(function($log) {
|
||||||
$log.log('fake log');
|
$log.log('fake log');
|
||||||
$log.info('fake log');
|
$log.info('fake log');
|
||||||
$log.warn('fake log');
|
$log.warn('fake log');
|
||||||
|
|
@ -197,19 +197,19 @@ describe('ngMock', function() {
|
||||||
$log.reset();
|
$log.reset();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should provide the debug method', function() {
|
it('should provide the log method', function() {
|
||||||
expect(function() { $log.log(''); }).not.toThrow();
|
expect(function() { $log.log(''); }).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide the debug method', function() {
|
it('should provide the info method', function() {
|
||||||
expect(function() { $log.info(''); }).not.toThrow();
|
expect(function() { $log.info(''); }).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide the debug method', function() {
|
it('should provide the warn method', function() {
|
||||||
expect(function() { $log.warn(''); }).not.toThrow();
|
expect(function() { $log.warn(''); }).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide the debug method', function() {
|
it('should provide the error method', function() {
|
||||||
expect(function() { $log.error(''); }).not.toThrow();
|
expect(function() { $log.error(''); }).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -797,7 +797,7 @@ describe("resource", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should call the error callback if provided on non 2xx response', function() {
|
it('should call the error callback if provided on non 2xx response (without data)', function() {
|
||||||
$httpBackend.expect('GET', '/CreditCard').respond(ERROR_CODE, ERROR_RESPONSE);
|
$httpBackend.expect('GET', '/CreditCard').respond(ERROR_CODE, ERROR_RESPONSE);
|
||||||
|
|
||||||
CreditCard.get(callback, errorCB);
|
CreditCard.get(callback, errorCB);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue