How to use the sinon.assert.calledWith function in sinon

To help you get started, we’ve selected a few sinon 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 DevWurm / webpack-war-plugin / src / WebpackWarPlugin.spec.ts View on Github external
it('Should be hooked into the after-emit step', function () {
      const spyPlugin = spy(compiler, 'plugin');

      const plugin = new WebpackWarPlugin({ archiveName: 'Test' });
      plugin.apply(compiler);

      assert.calledWith(spyPlugin, 'after-emit');
    });
  });
github dragonchain / dragonchain-sdk-javascript / src / services / dragonchain-client / DragonchainClient.spec.ts View on Github external
it('calls #fetch() with correct params', async () => {
        await client.createApiKey({ nickname: 'mynickname', permissionsDocument: { version: '1', default_allow: true, permissions: {} } });
        const expectedBody = { nickname: 'mynickname', permissions_document: { version: '1', default_allow: true, permissions: {} } };
        assert.calledWith(fetch, 'fakeUrl/v1/api-key', { ...expectedFetchOptions, body: JSON.stringify(expectedBody) });
      });
    });
github dragonchain / dragonchain-sdk-javascript / src / services / dragonchain-client / DragonchainClient.spec.ts View on Github external
it('calls #fetch() with correct params', async () => {
        const fakeBody: any = {
          version: '1',
          testnet: true,
          private_key: 'abcd',
          rpc_address: 'some rpc',
          rpc_authorization: 'some auth',
          utxo_scan: false
        };
        await client.updateBitcoinInterchain({ name: 'banana', testnet: true, privateKey: 'abcd', rpcAddress: 'some rpc', rpcAuthorization: 'some auth', utxoScan: false });
        const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
        assert.calledWith(fetch, 'fakeUrl/v1/interchains/bitcoin/banana', obj);
      });
    });
github dragonchain / dragonchain-sdk-javascript / src / services / dragonchain-client / DragonchainClient.spec.ts View on Github external
it('calls #fetch() with correct params', async () => {
        const fakeBody: any = {
          version: '1',
          fee: 4,
          data: 'someData',
          change: 'change address',
          outputs: [{ to: 'toaddr', value: 1.234 }]
        };
        await client.signBitcoinTransaction({ name: 'banana', satoshisPerByte: 4, data: 'someData', changeAddress: 'change address', outputs: [{ to: 'toaddr', value: 1.234 }] });
        const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
        assert.calledWith(fetch, 'fakeUrl/v1/interchains/bitcoin/banana/transaction', obj);
      });
    });
github silversonicaxel / summary-more / src / class / maker.spec.ts View on Github external
it('should return an error', async () => {
      const file = './somefile.md'
      const fileContent = 'Text'
      const expectedIsWriteCorrect = false
      const writeFileAsyncStub = sandboxSet.stub(maker, 'writeFileAsync').yields('writeError')

      const isWriteCorrect = await maker['writeSummaryFile'](file, fileContent)

      assert.calledOnce(writeFileAsyncStub)
      assert.calledWith(writeFileAsyncStub, file, fileContent, 'utf8')
      expect(isWriteCorrect).to.equal(expectedIsWriteCorrect)
    })
  })
github dragonchain / dragonchain-sdk-javascript / src / services / dragonchain-client / DragonchainClient.spec.ts View on Github external
it('calls #fetch() with correct params', async () => {
        const smartContractId = '616152367378';
        const status = 'active';
        const fakeBodyResponse: any = {
          version: '3',
          desired_state: status
        };
        await client.updateSmartContract({ smartContractId, enabled: true });
        const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBodyResponse) };
        assert.calledWith(fetch, `fakeUrl/v1/contract/${smartContractId}`, obj);
      });
    });
github dragonchain / dragonchain-sdk-javascript / src / services / dragonchain-client / DragonchainClient.spec.ts View on Github external
it('calls #fetch() with correct params', async () => {
        const fakeBody: any = {
          version: '1',
          name: 'banana',
          testnet: true,
          private_key: 'abcd',
          node_url: 'some IP',
          rpc_port: 1234,
          api_port: 5678
        };
        await client.createBinanceInterchain({ name: 'banana', testnet: true, privateKey: 'abcd', nodeURL: 'some IP', rpcPort: 1234, apiPort: 5678 });
        const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
        assert.calledWith(fetch, 'fakeUrl/v1/interchains/binance', obj);
      });
    });
github dragonchain / dragonchain-sdk-javascript / src / services / dragonchain-client / DragonchainClient.spec.ts View on Github external
it('calls #fetch() with correct params', async () => {
        await client.listInterchainNetworks({ blockchain: 'bitcoin' });
        assert.calledWith(fetch, 'fakeUrl/v1/interchains/bitcoin');
      });
    });
github dragonchain / dragonchain-sdk-javascript / src / services / dragonchain-client / DragonchainClient.spec.ts View on Github external
environmentVariables: { banana: 'banana', apple: 'banana' },
          cmd: 'banana',
          args: ['-m', 'cool']
        };
        const expectedBody = {
          version: '3',
          txn_type: 'name',
          image: contractPayload.image,
          execution_order: 'parallel',
          cmd: contractPayload.cmd,
          args: contractPayload.args,
          env: contractPayload.environmentVariables
        };
        await client.createSmartContract(contractPayload);
        const obj = { ...expectedFetchOptions, body: JSON.stringify(expectedBody) };
        assert.calledWith(fetch, 'fakeUrl/v1/contract', obj);
      });
    });
github dragonchain / dragonchain-sdk-javascript / src / services / dragonchain-client / DragonchainClient.spec.ts View on Github external
field_name: 'someField',
              type: 'text',
              options: {
                no_index: false,
                weight: 0.5,
                sortable: true
              }
            }
          ]
        };
        await client.createTransactionType({
          transactionType: 'testing',
          customIndexFields: [{ path: 'testPath', fieldName: 'someField', type: 'text', options: { noIndex: false, sortable: true, weight: 0.5 } }]
        });
        const obj = { ...expectedFetchOptions, body: JSON.stringify(expectedBody) };
        assert.calledWith(fetch, 'fakeUrl/v1/transaction-type', obj);
      });
    });