Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Oct 26, 2020
1 parent 20203da commit 79d0455
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 100 deletions.
81 changes: 0 additions & 81 deletions x-pack/plugins/case/server/client/__fixtures__/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions x-pack/plugins/case/server/client/cases/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { KibanaRequest } from 'kibana/server';
import { ConnectorTypes } from '../../../common/api';
import { ConnectorTypes, CasePostRequest } from '../../../common/api';

import {
createMockSavedObjectsRepository,
Expand Down Expand Up @@ -37,7 +37,7 @@ describe('create', () => {
type: ConnectorTypes.jira,
fields: { issueType: 'Task', priority: 'High', parent: null },
},
};
} as CasePostRequest;

const savedObjectsClient = createMockSavedObjectsRepository({
caseSavedObject: mockCases,
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/case/server/client/cases/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { KibanaRequest } from 'kibana/server';
import { ConnectorTypes } from '../../../common/api';
import { ConnectorTypes, CasesPatchRequest } from '../../../common/api';
import {
createMockSavedObjectsRepository,
mockCaseNoConnectorId,
Expand Down Expand Up @@ -190,7 +190,7 @@ describe('update', () => {
});

test('it updates the connector correctly', async () => {
const patchCases = {
const patchCases = ({
cases: [
{
id: 'mock-id-3',
Expand All @@ -203,7 +203,7 @@ describe('update', () => {
version: 'WzUsMV0=',
},
],
};
} as unknown) as CasesPatchRequest;

const savedObjectsClient = createMockSavedObjectsRepository({
caseSavedObject: mockCases,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ describe('addComment', () => {
});

expect(res.id).toEqual('mock-id-1');
expect(res.totalComment).toEqual(res.comments.length);
expect(res.comments[res.comments.length - 1]).toEqual({
expect(res.totalComment).toEqual(res.comments!.length);
expect(res.comments![res.comments!.length - 1]).toEqual({
comment: 'Wow, good luck catching that bad meanie!',
created_at: '2020-10-23T21:54:48.952Z',
created_by: {
Expand Down Expand Up @@ -85,7 +85,7 @@ describe('addComment', () => {
});

const caseClient = await createCaseClientWithMockSavedObjectsClient(savedObjectsClient);
const res = await caseClient.client.addComment({
await caseClient.client.addComment({
request,
caseId: 'mock-id-1',
comment: { comment: 'Wow, good luck catching that bad meanie!' },
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('addComment', () => {
});

expect(res.id).toEqual('mock-id-1');
expect(res.comments[res.comments.length - 1]).toEqual({
expect(res.comments![res.comments!.length - 1]).toEqual({
comment: 'Wow, good luck catching that bad meanie!',
created_at: '2020-10-23T21:54:48.952Z',
created_by: {
Expand Down
6 changes: 0 additions & 6 deletions x-pack/plugins/case/server/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,3 @@ export interface CaseClient {
update: (args: CaseClientUpdate) => Promise<CasesResponse>;
addComment: (args: CaseClientAddComment) => Promise<CaseResponse>;
}

export interface CaseClientFactoryArguments {
caseConfigureService: CaseConfigureServiceSetup;
caseService: CaseServiceSetup;
userActionService: CaseUserActionServiceSetup;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { httpServerMock } from 'src/core/server/mocks';

import { ConnectorTypes } from '../../../../common/api';
import { CaseClient } from '../../../client';
import {
createMockSavedObjectsRepository,
createRoute,
createRouteContext,
mockCases,
} from '../__fixtures__';
import { initPatchCasesApi } from './patch_cases';
import { ConnectorTypes } from '../../../../common/api/connectors';
import { CaseClient } from '../../../client';

describe('PATCH cases', () => {
let routeHandler: RequestHandler<any, any, any>;
Expand Down Expand Up @@ -43,7 +43,7 @@ describe('PATCH cases', () => {
description: 'This is a brand new case of a bad meanie defacing data',
id: 'mock-id-1',
external_service: null,
status: 'closed',
status: 'closed' as const,
tags: ['defacement'],
title: 'Super Bad Security Issue',
totalComment: 0,
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('PATCH cases', () => {
);

const caseClient = context.case!.getCaseClient() as jest.Mocked<CaseClient>;
caseClient.update.mockResolvedValueOnce(patchResult);
caseClient.update.mockResolvedValueOnce([patchResult]);
const response = await routeHandler(context, request, kibanaResponseFactory);

expect(caseClient.update).toHaveBeenCalledTimes(1);
Expand Down

0 comments on commit 79d0455

Please sign in to comment.