How to use sinon-test - 9 common examples

To help you get started, we’ve selected a few sinon-test 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 Macil / braincrunch / test / machine.js View on Github external
/* @flow */

import assert from 'assert';
import sinon from 'sinon';
import sinonTestFactory from 'sinon-test';
const sinonTest = sinonTestFactory(sinon);

import {Machine} from '../src/index.js';
import {SimpleMachine} from '../src/simple-machine';

[Machine, SimpleMachine].forEach(Ctor => {
  describe(Ctor.name, function() {
    it('works with basic program', function() {
      const output = [];
      const mac = new Ctor({
        code: '+.++.-.',
        write: output
      });
      assert.strictEqual(mac.complete, false);
      const cycles = mac.run();
      assert.strictEqual(mac.complete, true);
      assert.strictEqual(typeof cycles, 'number');
github Nexmo / nexmo-cli / tests / response.js View on Github external
import Response from '../src/response.js';
import Validator from '../src/validator.js';
import Emitter from '../src/emitter.js';
import Config from '../src/config.js';

import fs from 'fs';

import chai, {
  expect
} from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import sinonTest from 'sinon-test';
const test = sinonTest(sinon);

chai.use(sinonChai);


describe('Response', () => {
  let validator;
  let emitter;
  let response;

  beforeEach(() => {
    validator = sinon.createStubInstance(Validator);
    emitter = sinon.createStubInstance(Emitter);
    response = new Response(validator, emitter);
  });

  it('should export a Response object', () => {
github ArkEcosystem / core / packages / client / __tests__ / crypto / ecpair.spec.js View on Github external
import ecurve from 'ecurve'
import sinon from 'sinon'
import sinonTestFactory from 'sinon-test'
import BigInteger from 'bigi'

import ECPair from '../../lib/crypto/ecpair'
import ecdsa from '../../lib/crypto/ecdsa'
import configManager from '../../lib/managers/config'

import fixtures from './fixtures/ecpair.json'
import { NETWORKS, NETWORKS_LIST } from '../utils/network-list'

const curve = ecdsa.__curve
const sinonTest = sinonTestFactory(sinon)

beforeEach(() => configManager.setConfig(NETWORKS.mainnet))

describe('ECPair', () => {
  describe('constructor', () => {
    it('defaults to compressed', () => {
      const keyPair = new ECPair(BigInteger.ONE)

      expect(keyPair.compressed).toBeTruthy()
    })

    it('supports the uncompressed option', () => {
      const keyPair = new ECPair(BigInteger.ONE, null, {
        compressed: false
      })
github ArkEcosystem / core / packages / client / __tests__ / crypto / ecdsa.spec.js View on Github external
import sinon from 'sinon'
import sinonTestFactory from 'sinon-test'
import BigInteger from 'bigi'

import ecdsa from '../../lib/crypto/ecdsa'
import bcrypto from '../../lib/crypto'
import ECSignature from '../../lib/crypto/ecsignature'

import fixtures from './fixtures/ecdsa.json'

const curve = ecdsa.__curve
const sinonTest = sinonTestFactory(sinon)

describe('ecdsa', () => {
  describe('deterministicGenerateK', () => {
    function checkSig () {
      return true
    }

    fixtures.valid.ecdsa.forEach((f) => {
      it(`for "${f.message}"`, () => {
        const x = BigInteger.fromHex(f.d).toBuffer(32)
        const h1 = bcrypto.sha256(f.message)

        const k = ecdsa.deterministicGenerateK(h1, x, checkSig)
        expect(k.toHex()).toBe(f.k)
      })
    })
github Nexmo / nexmo-cli / tests / request.js View on Github external
import Client   from '../src/client.js';
import Config   from '../src/config.js';
import Request  from '../src/request.js';
import Response from '../src/response.js';

import Account        from 'nexmo/lib/Account';
import App            from 'nexmo/lib/App';
import Message        from 'nexmo/lib/Message';
import Number         from 'nexmo/lib/Number';
import NumberInsight  from 'nexmo/lib/NumberInsight';

import chai, { expect } from 'chai';
import sinon      from 'sinon';
import sinonChai  from 'sinon-chai';
import sinonTest        from 'sinon-test';
const test = sinonTest(sinon);

chai.use(sinonChai);

describe('Request', () => {
  it('should export a Request object', () => {
    expect(Request).to.not.be.null;
    expect(Request.name).to.equal('Request');
  });

  describe('with an instance', () => {
    let client;
    let config;
    let nexmo;
    let request;
    let response;
github canalplus / react-keys / test / config.js View on Github external
import chai from 'chai';
import sinonTest from 'sinon-test';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import chaiEnzyme from 'chai-enzyme';
import { _init } from '../src/listener';
import { ops } from './mocks';

sinon.test = sinonTest.configureTest(sinon);

chai.should();
chai.use(sinonChai);
chai.use(chaiEnzyme());
_init(ops);
github ArkEcosystem / core / packages / client / __tests__ / crypto / hdnode.spec.js View on Github external
import assert from 'assert'
import sinon from 'sinon'
import sinonTestFactory from 'sinon-test'
import BigInteger from 'bigi'

import configManager from '../../lib/managers/config'
import ecdsa from '../../lib/crypto/ecdsa'
import ECPair from '../../lib/crypto/ecpair'
import HDNode from '../../lib/crypto/hdnode'
import { NETWORKS, NETWORKS_LIST } from '../utils/network-list'

import fixtures from './fixtures/hdnode.json'

const sinonTest = sinonTestFactory(sinon)

beforeEach(() => configManager.setConfig(NETWORKS.mainnet))

let validAll = []
fixtures.valid.forEach((f) => {
  function addNetwork (n) {
    n.network = f.network
    return n
  }

  validAll = validAll.concat(addNetwork(f.master), f.children.map(addNetwork))
})

describe('HDNode', () => {
  describe('Constructor', () => {
    let keyPair
github dadi / web / test / unit / cache.js View on Github external
var path = require("path")
var should = require("should")

var sinon = require("sinon")
var sinonTest = require("sinon-test")

sinon.test = sinonTest.configureTest(sinon)
sinon.testCase = sinonTest.configureTestCase(sinon)

var api = require(__dirname + "/../../dadi/lib/api")
var Server = require(__dirname + "/../help").Server
var cache = require(__dirname + "/../../dadi/lib/cache")
var datasource = require(__dirname + "/../../dadi/lib/datasource")
var page = require(__dirname + "/../../dadi/lib/page")
var TestHelper = require(__dirname + "/../help")()
var config = require(path.resolve(path.join(__dirname, "/../../config")))

describe("Cache", function(done) {
  beforeEach(function(done) {
    TestHelper.resetConfig().then(() => {
      done()
    })
  })
github dadi / web / test / unit / cache.js View on Github external
var path = require("path")
var should = require("should")

var sinon = require("sinon")
var sinonTest = require("sinon-test")

sinon.test = sinonTest.configureTest(sinon)
sinon.testCase = sinonTest.configureTestCase(sinon)

var api = require(__dirname + "/../../dadi/lib/api")
var Server = require(__dirname + "/../help").Server
var cache = require(__dirname + "/../../dadi/lib/cache")
var datasource = require(__dirname + "/../../dadi/lib/datasource")
var page = require(__dirname + "/../../dadi/lib/page")
var TestHelper = require(__dirname + "/../help")()
var config = require(path.resolve(path.join(__dirname, "/../../config")))

describe("Cache", function(done) {
  beforeEach(function(done) {
    TestHelper.resetConfig().then(() => {
      done()
    })
  })

sinon-test

<a href="CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg" alt="Contributor Covenant" /></a>

BSD-3-Clause
Latest version published 7 months ago

Package Health Score

73 / 100
Full package analysis