- it("initializes service with middleware api", () => {
- const config = {
- id: "",
- columns: [],
- requestItems: jest.fn(),
- setApi: jest.fn()
- };
- const service = new ServiceMock(config);
- const api = {
- getState: jest.fn(),
- dispatch: jest.fn()
- };
- dataExplorerMiddleware(service)(api)(jest.fn());
- expect(config.setApi).toHaveBeenCalled();
- });
-
- it("initializes columns in the store", () => {
- const config = {
- id: "Id",
- columns: [{
- name: "Column",
- selected: true,
- render: jest.fn()
- }],
- requestItems: jest.fn(),
- setApi: jest.fn()
- };
- const service = new ServiceMock(config);
- const api = {
- getState: jest.fn(),
- dispatch: jest.fn()
- };
- const next = jest.fn();
- dataExplorerMiddleware(service)(api)(next);
- expect(next)
- .toHaveBeenCalledWith(dataExplorerActions.SET_COLUMNS({ id: service.Id, columns: service.Columns }));
- });