Skip to content

Commit

Permalink
Fix type errors
Browse files Browse the repository at this point in the history
* Continue to export decoded types without a qualifier
* pull types used by hooks from their new location
* Fix errors with usage of act()
  • Loading branch information
rylnd committed Jun 25, 2020
1 parent 0f223aa commit e7f5b86
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export const deleteListSchema = t.exact(
})
);

export type DeleteListSchemaDecoded = t.TypeOf<typeof deleteListSchema>;
export type DeleteListSchema = t.TypeOf<typeof deleteListSchema>;
export type DeleteListSchemaEncoded = t.OutputOf<typeof deleteListSchema>;
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ export const exportListItemQuerySchema = t.exact(
})
);

export type ExportListItemQuerySchemaDecoded = t.TypeOf<typeof exportListItemQuerySchema>;
export type ExportListItemQuerySchema = t.TypeOf<typeof exportListItemQuerySchema>;
export type ExportListItemQuerySchemaEncoded = t.OutputOf<typeof exportListItemQuerySchema>;
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@ export const findListSchema = t.exact(
})
);

type FindListSchema = typeof findListSchema;

export type FindListSchemaDecoded = t.TypeOf<FindListSchema>;
export type FindListSchemaEncoded = t.OutputOf<FindListSchema>;
export type FindListSchema = t.TypeOf<typeof findListSchema>;
export type FindListSchemaEncoded = t.OutputOf<typeof findListSchema>;
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import { LIST_ID, TYPE } from '../../constants.mock';

import { ImportListItemQuerySchemaDecoded } from './import_list_item_query_schema';
import { ImportListItemQuerySchema } from './import_list_item_query_schema';

export const getImportListItemQuerySchemaMock = (): ImportListItemQuerySchemaDecoded => ({
export const getImportListItemQuerySchemaMock = (): ImportListItemQuerySchema => ({
list_id: LIST_ID,
type: TYPE,
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export const importListItemQuerySchema = t.exact(t.partial({ list_id, type }));

export type ImportListItemQuerySchemaPartial = Identity<t.TypeOf<typeof importListItemQuerySchema>>;

export type ImportListItemQuerySchemaDecoded = t.TypeOf<typeof importListItemQuerySchema>;
export type ImportListItemQuerySchema = t.TypeOf<typeof importListItemQuerySchema>;
export type ImportListItemQuerySchemaEncoded = t.OutputOf<typeof importListItemQuerySchema>;
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export const importListItemSchema = t.exact(
})
);

export type ImportListItemSchemaDecoded = t.TypeOf<typeof importListItemSchema>;
export type ImportListItemSchema = t.TypeOf<typeof importListItemSchema>;
export type ImportListItemSchemaEncoded = t.OutputOf<typeof importListItemSchema>;
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ describe('useDeleteList', () => {
});

it('invokes Api.deleteList', async () => {
const { result } = renderHook(() => useDeleteList());
await act(() => result.current.start({ http: httpMock, id: 'list' }));
const { result, waitForNextUpdate } = renderHook(() => useDeleteList());
act(() => {
result.current.start({ http: httpMock, id: 'list' });
});
await waitForNextUpdate();

expect(Api.deleteList).toHaveBeenCalledWith(
expect.objectContaining({ http: httpMock, id: 'list' })
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/lists/public/lists/hooks/use_delete_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/

import { useAsyncTask } from '../../common/hooks/use_async_task';
import { DeleteListParams, deleteList } from '../api';
import { DeleteListParams } from '../types';
import { deleteList } from '../api';

export type DeleteListTaskArgs = Omit<DeleteListParams, 'signal'>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ describe('useExportList', () => {
});

it('invokes Api.exportList', async () => {
const { result } = renderHook(() => useExportList());
await act(() => result.current.start({ http: httpMock, id: 'list' }));
const { result, waitForNextUpdate } = renderHook(() => useExportList());
act(() => {
result.current.start({ http: httpMock, listId: 'list' });
});
await waitForNextUpdate();

expect(Api.exportList).toHaveBeenCalledWith(
expect.objectContaining({ http: httpMock, id: 'list' })
expect.objectContaining({ http: httpMock, listId: 'list' })
);
});
});
3 changes: 2 additions & 1 deletion x-pack/plugins/lists/public/lists/hooks/use_export_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/

import { useAsyncTask } from '../../common/hooks/use_async_task';
import { ExportListParams, exportList } from '../api';
import { ExportListParams } from '../types';
import { exportList } from '../api';

export type ExportListTaskArgs = Omit<ExportListParams, 'signal'>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ describe('useFindLists', () => {
});

it('invokes Api.findLists', async () => {
const { result } = renderHook(() => useFindLists());
await act(() => result.current.start({ http: httpMock, pageIndex: 1, pageSize: 10 }));
const { result, waitForNextUpdate } = renderHook(() => useFindLists());
act(() => {
result.current.start({ http: httpMock, pageIndex: 1, pageSize: 10 });
});
await waitForNextUpdate();

expect(Api.findLists).toHaveBeenCalledWith(
expect.objectContaining({ http: httpMock, pageIndex: 1, pageSize: 10 })
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/lists/public/lists/hooks/use_find_lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/

import { useAsyncTask } from '../../common/hooks/use_async_task';
import { FindListsParams, findLists } from '../api';
import { FindListsParams } from '../types';
import { findLists } from '../api';

export type FindListsTaskArgs = Omit<FindListsParams, 'signal'>;

Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/lists/public/lists/hooks/use_import_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/

import { useAsyncTask } from '../../common/hooks/use_async_task';
import { ImportListParams, importList } from '../api';
import { ImportListParams } from '../types';
import { importList } from '../api';

export type ImportListTaskArgs = Omit<ImportListParams, 'signal'>;

Expand Down

0 comments on commit e7f5b86

Please sign in to comment.