File size: 619 Bytes
9705b6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const mockGet = jest.fn();
const mockSet = jest.fn();

jest.mock('@keyv/mongo', () => {
  const EventEmitter = require('events');
  class KeyvMongo extends EventEmitter {
    constructor(url = 'mongodb://127.0.0.1:27017', options) {
      super();
      this.ttlSupport = false;
      url = url ?? {};
      if (typeof url === 'string') {
        url = { url };
      }
      if (url.uri) {
        url = { url: url.uri, ...url };
      }
      this.opts = {
        url,
        collection: 'keyv',
        ...url,
        ...options,
      };
    }

    get = mockGet;
    set = mockSet;
  }

  return KeyvMongo;
});