Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Constance <[email protected]>
  • Loading branch information
JasonStoltz and Constance authored Nov 16, 2020
1 parent c371287 commit f492e2e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const DELETE_SUCCESS = i18n.translate(
export const DocumentDetailLogic = kea<DocumentDetailLogicType>({
path: ['enterprise_search', 'app_search', 'document_detail_logic'],
actions: () => ({
setFields: (fields: FieldDetails[]) => ({ fields }),
getDocumentDetails: (documentId: string) => ({ documentId }),
deleteDocument: (documentId: string) => ({ documentId }),
setFields: (fields) => ({ fields }),
getDocumentDetails: (documentId) => ({ documentId }),
deleteDocument: (documentId) => ({ documentId }),
}),
reducers: () => ({
dataLoading: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('DocumentsLogic', () => {

it('handles errors', async () => {
mount();
const promise = Promise.reject('An error occured');
const promise = Promise.reject('An error occurred');
http.get.mockReturnValue(promise);

try {
Expand All @@ -98,23 +98,23 @@ describe('DocumentsLogic', () => {
} catch {
// Do nothing
}
expect(flashAPIErrors).toHaveBeenCalledWith('An error occured');
expect(flashAPIErrors).toHaveBeenCalledWith('An error occurred');
});
});

describe('deleteDocument', () => {
let originalWindowConfirm: any;
let confirmSpy: any;
let promise: Promise<any>;

beforeEach(() => {
originalWindowConfirm = window.confirm;
window.confirm = () => true;
confirmSpy = jest.spyOn(window, 'confirm');
confirmSpy.mockImplementation(jest.fn(() => true));
promise = Promise.resolve({});
http.delete.mockReturnValue(promise);
});

afterEach(() => {
window.confirm = originalWindowConfirm;
confirmSpy.mockRestore())
});

it('will call an API endpoint and show a success message', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export interface DocumentsLogicActions {
openDocumentCreation(): void;
}

type DocumnetsLogicType = MakeLogicType<DocumentsLogicValues, DocumentsLogicActions>;
type DocumentsLogicType = MakeLogicType<DocumentsLogicValues, DocumentsLogicActions>;

export const DocumentsLogic = kea<DocumnetsLogicType>({
export const DocumentsLogic = kea<DocumentsLogicType>({
path: ['enterprise_search', 'app_search', 'documents_logic'],
actions: () => ({
openDocumentCreation: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('document routes', () => {
mockRouter = new MockRouter({
method: 'get',
path: '/api/app_search/engines/{engineName}/documents/{documentId}',
payload: 'query',
});

registerDocumentRoutes({
Expand All @@ -43,7 +42,6 @@ describe('document routes', () => {
mockRouter = new MockRouter({
method: 'delete',
path: '/api/app_search/engines/{engineName}/documents/{documentId}',
payload: 'query',
});

registerDocumentRoutes({
Expand Down

0 comments on commit f492e2e

Please sign in to comment.