How to use chai - 10 common examples

To help you get started, we’ve selected a few chai 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 ExpediaDotCom / c3vis / test / configSpec.js View on Github external
it('should override with environment values', function() {
    process.env.TARGET_ENV = "test";
    // Invalidate cached config module so we can load it again with new TARGET_ENV
    delete require.cache[require.resolve(CONFIG_MODULE_FILE_NAME)];
    const subject = require(CONFIG_MODULE_FILE_NAME);
    checkDefaults(subject);
    assert.equal(subject.environmentName, "Test");
  });
});
github invisible-college / democracy / tests / link.spec.js View on Github external
const demo = require('..')
const chai = require('chai')
const assert = chai.assert
const expect = chai.expect
const should = chai.should()
chai.use(require('chai-as-promised'))

const { Map, List } = require('immutable')

let networkId

describe('Democracy linking', () => {

  before(async () => {
    demo.cleanCompileSync("TestLibrary")
    eth = demo.getNetwork('test')
    networkId = await eth.net_version()
  })

  // Expect error thrown from promise
  // https://stackoverflow.com/a/45496509
  it('throws an error to link without compiling', async () => {
github interledgerjs / ilp / test / clientSpec.js View on Github external
'use strict'
/* global describe it beforeEach afterEach */

const chai = require('chai')
const expect = chai.expect
const mockRequire = require('mock-require')
const sinon = require('sinon')
const sinonChai = require('sinon-chai')
chai.use(sinonChai)

const MockCore = require('./mocks/mock-core')
mockRequire('ilp-core', MockCore)
const Client = require('../src/lib/client')
const PaymentRequest = require('../src/lib/request')

const FAKE_TIME = 0

describe('Client', function () {
  describe('constructor', function () {
    it('should instantiate an ilp-core client', function () {
      const client = new Client({
        auth: {
          account: 'https://ledger.example/accounts/alice',
          password: 'alice'
        }
github GoogleChromeLabs / sw-toolbox / test / automated-suite.js View on Github external
'use strict';

/* eslint-disable max-len, no-console, padded-blocks, no-multiple-empty-lines */
/* eslint-env node,mocha */

// These tests make use of selenium-webdriver. You can find the relevant
// documentation here: https://github.com/SeleniumHQ/selenium

const path = require('path');
const seleniumAssistant = require('selenium-assistant');
const mochaUtils = require('sw-testing-helpers').mochaUtils;

require('geckodriver');
require('chromedriver');

require('chai').should();

const testServer = require('./server/index.js');

describe('Test SW-Toolbox', function() {
  // Browser tests can be slow
  this.timeout(100000);

  // Selenium Tests are Flakey
  this.retries(3);

  // Driver is initialised to `null` to handle scenarios
  // where the desired browser isn't installed / fails to load
  // `null` allows afterEach a safe way to skip quiting the driver
  let globalDriverReference = null;
  let testServerURL;
github SciCatProject / catamel / test / Users.js View on Github external
/* jshint node:true */
/* jshint esversion:6 */
'use strict';

// process.env.NODE_ENV = 'test';

var chai = require('chai');
var chaiHttp = require('chai-http');
var request = require('supertest');
var utils = require('./LoginUtils');
var should = chai.should();

var accessToken = null;

var app
before( function(){
    app = require('../server/server')
});

describe('Login with functional accounts', () => {

    it('Ingestor login fails with incorrect credentials', function(done) {
        request(app)
            .post('/api/v3/Users/Login?include=user')
            .send({
                'username': 'ingestor',
                'password': 'abc123'
github appium / appium / test / functional / ios / testapp / device-specs.js View on Github external
"use strict";

var _ = require('underscore'),
    initSession = require('../../../helpers/session').initSession,
    should = require('chai').should(),
    expect = require('chai').expect,
    XCODE = require('../../../../lib/future.js').xcode,
    fs = require('fs'),
    env = process.env,
    desired = require('./desired');

require('../../../helpers/setup-chai.js');

describe('testapp - device', function () {

  describe('xcode#getpath', function () {
    it('should always return a valid path', function (done) {
      this.timeout(5000);
      // getPath failures have been intermittent, so try a few times
      var iterations = 100;
      var nextTest = function () {
github chrisveness / geodesy / test / latlon-vectors-tests.js View on Github external
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
/*  Geodesy Test Harness - latlon-vectors                             (c) Chris Veness 2014-2017  */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */

'use strict';

require('chai').should();  // BDD/TDD assertion library

var LatLon   = require('../npm.js').LatLonVectors;
var Vector3d = require('../npm.js').Vector3d;
var Dms      = require('../npm.js').Dms;

var test = it; // just an alias

describe('latlon-vectors', function() {
    var R = 6371e3;
    var π = Math.PI;

    describe('formatting', function() {
        test('toString d',       function() { new LatLon(51.521470, -0.138833).toString('d', 6).should.equal('51.521470°N, 000.138833°W'); });
        test('toString dms',     function() { new LatLon(51.521470, -0.138833).toString('dms', 2).should.equal('51°31′17.29″N, 000°08′19.80″W'); });
    });
github AXErunners / axecore-lib / test / mnemonic / mnemonic.unit.js View on Github external
/* eslint-disable */
// TODO: Remove previous line and work through linting issues at next edit

'use strict';

var chai = require('chai');
var should = chai.should();

var Mnemonic = require('../../index').Mnemonic;
var errors = require('../../lib/mnemonic/errors');
var bip39_vectors = require('./data/fixtures.json');

describe('Mnemonic', function() {
  this.timeout(30000);

  it('should initialize the class', function() {
    should.exist(Mnemonic);
  });

  describe('# Mnemonic', function() {

    describe('Constructor', function() {
      it('does not require new keyword', function() {
github keymanapp / keyman / common / predictive-text / unit_tests / headless / promise-store.js View on Github external
it("should track a promise's callbacks", function () {
      var promises = new PromiseStore();
      // There should be no tracked promises.
      assert.lengthOf(promises, 0);

      // Add one promise.
      new Promise(function (resolve, reject) {
        promises.make(randomToken(), resolve, reject);
      });
      assert.lengthOf(promises, 1);
    });
github Paratii-Video / paratii-js / test / tcr / registry.spec.js View on Github external
let amountToAllowWei = paratii.eth.web3.utils.toWei('100')
    let amountToAllowInHex = paratii.eth.web3.utils.toHex(amountToAllowWei)
    let tx2 = await token.methods.approve(tcrRegistry.options.address, amountToAllowInHex).send()
    assert.isOk(tx2)

    // let allowance = await token.methods.allowance(address, tcrRegistry.options.address).call()
    // assert.equal(allowance, paratii.eth.web3.utils.toWei('100'))

    let applicationTx = await tcrRegistry.methods.apply(
      paratii.eth.web3.utils.soliditySha3('test_video_id'),
      paratii.eth.web3.utils.toWei('20'),
      ''
    ).send()

    assert.isOk(applicationTx)
    assert.isOk(applicationTx.events._Application)
    // console.log('apply Tx', applicationTx)
  })