How to use the megalodon.mockImplementation function in megalodon

To help you get started, we’ve selected a few megalodon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github h3poteto / whalebird-desktop / spec / renderer / integration / store / TimelineSpace / Contents / Home.spec.js View on Github external
it('should be updated', async () => {
      const mockClient = {
        get: () => {
          return new Promise((resolve, reject) => {
            resolve({
              data: [
                { id: 1 },
                { id: 2 }
              ]
            })
          })
        }
      }

      Mastodon.mockImplementation(() => mockClient)
      const statuses = await store.dispatch('Home/fetchTimeline')
      expect(statuses).toEqual([
        { id: 1 },
        { id: 2 }
      ])
      expect(store.state.Home.timeline).toEqual([
        { id: 1 },
        { id: 2 }
      ])
    })
  })
github h3poteto / whalebird-desktop / spec / renderer / integration / store / TimelineSpace / Contents / Mentions.spec.js View on Github external
const mockClient = {
        get: () => {
          return new Promise((resolve, reject) => {
            resolve({
              data: [
                { id: 1, type: 'mention' },
                { id: 2, type: 'favourite' },
                { id: 3, type: 'reblog' },
                { id: 4, type: 'follow' }
              ]
            })
          })
        }
      }

      Mastodon.mockImplementation(() => mockClient)
      await store.dispatch('Mentions/fetchMentions')
      expect(store.state.Mentions.mentions).toEqual([
        { id: 1, type: 'mention' },
        { id: 2, type: 'favourite' },
        { id: 3, type: 'reblog' },
        { id: 4, type: 'follow' }
      ])
    })
  })

megalodon

Fediverse API client for node.js and browser

MIT
Latest version published 15 days ago

Package Health Score

78 / 100
Full package analysis