From 49f090235c87a6784b2f3ee0021357273f60a404 Mon Sep 17 00:00:00 2001 From: Mike Tschudi Date: Wed, 12 Sep 2018 15:22:18 -0700 Subject: [PATCH] Reworked function args for https://github.com/Esri/arcgis-rest-js/pull/317#discussion_r216850450 --- .../src/update.ts | 9 +++++---- .../test/update.test.ts | 18 +++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/arcgis-rest-feature-service-admin/src/update.ts b/packages/arcgis-rest-feature-service-admin/src/update.ts index afa1399bd0..ad72c46e57 100644 --- a/packages/arcgis-rest-feature-service-admin/src/update.ts +++ b/packages/arcgis-rest-feature-service-admin/src/update.ts @@ -51,7 +51,8 @@ export interface IAddToServiceDefinitionFailureResult { * * @param url - URL of feature service * @param requestOptions - Options for the request - * @returns A Promise that resolves with service details once the service has been created + * @returns A Promise that resolves with service layer and/or table details once the definition + * has been updated */ export function addToServiceDefinition( url: string, @@ -75,14 +76,14 @@ export function addToServiceDefinition( requestOptions.params.addToDefinition.tables = requestOptions.tables; } - return new Promise(resolve => { + return new Promise((resolve, reject) => { request(adminUrl, requestOptions).then( response => { resolve(response); }, response => { - // We're not interested in the full ArcGISRequestError response, nor having an exception thrown - resolve(response.response); + // We're not interested in the full ArcGISRequestError response + reject(response.response); } ); }); diff --git a/packages/arcgis-rest-feature-service-admin/test/update.test.ts b/packages/arcgis-rest-feature-service-admin/test/update.test.ts index 5c0fe20b2b..c1b78ce7d6 100644 --- a/packages/arcgis-rest-feature-service-admin/test/update.test.ts +++ b/packages/arcgis-rest-feature-service-admin/test/update.test.ts @@ -243,6 +243,9 @@ describe("add to feature service", () => { } ) .then( + e => { + fail(e); // call is supposed to fail + }, response => { // Check service call expect(fetchMock.called()).toEqual(true); @@ -267,9 +270,6 @@ describe("add to feature service", () => { expect(response).toEqual(AddToFeatureServiceFailResponse); done(); - }, - e => { - fail(e); // call is supposed to succeed } ) .catch(e => { @@ -288,6 +288,9 @@ describe("add to feature service", () => { } ) .then( + e => { + fail(e); // call is supposed to fail + }, response => { // Check service call expect(fetchMock.called()).toEqual(true); @@ -312,9 +315,6 @@ describe("add to feature service", () => { expect(response).toEqual(AddToFeatureServiceFailResponse); done(); - }, - e => { - fail(e); // call is supposed to succeed } ) .catch(e => { @@ -334,6 +334,9 @@ describe("add to feature service", () => { } ) .then( + e => { + fail(e); // call is supposed to fail + }, response => { // Check service call expect(fetchMock.called()).toEqual(true); @@ -361,9 +364,6 @@ describe("add to feature service", () => { expect(response).toEqual(AddToFeatureServiceFailResponse); done(); - }, - e => { - fail(e); // call is supposed to succeed } ) .catch(e => {