Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
feat(loaders): addition to e7516dc #1080 (disable legacy $http cbs)
Browse files Browse the repository at this point in the history
This disables the legacy promise's methods via `$http.useLegacyPromiseExtensions(false)` in tests (avoiding regressions).

Available since AngularJS 1.4
  • Loading branch information
ghostd authored and knalli committed Sep 13, 2015
1 parent 664411f commit 233a012
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
39 changes: 37 additions & 2 deletions test/unit/service/loader-partial.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,11 @@ describe('pascalprecht.translate', function() {

describe('$translatePartialLoader', function () {

beforeEach(module('pascalprecht.translate'));
beforeEach(module('pascalprecht.translate', function ($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
}));

var $translatePartialLoader, $rootScope;

Expand Down Expand Up @@ -457,7 +461,11 @@ describe('pascalprecht.translate', function() {

describe('$translatePartialLoader', function () {

beforeEach(module('pascalprecht.translate'));
beforeEach(module('pascalprecht.translate', function ($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
}));

it('should use error handler if it is specified', function() {
inject(function($translatePartialLoader, $httpBackend) {
Expand Down Expand Up @@ -513,6 +521,9 @@ describe('pascalprecht.translate', function() {
counter = 0;

module(function($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
$httpProvider.defaults.transformRequest.push(CounterHttpInterceptor);
});

Expand All @@ -536,6 +547,9 @@ describe('pascalprecht.translate', function() {
counter = 0;

module(function($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
$httpProvider.defaults.transformRequest.push(CounterHttpInterceptor);
});

Expand Down Expand Up @@ -564,6 +578,9 @@ describe('pascalprecht.translate', function() {
it('shouldn\'t load a part if it was loaded, deleted and added again', function() {
counter = 0;
module(function($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
$httpProvider.defaults.transformRequest.push(CounterHttpInterceptor);
});

Expand Down Expand Up @@ -594,6 +611,9 @@ describe('pascalprecht.translate', function() {
counter = 0;

module(function($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
$httpProvider.defaults.transformRequest.push(CounterHttpInterceptor);
});

Expand Down Expand Up @@ -621,6 +641,9 @@ describe('pascalprecht.translate', function() {

it('should put a part into a cache and remove from the cache if the part was deleted', function() {
module(function($httpProvider, $translateProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
$httpProvider.defaults.transformRequest.push(CounterHttpInterceptor);
$translateProvider.useLoaderCache();
});
Expand Down Expand Up @@ -656,6 +679,9 @@ describe('pascalprecht.translate', function() {
counter = 0;

module(function($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
$httpProvider.defaults.transformRequest.push(CounterHttpInterceptor);
});

Expand All @@ -682,6 +708,9 @@ describe('pascalprecht.translate', function() {
counter = 0;

module(function($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
$httpProvider.defaults.transformRequest.push(CounterHttpInterceptor);
});

Expand Down Expand Up @@ -716,6 +745,9 @@ describe('pascalprecht.translate', function() {
it('shouldn\'t load a part if it was loaded, deleted and added again', function() {
counter = 0;
module(function($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
$httpProvider.defaults.transformRequest.push(CounterHttpInterceptor);
});

Expand Down Expand Up @@ -752,6 +784,9 @@ describe('pascalprecht.translate', function() {
counter = 0;

module(function($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
$httpProvider.defaults.transformRequest.push(CounterHttpInterceptor);
});

Expand Down
12 changes: 10 additions & 2 deletions test/unit/service/loader-static-files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ describe('pascalprecht.translate', function () {

var $translate, $httpBackend, $translateStaticFilesLoader, $translationCache;

beforeEach(module('pascalprecht.translate'));
beforeEach(module('pascalprecht.translate', function ($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
}));

beforeEach(inject(function (_$translate_, _$httpBackend_, _$translateStaticFilesLoader_, _$translationCache_) {
$httpBackend = _$httpBackend_;
Expand Down Expand Up @@ -88,7 +92,11 @@ describe('pascalprecht.translate', function () {

var $translate, $httpBackend, $translateStaticFilesLoader;

beforeEach(module('pascalprecht.translate'));
beforeEach(module('pascalprecht.translate', function ($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
}));

beforeEach(inject(function (_$translate_, _$httpBackend_, _$translateStaticFilesLoader_) {
$httpBackend = _$httpBackend_;
Expand Down
16 changes: 13 additions & 3 deletions test/unit/service/loader-url.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ describe('pascalprecht.translate', function () {

var $translate, $httpBackend, $translateUrlLoader, $translationCache;

beforeEach(module('pascalprecht.translate'));
beforeEach(module('pascalprecht.translate', function ($httpProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
}));

beforeEach(inject(function (_$translate_, _$httpBackend_, _$translateUrlLoader_, _$translationCache_) {
$translate = _$translate_;
Expand Down Expand Up @@ -88,7 +92,10 @@ describe('pascalprecht.translate', function () {
});

describe('$translateProvider#useUrlLoader', function () {
beforeEach(module('pascalprecht.translate', function ($translateProvider) {
beforeEach(module('pascalprecht.translate', function ($httpProvider, $translateProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
$translateProvider.useUrlLoader('foo/bar.json');
}));

Expand All @@ -114,7 +121,10 @@ describe('pascalprecht.translate', function () {
});

describe('$translateProvider#useUrlLoader with custom $http options (method=POST)', function () {
beforeEach(module('pascalprecht.translate', function ($translateProvider) {
beforeEach(module('pascalprecht.translate', function ($httpProvider, $translateProvider) {
if (angular.isDefined($httpProvider.useLegacyPromiseExtensions)) {
$httpProvider.useLegacyPromiseExtensions(false);
}
$translateProvider.useUrlLoader('foo/bar.json', {
$http: {
method: 'POST'
Expand Down

0 comments on commit 233a012

Please sign in to comment.