How to use the jest-mock-axios.mockResponse function in jest-mock-axios

To help you get started, weā€™ve selected a few jest-mock-axios 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 klarstil / lifx-http-api / __tests__ / lifx / lifx-factory.spec.ts View on Github external
it('should set a state delta', (done) => {
        const token = process.env.TOKEN as string;
        const factory = new LifxFactory(token);
        const selector = (new SelectorCriteria())
            .setAll();

        const state = new StateCriteria(selector);
        state.setColor((new ColorCriteria()).setName('green'));

        factory.setStateDelta(state).then((result: LifxEffectResult) => {
            expect(result.results.length).toBe(1);
            done();
        });

        mockAxios.mockResponse({ data: effectFixtures } as AxiosResponse);
    });
github indico / indico / indico / modules / events / editing / client / js / __tests__ / FileManager.spec.jsx View on Github external
await act(async () => {
    mockAxios.mockResponse(
      {
        data: {
          uuid,
          filename: name,
          claimed: false,
          downloadURL: 'goes://nowhere',
        },
      },
      mockAxios.mustGetReqByUrl('goes://nowhere')
    );
  });
github Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-account / src / __tests__ / wallet.spec.ts View on Github external
const [wallet] = createWallet(1);
    const pubKey = (wallet.defaultAccount &&
      wallet.defaultAccount.publicKey) as string;

    const tx = new Transaction({
      version: 1,
      nonce: 1,
      to: '0x1234567890123456789012345678901234567890',
      amount: new BN(0),
      gasPrice: 1000,
      gasLimit: 1000,
      pubKey,
    });

    const signed = wallet.sign(tx);
    mockAxios.mockResponse({
      data: {
        result: {nonce: 1},
      },
    });

    return signed.then(tx => {
      const bytes = tx.bytes;
      const signature = schnorr.toSignature(tx.return().signature as string);
      const lgtm = schnorr.verify(bytes, signature, Buffer.from(pubKey, 'hex'));

      expect(lgtm).toBeTruthy();
    });
  });
github Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-account / src / __tests__ / transaction.spec.ts View on Github external
return tx.then(tx => {
      tx.confirmReceipt('some_hash').map(txObj => {
        expect(txObj.id).toEqual('some_hash');
        expect(txObj.receipt).toEqual({succcess: true, cumulative_gas: 1000});
        expect(tx.isPending()).toBeFalsy();
        expect(tx.isConfirmed()).toBeTruthy();
        return txObj;
      });

      mockAxios.mockResponse({
        data: {
          result: {
            ID: 'some_hash',
            receipt: {
              success: true,
              cumulative_gas: 1000,
            },
          },
        },
      });
    });
  });