DefinitelyTyped/types/pouch-redux-middleware/pouch-redux-middleware-tests.ts
FaithForHumans 56b659e0f0 [pouch-redux-middleware] v1.2 (#38277)
* Updating pouch-redux-middleware for v1.2

* Fixing spacing
2019-09-24 16:42:48 -07:00

26 lines
881 B
TypeScript

import * as redux from 'redux';
import makePouchMiddleware, { Document, Path } from 'pouch-redux-middleware';
import PouchDB = require('pouchdb');
const types = {
DELETE_TODO: 'delete-todo',
BATCH_INSERT_TODO: 'batch-insert-todo',
INSERT_TODO: 'insert-todo',
UPDATE_TODO: 'update-todo'
};
const path: Path<{}> = {
path: "/test",
db: new PouchDB('test'),
actions: {
remove: doc => ({ type: types.DELETE_TODO, id: doc._id }),
batchInsert: doc => ({ type: types.BATCH_INSERT_TODO, todo: doc }),
insert: doc => ({ type: types.INSERT_TODO, todo: doc }),
update: doc => ({ type: types.UPDATE_TODO, todo: doc }),
},
initialBatchDispatched: (error?: Error) => {},
};
const middleware: redux.Middleware = makePouchMiddleware<{}>(path);
const otherMiddleware: redux.Middleware = makePouchMiddleware([path, path, path]);