Updated tests to include validateEntity in mocks

Signed-off-by: Taras <tarasm@gmail.com>
This commit is contained in:
Taras
2022-09-07 18:12:01 -04:00
parent 54f14d5b88
commit 93a1072a0a
14 changed files with 15 additions and 2 deletions
@@ -299,7 +299,7 @@ describe('CatalogClient', () => {
describe('validateEntity', () => {
it('returns valid false when validation fails', async () => {
server.use(
rest.post(`${mockBaseUrl}/validate-entity`, (req, res, ctx) => {
rest.post(`${mockBaseUrl}/validate-entity`, (_req, res, ctx) => {
return res(
ctx.status(400),
ctx.json({
@@ -336,7 +336,7 @@ describe('CatalogClient', () => {
it('returns valid true when validation fails', async () => {
server.use(
rest.post(`${mockBaseUrl}/validate-entity`, (req, res, ctx) => {
rest.post(`${mockBaseUrl}/validate-entity`, (_req, res, ctx) => {
return res(ctx.status(200), ctx.text(''));
}),
);
@@ -35,6 +35,7 @@ describe('CatalogIdentityClient', () => {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
const tokenManager: jest.Mocked<TokenManager> = {
getToken: jest.fn(),
@@ -68,6 +68,7 @@ describe('createRouter', () => {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
config = new ConfigReader({
@@ -59,6 +59,7 @@ describe('<CatalogGraphCard/>', () => {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
apis = TestApiRegistry.from([catalogApiRef, catalog]);
@@ -92,6 +92,7 @@ describe('<CatalogGraphPage/>', () => {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
wrapper = (
@@ -119,6 +119,7 @@ describe('<EntityRelationsGraph/>', () => {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
Wrapper = ({ children }) => (
@@ -38,6 +38,7 @@ describe('useEntityStore', () => {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
useApi.mockReturnValue(catalogApi);
@@ -100,6 +100,7 @@ describe('CatalogImportClient', () => {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
let catalogImportClient: CatalogImportClient;
@@ -46,6 +46,7 @@ describe('<StepPrepareCreatePullRequest />', () => {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
const errorApi: jest.Mocked<typeof errorApiRef.T> = {
@@ -32,6 +32,7 @@ describe('<DefaultExplorePage />', () => {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
const Wrapper = ({ children }: { children?: React.ReactNode }) => (
@@ -33,6 +33,7 @@ describe('<DomainExplorerContent />', () => {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
const Wrapper = ({ children }: { children?: React.ReactNode }) => (
@@ -33,6 +33,7 @@ describe('<GroupsExplorerContent />', () => {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
const Wrapper = ({ children }: { children?: React.ReactNode }) => (
@@ -37,6 +37,7 @@ describe('<FossaPage />', () => {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
const fossaApi: jest.Mocked<FossaApi> = {
getFindingSummary: jest.fn(),
@@ -53,6 +53,7 @@ function mockCatalogClient(entity?: Entity): jest.Mocked<CatalogApi> {
refreshEntity: jest.fn(),
getEntityAncestors: jest.fn(),
getEntityFacets: jest.fn(),
validateEntity: jest.fn(),
};
if (entity) {
mock.getEntityByRef.mockReturnValue(entity);