-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hub-common): introduces a getFamilyTypes function that returns t…
…he types associated with a prov affects: @esri/hub-common
- Loading branch information
1 parent
0dfdbe8
commit 02d7cc7
Showing
4 changed files
with
164 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
import { getCollection } from "../src/collections"; | ||
import { getCollection, getCollectionTypes } from "../src/collections"; | ||
|
||
describe("getCollection", () => { | ||
it("can abort", () => { | ||
expect(getCollection()).toBe(undefined); | ||
}); | ||
describe("collections", () => { | ||
describe("getCollections", () => { | ||
it("can abort", () => { | ||
expect(getCollection()).toBe(undefined); | ||
}); | ||
|
||
it("can retrieve a single category", () => { | ||
expect(getCollection("Feature Layer")).toBe("dataset"); | ||
}); | ||
|
||
it("can retrieve a single category", () => { | ||
expect(getCollection("Feature Layer")).toBe("dataset"); | ||
it("can retrieve a single category (from cache)", () => { | ||
expect(getCollection("Feature Layer")).toBe("dataset"); | ||
}); | ||
}); | ||
|
||
it("can retrieve a single category (from cache)", () => { | ||
expect(getCollection("Feature Layer")).toBe("dataset"); | ||
describe("getTypesFromCollection", () => { | ||
it("can abort", () => { | ||
expect(getCollectionTypes()).toBe(undefined); | ||
}); | ||
|
||
it("can retrieve types from a collection", () => { | ||
expect(getCollectionTypes("feedback")).toEqual([ | ||
"Form", | ||
"Quick Capture Project", | ||
]); | ||
}); | ||
|
||
it("returns undefined with unknown collection", () => { | ||
expect(getCollectionTypes("dummy")).toBe(undefined); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { getFamilyTypes } from "../../src"; | ||
|
||
describe("getFamily", () => { | ||
describe("getFamilyTypes", () => { | ||
it("can get 'content' types", () => { | ||
const types = getFamilyTypes("content"); | ||
expect(Array.isArray(types)).toBeTruthy(); | ||
expect(types.length > 0).toBeTruthy(); | ||
expect(types.includes("CAD Drawing")).toBeTruthy(); | ||
expect(types.includes("Feature Collection Template")).toBeTruthy(); | ||
expect(types.includes("Report Template")).toBeTruthy(); | ||
}); | ||
|
||
it("can get 'template' types", () => { | ||
const types = getFamilyTypes("template"); | ||
expect(Array.isArray(types)).toBeTruthy(); | ||
expect(types.length).toBe(1); | ||
expect(types.includes("Solution")).toBeTruthy(); | ||
}); | ||
|
||
it("can get 'dataset' types", () => { | ||
const types = getFamilyTypes("dataset"); | ||
expect(Array.isArray(types)).toBeTruthy(); | ||
expect(types.length > 0).toBeTruthy(); | ||
expect(types.includes("Image Service")).toBeTruthy(); | ||
expect(types.includes("Feature Collection Template")).toBeFalsy(); | ||
expect(types.includes("Feature Service")).toBeFalsy(); | ||
expect(types.includes("Raster Layer")).toBeFalsy(); | ||
expect(types.includes("Microsoft Excel")).toBeFalsy(); | ||
}); | ||
|
||
it("can get 'map' types", () => { | ||
const types = getFamilyTypes("map"); | ||
expect(Array.isArray(types)).toBeTruthy(); | ||
expect(types.length > 0).toBeTruthy(); | ||
expect(types.includes("Image Service")).toBeFalsy(); | ||
expect(types.includes("Feature Service")).toBeTruthy(); | ||
expect(types.includes("Raster Layer")).toBeTruthy(); | ||
}); | ||
|
||
it("can get 'document' types", () => { | ||
const types = getFamilyTypes("document"); | ||
expect(Array.isArray(types)).toBeTruthy(); | ||
expect(types.length > 0).toBeTruthy(); | ||
expect(types.includes("CAD Drawing")).toBeFalsy(); | ||
expect(types.includes("Report Template")).toBeFalsy(); | ||
expect(types.includes("Microsoft Excel")).toBeTruthy(); | ||
}); | ||
|
||
it("can get 'project' types", () => { | ||
const types = getFamilyTypes("project"); | ||
expect(Array.isArray(types)).toBeTruthy(); | ||
expect(types.length).toBe(1); | ||
expect(types.includes("Hub Project")).toBeTruthy(); | ||
}); | ||
|
||
it("can get types any other valid family", () => { | ||
const types = getFamilyTypes("site"); | ||
expect(Array.isArray(types)).toBeTruthy(); | ||
expect(types.length > 0).toBeTruthy(); | ||
}); | ||
|
||
it("can returns undefined for an invalid family", () => { | ||
const types = getFamilyTypes("dummy" as any); | ||
expect(types).toBeUndefined(); | ||
}); | ||
}); | ||
}); |