-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce89008
commit 19fa274
Showing
4 changed files
with
84 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import API from '../../APICore.js'; | ||
import Resource from '../Resource.js'; | ||
|
||
export type ObjectType = { | ||
objectType: string; | ||
}; | ||
|
||
export default class CatalogContent extends Resource { | ||
static baseUrl = `/rest/organizations/${API.orgPlaceholder}/catalogcontent/source`; | ||
|
||
getObjectTypes(sourceId: string) { | ||
return this.api.get(`${CatalogContent.baseUrl}/${sourceId}/objecttypes`); | ||
} | ||
|
||
getMetadataValues(sourceId: string, objectType: ObjectType) { | ||
return this.api.get(this.buildPath(`${CatalogContent.baseUrl}/${sourceId}/metadatavalues`, objectType)); | ||
} | ||
|
||
getMetadata(sourceId: string, objectType: ObjectType) { | ||
return this.api.get(this.buildPath(`${CatalogContent.baseUrl}/${sourceId}/metadata`, objectType)); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import API from '../../../APICore.js'; | ||
import CatalogContent, {ObjectType} from '../CatalogContent.js'; | ||
import queryString from '#query-string'; | ||
|
||
jest.mock('../../../APICore.js'); | ||
|
||
const APIMock: jest.Mock<API> = API as any; | ||
|
||
describe('CatalogContent', () => { | ||
let metadata: CatalogContent; | ||
const api = new APIMock() as jest.Mocked<API>; | ||
const serverlessApi = new APIMock() as jest.Mocked<API>; | ||
|
||
const baseUrl = `/rest/organizations/${API.orgPlaceholder}/catalogcontent/source`; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
metadata = new CatalogContent(api, serverlessApi); | ||
}); | ||
|
||
describe('getObjectTypes', () => { | ||
it('should make a GET call to the specific CatalogContent url', () => { | ||
const sourceId = 'McDonald'; | ||
|
||
metadata.getObjectTypes(sourceId); | ||
expect(api.get).toHaveBeenCalledTimes(1); | ||
expect(api.get).toHaveBeenCalledWith(`${baseUrl}/${sourceId}/objecttypes`); | ||
}); | ||
}); | ||
|
||
describe('getMetadataValues', () => { | ||
it('should make a GET call to the specific CatalogContent url', () => { | ||
const defaultOptions: queryString.StringifyOptions = {skipEmptyString: true, skipNull: true, sort: false}; | ||
const sourceId = 'McDonald'; | ||
const objectType: ObjectType = {objectType: 'Provigo'}; | ||
|
||
metadata.getMetadataValues(sourceId, objectType); | ||
expect(api.get).toHaveBeenCalledTimes(1); | ||
expect(api.get).toHaveBeenCalledWith( | ||
`${baseUrl}/${sourceId}/metadatavalues?${queryString.stringify(objectType, {...defaultOptions})}`, | ||
); | ||
}); | ||
}); | ||
|
||
describe('getMetadata', () => { | ||
it('should make a GET call to the specific CatalogContent url', () => { | ||
const defaultOptions: queryString.StringifyOptions = {skipEmptyString: true, skipNull: true, sort: false}; | ||
const sourceId = 'KFC'; | ||
const objectType: ObjectType = {objectType: 'Provigo'}; | ||
|
||
metadata.getMetadata(sourceId, objectType); | ||
expect(api.get).toHaveBeenCalledTimes(1); | ||
expect(api.get).toHaveBeenCalledWith( | ||
`${baseUrl}/${sourceId}/metadata?${queryString.stringify(objectType, {...defaultOptions})}`, | ||
); | ||
}); | ||
}); | ||
}); |
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