Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
/ Orion Public archive

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kernelwhisperer committed Jul 2, 2018
1 parent 9ff6ccb commit 7f6c13f
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions app/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@ import * as api from './api'
import ipfsApi from 'ipfs-api'
import multiaddr from 'multiaddr'
import request from 'request-promise-native'
// import gateways from './gateways'
import pjson from '../package'
// import Settings from 'electron-settings'

jest.mock('fs', () => {
return {
statSync: jest.fn().mockReturnValue({ size: 13 })
}
})

jest.mock('electron', () => {
return {
app: {
emit: jest.fn()
}
}
})

jest.mock('ipfs-api', () => {
return jest.fn().mockReturnValue('new-instance')
Expand All @@ -16,12 +28,12 @@ jest.mock('./gateways', () => {

jest.mock('./stats', () => {
return {
trackEvent: jest.fn().mockReturnValue(Promise.resolve())
trackEvent: jest.fn().mockResolvedValue()
}
})

jest.mock('request-promise-native', () => {
return jest.fn().mockReturnValue(Promise.resolve())
return jest.fn().mockResolvedValue()
})

jest.mock('electron-settings', () => {
Expand Down Expand Up @@ -237,7 +249,10 @@ describe('api.js', () => {
return api.addFilesFromFSPath(['./textfiles'], queryGatewaysMock)
.then(result => {
// assert
expect(addFromFsMock).toHaveBeenCalledWith('./textfiles', { recursive: true })
expect(addFromFsMock).toHaveBeenCalledWith('./textfiles', {
recursive: true,
progress: expect.any(Function)
})
expect(objectPutMock).toHaveBeenCalledWith({
Data: Buffer.from('\u0008\u0001'),
Links: [{
Expand Down

0 comments on commit 7f6c13f

Please sign in to comment.