mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
angular: fixed some tests and removed some which are no longer relevant due to the removal of the success and error methods from IHttpPromise
This commit is contained in:
parent
a766c1df30
commit
e338791f88
@ -143,7 +143,7 @@ class UrlLocatorTestService implements IUrlLocatorTestService {
|
||||
private $state: ng.ui.IStateService
|
||||
) {
|
||||
$rootScope.$on("$locationChangeSuccess", (event: ng.IAngularEvent) => this.onLocationChangeSuccess(event));
|
||||
$rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) =>
|
||||
$rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) =>
|
||||
this.onStateNotFound(event, unfoundState, fromState, fromParams));
|
||||
}
|
||||
|
||||
@ -157,8 +157,8 @@ class UrlLocatorTestService implements IUrlLocatorTestService {
|
||||
|
||||
// Note that we do not concern ourselves with what to do if this request fails,
|
||||
// because if it fails, the web page will be redirected away to the login screen.
|
||||
this.$http({ url: "/api/me", method: "GET" }).success((user: any) => {
|
||||
this.currentUser = user;
|
||||
this.$http({ url: "/api/me", method: "GET" }).then((response: ng.IHttpPromiseCallbackArg<any>) => {
|
||||
this.currentUser = response.data;
|
||||
|
||||
// sync the ui-state with the location in the browser, which effectively
|
||||
// restarts the state change that was stopped previously
|
||||
@ -166,14 +166,14 @@ class UrlLocatorTestService implements IUrlLocatorTestService {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private onStateNotFound(event: ng.IAngularEvent,
|
||||
unfoundState: ng.ui.IUnfoundState,
|
||||
fromState: ng.ui.IState,
|
||||
fromParams: {}) {
|
||||
var unfoundTo: string = unfoundState.to;
|
||||
var unfoundToParams: {} = unfoundState.toParams;
|
||||
var unfoundOptions: ng.ui.IStateOptions = unfoundState.options
|
||||
var unfoundOptions: ng.ui.IStateOptions = unfoundState.options
|
||||
}
|
||||
|
||||
private stateServiceTest() {
|
||||
|
||||
@ -108,11 +108,6 @@ namespace HttpAndRegularPromiseTests {
|
||||
}
|
||||
|
||||
function someController($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) {
|
||||
$http.get<ExpectedResponse>('http://somewhere/some/resource')
|
||||
.success((data: ExpectedResponse) => {
|
||||
$scope.person = data;
|
||||
});
|
||||
|
||||
$http.get<ExpectedResponse>('http://somewhere/some/resource')
|
||||
.then((response: ng.IHttpPromiseCallbackArg<ExpectedResponse>) => {
|
||||
// typing lost, so something like
|
||||
@ -156,21 +151,6 @@ namespace HttpAndRegularPromiseTests {
|
||||
$scope.nothing = 'really nothing';
|
||||
});
|
||||
}
|
||||
|
||||
// Test that we can pass around a type-checked success/error Promise Callback
|
||||
function anotherController($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) {
|
||||
function buildFooData(): ng.IRequestShortcutConfig {
|
||||
return {};
|
||||
}
|
||||
|
||||
function doFoo(callback: ng.IHttpPromiseCallback<ExpectedResponse>) {
|
||||
$http
|
||||
.get<ExpectedResponse>('/foo', buildFooData())
|
||||
.success(callback);
|
||||
};
|
||||
|
||||
doFoo((data: any) => console.log(data));
|
||||
};
|
||||
}
|
||||
|
||||
// Test for AngularJS Syntax
|
||||
@ -441,10 +421,10 @@ httpFoo.then((x) => {
|
||||
x.toFixed();
|
||||
});
|
||||
|
||||
httpFoo.success((data, status, headers, config) => {
|
||||
const h = headers('test');
|
||||
httpFoo.then((response: ng.IHttpPromiseCallbackArg<any>) => {
|
||||
const h = response.headers('test');
|
||||
h.charAt(0);
|
||||
const hs = headers();
|
||||
const hs = response.headers();
|
||||
hs['content-type'].charAt(1);
|
||||
});
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ class UploadController {
|
||||
ngfValidateForce: true
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
onFileSelect(files: Array<File>) {
|
||||
|
||||
this.Upload
|
||||
@ -44,11 +44,11 @@ class UploadController {
|
||||
}).progress((evt: angular.angularFileUpload.IFileProgressEvent) => {
|
||||
let percent = parseInt((100.0 * evt.loaded / evt.total).toString(), 10);
|
||||
console.log("upload progress: " + percent + "% for " + evt.config.data.media[0]);
|
||||
}).error((data: any, status: number, response: any, headers: any) => {
|
||||
console.error(data, status, response, headers);
|
||||
}).success((data: any, status: number, headers: any, config: angular.angularFileUpload.IFileUploadConfigFile) => {
|
||||
}).catch((response: ng.IHttpPromiseCallbackArg<any>) => {
|
||||
console.error(response.data, response.status, response.statusText, response.headers);
|
||||
}).then((response: ng.IHttpPromiseCallbackArg<any>) => {
|
||||
// file is uploaded successfully
|
||||
console.log("Success!", data, status, headers, config);
|
||||
console.log("Success!", response.data, response.status, response.headers, response.config);
|
||||
});
|
||||
|
||||
this.Upload
|
||||
@ -72,16 +72,16 @@ class UploadController {
|
||||
this.Upload.isResizeSupported();
|
||||
this.Upload.isResumeSupported();
|
||||
this.Upload.isUploadInProgress();
|
||||
|
||||
|
||||
let json = this.Upload.json({ test: true }),
|
||||
jsonBlob = this.Upload.jsonBlob({ test: true }),
|
||||
fileWithNewName = this.Upload.rename(files[0], "newName.jpg");
|
||||
|
||||
this.Upload
|
||||
.resize(files[0], {
|
||||
.resize(files[0], {
|
||||
height: 1024,
|
||||
width: 1024,
|
||||
quality: 0.7,
|
||||
quality: 0.7,
|
||||
ratio: 0.9,
|
||||
centerCrop: true,
|
||||
restoreExif: true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user