Skip to content

Commit

Permalink
feat(metadata-taxonomy): Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JChan106 committed Oct 23, 2024
1 parent 0ade2ca commit f9e120e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PaginationQueryInput } from '@box/metadata-editor';
import { metadataTaxonomyFetcher, metadataTaxonomyNodeFetcher } from '../fetchers/metadataTaxonomyFetcher';
import { metadataTaxonomyFetcher, metadataTaxonomyNodeAncestorsFetcher } from '../fetchers/metadataTaxonomyFetcher';
import type API from '../../../api';

describe('metadataTaxonomyFetcher', () => {
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('metadataNodeTaxonomiesFetcher', () => {
apiMock.getMetadataAPI(false).getMetadataTaxonomyLevels.mockResolvedValue(mockTaxonomyLevels);
apiMock.getMetadataAPI(false).getMetadataTaxonomyNode.mockResolvedValue(mockTaxonomyNode);

const result = await metadataTaxonomyNodeFetcher(apiMock, scope, taxonomyKey, nodeID);
const result = await metadataTaxonomyNodeAncestorsFetcher(apiMock, scope, taxonomyKey, nodeID);

const expectedResult = [
{
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('metadataNodeTaxonomiesFetcher', () => {
apiMock.getMetadataAPI(false).getMetadataTaxonomyLevels.mockResolvedValue(mockTaxonomyLevels);
apiMock.getMetadataAPI(false).getMetadataTaxonomyNode.mockResolvedValue(mockTaxonomyNode);

const result = await metadataTaxonomyNodeFetcher(apiMock, scope, taxonomyKey, nodeID);
const result = await metadataTaxonomyNodeAncestorsFetcher(apiMock, scope, taxonomyKey, nodeID);

const expectedResult = [
{
Expand All @@ -189,13 +189,17 @@ describe('metadataNodeTaxonomiesFetcher', () => {
const error = new Error('API Error');
apiMock.getMetadataAPI(false).getMetadataTaxonomyLevels.mockRejectedValue(error);

await expect(metadataTaxonomyNodeFetcher(apiMock, scope, taxonomyKey, nodeID)).rejects.toThrow('API Error');
await expect(metadataTaxonomyNodeAncestorsFetcher(apiMock, scope, taxonomyKey, nodeID)).rejects.toThrow(
'API Error',
);
});

test('should throw an error if getMetadataTaxonomyNode fails', async () => {
const error = new Error('API Error');
apiMock.getMetadataAPI(false).getMetadataTaxonomyNode.mockRejectedValue(error);

await expect(metadataTaxonomyNodeFetcher(apiMock, scope, taxonomyKey, nodeID)).rejects.toThrow('API Error');
await expect(metadataTaxonomyNodeAncestorsFetcher(apiMock, scope, taxonomyKey, nodeID)).rejects.toThrow(
'API Error',
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ export const metadataTaxonomyFetcher = async (
};
};

export const metadataTaxonomyNodeFetcher = async (api: API, scope: string, taxonomyKey: string, nodeID: string) => {
export const metadataTaxonomyNodeAncestorsFetcher = async (
api: API,
scope: string,
taxonomyKey: string,
nodeID: string,
) => {
const [metadataTaxonomyLevels, metadataTaxonomyNode] = await Promise.all([
api.getMetadataAPI(false).getMetadataTaxonomyLevels(scope, taxonomyKey),
api.getMetadataAPI(false).getMetadataTaxonomyNode(scope, taxonomyKey, nodeID, true),
Expand Down

0 comments on commit f9e120e

Please sign in to comment.