Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @format
import { expectSaga } from "redux-saga-test-plan";
import { call } from "redux-saga/effects";
import Web3 from "web3";
import { fetchTransactionsBatch } from "../../src/sagas/fetchTransactions";
expectSaga.DEFAULT_TIMEOUT = 500;
describe("transaction fetching", () => {
it("should process transactions correctly and return a token", async () => {
const contractAddress = "0x9326f84fcca8a136da3a4f71bbffbde6635c58da";
const address = "0x51Ff1fab76079d20418d1c74DA65653FfE3fD0aa";
const web3Mock = {
eth: {
net: {
getId: jest.fn(() => 1)
},
Contract: jest.fn(() => {
return {
getPastEvents: jest
.fn()
.mockReturnValueOnce([{ returnValues: { _tokenId: 1 } }]) //outputs
.mockReturnValueOnce([{ returnValues: { _tokenId: 2 } }]), // inputs
// import { throwError } from 'redux-saga-test-plan/providers'
import {
processPayment
} from '../payments'
import {
requestPayment,
setAmount,
setTip
} from '../../actions/payments'
import * as types from '../../actions/constants/payments'
// Travis CI timeout using default 250ms
expectSaga.DEFAULT_TIMEOUT = process.env.ASYNC_TIMEOUT || expectSaga.DEFAULT_TIMEOUT
const at = (timestamp, execute) => {
const { Date } = global
global.Date = jest.fn(() => new Date(timestamp))
try {
return execute()
} finally {
global.Date = Date
}
}
const URL_BASE = 'https://stagenet.kasisto.io:28082'
const URL_PATH = '/json_rpc'
const URL = `${URL_BASE}${URL_PATH}`
const mockRequest = nock(URL_BASE)