neo4j-driver.js 695 B

123456789101112131415161718192021222324252627
  1. const Neo4j = jest.requireActual('neo4j-driver');
  2. export const mockSessionRun = jest.fn(() => {
  3. const observablePromise = Promise.resolve();
  4. observablePromise.subscribe = jest.fn(() => {});
  5. return observablePromise;
  6. });
  7. export const mockSessionClose = jest.fn().mockImplementation(() => {});
  8. export const mockSession = jest.fn().mockImplementation(() => ({
  9. run: mockSessionRun,
  10. close: mockSessionClose
  11. }));
  12. export const mockDriver = jest.spyOn(Neo4j, 'driver').mockImplementation(() => ({
  13. session: mockSession
  14. }));
  15. export function clearAllMocks() {
  16. mockSessionClose.mockClear();
  17. mockSessionRun.mockClear();
  18. mockSession.mockClear();
  19. mockDriver.mockClear();
  20. }
  21. export default Neo4j;