From 9575641f2a8342cf0d0e96fc44f30334c8439f88 Mon Sep 17 00:00:00 2001 From: Mike Tschudi Date: Mon, 14 Feb 2022 11:52:46 -0800 Subject: [PATCH] Fix deprecations --- jasmine.json | 3 +- packages/common/test/restHelpers.test.ts | 49 ++++++++-- packages/common/test/workforceHelpers.test.ts | 18 +++- .../deployer/test/deploySolutionItems.test.ts | 45 ++++++++- packages/deployer/test/deployer.test.ts | 22 +++-- .../feature-layer/test/feature-layer.test.ts | 40 ++++++-- packages/simple-types/test/oic.test.ts | 39 ++++---- .../test/webmappingapplication.test.ts | 11 ++- packages/simple-types/test/workforce.test.ts | 97 +++++++++++-------- .../velocity/test/velocity-processor.test.ts | 25 +++-- 10 files changed, 252 insertions(+), 97 deletions(-) diff --git a/jasmine.json b/jasmine.json index 9a0a4fbd8..cd6d1f04e 100644 --- a/jasmine.json +++ b/jasmine.json @@ -3,5 +3,6 @@ "spec_files": ["*/test/**/*.test.ts"], "helpers": ["../support/test-helpers.js"], "stopSpecOnExpectationFailure": false, - "random": false + "random": true, + "verboseDeprecations": true } diff --git a/packages/common/test/restHelpers.test.ts b/packages/common/test/restHelpers.test.ts index 644f5948e..4c5c9b7e6 100644 --- a/packages/common/test/restHelpers.test.ts +++ b/packages/common/test/restHelpers.test.ts @@ -1955,9 +1955,14 @@ describe("Module `restHelpers`: common REST utility functions shared across pack restHelpers .convertExtent(extent, serviceSR, geometryServiceUrl, MOCK_USER_SESSION) - .then(_extent => { - done.fail(); - }, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); it("can handle unmatched wkid and failure on findTransformations", done => { @@ -1976,9 +1981,14 @@ describe("Module `restHelpers`: common REST utility functions shared across pack restHelpers .convertExtent(extent, serviceSR, geometryServiceUrl, MOCK_USER_SESSION) - .then(_extent => { - done.fail(); - }, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); }); @@ -2142,7 +2152,14 @@ describe("Module `restHelpers`: common REST utility functions shared across pack geometryServiceUrl, MOCK_USER_SESSION ) - .then(done.fail, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); }); @@ -3595,7 +3612,14 @@ describe("Module `restHelpers`: common REST utility functions shared across pack restHelpers .updateGroup(grp, MOCK_USER_SESSION) - .then(() => done.fail, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); }); @@ -4731,7 +4755,14 @@ describe("Module `restHelpers`: common REST utility functions shared across pack ); restHelpers ._getCreateServiceOptions(itemTemplate, userSession, templateDictionary) - .then(done.fail, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); }); diff --git a/packages/common/test/workforceHelpers.test.ts b/packages/common/test/workforceHelpers.test.ts index bc931ed53..40857afd6 100644 --- a/packages/common/test/workforceHelpers.test.ts +++ b/packages/common/test/workforceHelpers.test.ts @@ -44,7 +44,14 @@ describe("Module `workforceHelpers`: manages the creation and deployment of work it("will handle no edits", done => { workforceHelpers ._applyEdits("http://url", [], MOCK_USER_SESSION) - .then(done, done.fail); + .then( + () => { + done(); + }, + () => { + done.fail(); + } + ); }); }); describe("_extractDependencies", () => { @@ -361,7 +368,14 @@ describe("Module `workforceHelpers`: manages the creation and deployment of work workforceHelpers .getWorkforceServiceInfo(props, url, MOCK_USER_SESSION) - .then(() => done.fail, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); it("can handle _getAssignmentIntegrationInfos failure", done => { diff --git a/packages/deployer/test/deploySolutionItems.test.ts b/packages/deployer/test/deploySolutionItems.test.ts index b03e448d8..c4d719d27 100644 --- a/packages/deployer/test/deploySolutionItems.test.ts +++ b/packages/deployer/test/deploySolutionItems.test.ts @@ -780,7 +780,14 @@ describe("Module `deploySolutionItems`", () => { progressCallback: utils.SOLUTION_PROGRESS_CALLBACK } ) - .then(() => done.fail(), done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); it("can handle error on find items by tag", done => { @@ -857,7 +864,14 @@ describe("Module `deploySolutionItems`", () => { progressCallback: utils.SOLUTION_PROGRESS_CALLBACK } ) - .then(() => done.fail(), done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); it("handles failure to delete all items when unwinding after failure to deploy", done => { @@ -1152,7 +1166,14 @@ describe("Module `deploySolutionItems`", () => { progressCallback: utils.SOLUTION_PROGRESS_CALLBACK } ) - .then(() => done.fail(), done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); it("handle failure to use existing items", done => { @@ -1231,7 +1252,14 @@ describe("Module `deploySolutionItems`", () => { progressCallback: utils.SOLUTION_PROGRESS_CALLBACK } ) - .then(() => done.fail(), done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); }); @@ -2616,7 +2644,14 @@ describe("Module `deploySolutionItems`", () => { it("will handle no custom item id requests", done => { deploySolution ._setTypekeywordForExisting([], {}, MOCK_USER_SESSION) - .then(done); + .then( + () => { + done(); + }, + () => { + done.fail(); + } + ); }); }); }); diff --git a/packages/deployer/test/deployer.test.ts b/packages/deployer/test/deployer.test.ts index bc37c5c97..42e9d7814 100644 --- a/packages/deployer/test/deployer.test.ts +++ b/packages/deployer/test/deployer.test.ts @@ -704,9 +704,14 @@ describe("Module `deployer`", () => { }; deployer .deploySolution(itemInfo.item.id, MOCK_USER_SESSION, options) - .then(done, e => { - done.fail(e); - }); + .then( + () => { + done(); + }, + e => { + done.fail(e); + } + ); }, e => { done.fail(e); @@ -1028,9 +1033,14 @@ describe("Module `deployer`", () => { deployer .deploySolution(itemInfoCard.id, MOCK_USER_SESSION, options) - .then(() => { - done.fail(); - }, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); it("can handle error on createItemWithData", done => { diff --git a/packages/feature-layer/test/feature-layer.test.ts b/packages/feature-layer/test/feature-layer.test.ts index b64cf810a..a7e15cf6c 100644 --- a/packages/feature-layer/test/feature-layer.test.ts +++ b/packages/feature-layer/test/feature-layer.test.ts @@ -337,9 +337,14 @@ describe("Module `feature-layer`: manages the creation and deployment of feature MOCK_USER_SESSION, templateDictionary ) - .then(r => { - done.fail(); - }, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); it("should handle error on getItemData", done => { @@ -384,7 +389,14 @@ describe("Module `feature-layer`: manages the creation and deployment of feature MOCK_USER_SESSION, templateDictionary ) - .then(done, done.fail); + .then( + () => { + done(); + }, + e => { + done.fail(e); + } + ); }); it("should handle error on getServiceLayersAndTables", done => { @@ -426,9 +438,14 @@ describe("Module `feature-layer`: manages the creation and deployment of feature MOCK_USER_SESSION, templateDictionary ) - .then(r => { - done.fail(); - }, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); }); @@ -2749,7 +2766,14 @@ describe("Module `feature-layer`: manages the creation and deployment of feature featureLayer .postProcess("", "", [], template, [], {}, MOCK_USER_SESSION) - .then(done, done.fail); + .then( + () => { + done(); + }, + e => { + done.fail(e); + } + ); }); }); }); diff --git a/packages/simple-types/test/oic.test.ts b/packages/simple-types/test/oic.test.ts index 6b3b4cb5a..350a3e12d 100644 --- a/packages/simple-types/test/oic.test.ts +++ b/packages/simple-types/test/oic.test.ts @@ -92,33 +92,36 @@ describe("Module `webmap`: manages the creation and deployment of OIC (Oriented }); describe("_extractDependencies", () => { - it("handles missing data or properties", done => { + it("handles missing data or properties", () => { const expectedDependencies = { dependencies: [] as string[], urlHash: {} as any }; + let itemTemplate: common.IItemTemplate; - oic - ._extractDependencies(templates.getItemTemplateSkeleton(), null) - .then(actual => { - expect(actual).toEqual(expectedDependencies); - done(); - }, done.fail); + return oic._extractDependencies(templates.getItemTemplateSkeleton(), null) + .then(actual => { + expect(actual).toEqual(expectedDependencies); - const itemTemplate = templates.getItemTemplate( - "Oriented Imagery Catalog" - ); - itemTemplate.data.properties = null; - oic._extractDependencies(itemTemplate, null).then(actual => { + itemTemplate = templates.getItemTemplate( + "Oriented Imagery Catalog" + ); + itemTemplate.data.properties = null; + return oic._extractDependencies(itemTemplate, null); + }) + .then(actual => { expect(actual).toEqual(expectedDependencies); - done(); - }, done.fail); - itemTemplate.data = null; - oic._extractDependencies(itemTemplate, null).then(actual => { + itemTemplate.data = null; + return oic._extractDependencies(itemTemplate, null); + }) + .then(actual => { expect(actual).toEqual(expectedDependencies); - done(); - }, done.fail); + return Promise.resolve(); + }) + .catch(error => { + return Promise.reject(error); + }); }); it("handles both of the URL properties", done => { diff --git a/packages/simple-types/test/webmappingapplication.test.ts b/packages/simple-types/test/webmappingapplication.test.ts index 66ff7cc6c..49fff229a 100644 --- a/packages/simple-types/test/webmappingapplication.test.ts +++ b/packages/simple-types/test/webmappingapplication.test.ts @@ -1143,9 +1143,14 @@ describe("Module `webmappingapplication`: manages the creation and deployment of webmappingapplication .convertItemToTemplate(infoLookupTemplate, MOCK_USER_SESSION, MOCK_USER_SESSION) - .then(template => { - done.fail(); - }, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); }); diff --git a/packages/simple-types/test/workforce.test.ts b/packages/simple-types/test/workforce.test.ts index 0eecd0e53..2c623f846 100644 --- a/packages/simple-types/test/workforce.test.ts +++ b/packages/simple-types/test/workforce.test.ts @@ -40,7 +40,7 @@ afterEach(() => { describe("Module `workforce`: manages the creation and deployment of workforce project item types", () => { describe("convertItemToTemplate", () => { - it("should extract dependencies", done => { + it("should extract dependencies 1", done => { const itemTemplate: common.IItemTemplate = mockItems.getAGOLItem( "Workforce Project", null @@ -67,8 +67,40 @@ describe("Module `workforce`: manages the creation and deployment of workforce p expectedDependencies.forEach(d => { expect(newDependencies.indexOf(d)).toBeGreaterThan(-1); - done(); }); + done(); + }, done.fail); + }); + + it("should extract dependencies 2", done => { + const itemTemplate: common.IItemTemplate = mockItems.getAGOLItem( + "Workforce Project", + null + ); + itemTemplate.data = mockItems.getAGOLItemData("Workforce Project"); + + const expectedDependencies: string[] = [ + "abc116555b16437f8435e079033128d0", + "abc26a244163430590151395821fb845", + "abc302ec12b74d2f9f2b3cc549420086", + "abc4494043c3459faabcfd0e1ab557fc", + "abc5dd4bdd18437f8d5ff1aa2d25fd7c", + "abc64329e69144c59f69f3f3e0d45269", + "abc715c2df2b466da05577776e82d044", + "cad3483e025c47338d43df308c117308", + "bad3483e025c47338d43df308c117308" + ]; + + workforce + .convertItemToTemplate(itemTemplate, MOCK_USER_SESSION, MOCK_USER_SESSION) + .then(newItemTemplate => { + const newDependencies: string[] = newItemTemplate.dependencies; + expect(newDependencies.length).toEqual(expectedDependencies.length); + + expectedDependencies.forEach(d => { + expect(newDependencies.indexOf(d)).toBeGreaterThan(-1); + }); + done(); }, done.fail); }); @@ -169,38 +201,6 @@ describe("Module `workforce`: manages the creation and deployment of workforce p }, done.fail); }); - it("should extract dependencies", done => { - const itemTemplate: common.IItemTemplate = mockItems.getAGOLItem( - "Workforce Project", - null - ); - itemTemplate.data = mockItems.getAGOLItemData("Workforce Project"); - - const expectedDependencies: string[] = [ - "abc116555b16437f8435e079033128d0", - "abc26a244163430590151395821fb845", - "abc302ec12b74d2f9f2b3cc549420086", - "abc4494043c3459faabcfd0e1ab557fc", - "abc5dd4bdd18437f8d5ff1aa2d25fd7c", - "abc64329e69144c59f69f3f3e0d45269", - "abc715c2df2b466da05577776e82d044", - "cad3483e025c47338d43df308c117308", - "bad3483e025c47338d43df308c117308" - ]; - - workforce - .convertItemToTemplate(itemTemplate, MOCK_USER_SESSION, MOCK_USER_SESSION) - .then(newItemTemplate => { - const newDependencies: string[] = newItemTemplate.dependencies; - expect(newDependencies.length).toEqual(expectedDependencies.length); - - expectedDependencies.forEach(d => { - expect(newDependencies.indexOf(d)).toBeGreaterThan(-1); - done(); - }); - }, done.fail); - }); - it("should handle workforce projects without data", done => { const itemTemplate: common.IItemTemplate = mockItems.getAGOLItem( "Workforce Project" @@ -245,9 +245,14 @@ describe("Module `workforce`: manages the creation and deployment of workforce p workforce .convertItemToTemplate(itemTemplate, MOCK_USER_SESSION, MOCK_USER_SESSION) - .then(() => { - done.fail(); - }, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); it("should handle url without layer id", done => { @@ -426,7 +431,14 @@ describe("Module `workforce`: manages the creation and deployment of workforce p workforce .fineTuneCreatedItem(itemTemplate, MOCK_USER_SESSION, {}) - .then(done.fail, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); it("should handle error on getUser", done => { @@ -447,7 +459,14 @@ describe("Module `workforce`: manages the creation and deployment of workforce p workforce .fineTuneCreatedItem(itemTemplate, MOCK_USER_SESSION, {}) - .then(done.fail, done); + .then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); it("should not update dispatchers service if it contains records", done => { diff --git a/packages/velocity/test/velocity-processor.test.ts b/packages/velocity/test/velocity-processor.test.ts index 48c8f332b..ce36ca04f 100644 --- a/packages/velocity/test/velocity-processor.test.ts +++ b/packages/velocity/test/velocity-processor.test.ts @@ -276,11 +276,14 @@ describe("convertItemToTemplate", () => { agolItems.get500Failure() ); - convertItemToTemplate(solutionItemId, itemInfo, MOCK_USER_SESSION, MOCK_USER_SESSION, {}).then( + convertItemToTemplate(solutionItemId, itemInfo, MOCK_USER_SESSION, MOCK_USER_SESSION, {}) + .then( () => { done.fail(); }, - done + () => { + done(); + } ); }); @@ -298,11 +301,14 @@ describe("convertItemToTemplate", () => { } ); - convertItemToTemplate(solutionItemId, itemInfo, MOCK_USER_SESSION, MOCK_USER_SESSION, {}).then( + convertItemToTemplate(solutionItemId, itemInfo, MOCK_USER_SESSION, MOCK_USER_SESSION, {}) + .then( () => { done.fail(); }, - done + () => { + done(); + } ); }); }); @@ -550,7 +556,14 @@ describe("createItemFromTemplate", () => { templateDictionary, destinationAuthentication, utils.ITEM_PROGRESS_CALLBACK - ).then(() => done.fail, done); + ).then( + () => { + done.fail(); + }, + () => { + done(); + } + ); }); }); @@ -580,7 +593,7 @@ describe("postProcess", () => { const url: string = "https://myorg.maps.arcgis.com/sharing/rest/content/users/casey/items/thisismyitemid/" fetchMock.post( - `${url}move`, + `${url}move`, {success: true} ) .post(