How to use the chai.assert function in chai

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 azuqua / notp / test / unit / gossip.js View on Github external
it("Should merge two rings on a join event", function () {
        var data = gossip.decodeJob(Buffer.from(JSON.stringify({
          event: "ring",
          data: {
            type: "join",
            actor: "foo",
            vclock: vclock.toJSON(true),
            data: chash.toJSON(true),
            round: 0
          }
        })));
        sinon.spy(gossip, "_joinNewRing");
        gossip._mergeRings(data.data);
        assert(gossip._joinNewRing.called);
        gossip._joinNewRing.restore();
      });
github okfn / opendatasurvey / tests / localization.js View on Github external
browser.visit('/', function() {
      assert.ok(browser.success);
      var item = browser.query('.lang-picker span');
      assert(!!item, 'There should be current language indicator');
      var prevLanguage = item.textContent;

      item = browser.query('.lang-picker a');
      assert(!!item, 'There should be language switcher');
      var requestedLanguage = item.textContent;

      browser.visit(item.getAttribute('href'), function() {
        assert.ok(browser.success);
        var item = browser.query('.lang-picker span');
        assert(!!item, 'There should be current language indicator');
        var newLanguage = item.textContent;
        assert(prevLanguage != newLanguage,
          'New language should be different from previous');
        assert(requestedLanguage == newLanguage,
          'New language should be the one that we requested');
        done();
      });
    });
  });
github sithmel / async-deco / tests / promise / limit.spec.js View on Github external
return function (ms) {
    var t1 = Date.now()
    var delta = t1 - t0
    assert(delta < ms + 5, 'It took more than ' + ms + ' ms')
    assert(delta > ms - 5, 'It took less than ' + ms + ' ms')
  }
}
github goatslacker / alt / test / immutable-stores.js View on Github external
}

        handleReplaceList(x) {
          this.setState(this.state.set('list', Immutable.fromJS(x).toList()))
        }
      }

      const store = alt.createStore(ImmutableStore, 'ImmutableStore')

      assert(store.getState().get('bar') === 'hello', 'bar is initially `hello`')
      assert(store.getState().get('map').count() === 0, 'map is initially zero')
      assert(store.getState().get('list').count() === 0, 'list is initially zero')

      actions.replaceMap({a: 1, b: 2})
      assert(store.getState().get('bar') === 'hello', 'bar is still `hello` after replacing map')
      assert(store.getState().get('list').count() === 0, 'list still has zero items after replacing map')
      assert(store.getState().get('map').count() === 2, 'map has 2 items in it now after replacing map')

      actions.replaceList([1, 2, 3, 4])
      assert(store.getState().get('bar') === 'hello', 'bar is still `hello` after replacing list')
      assert(store.getState().get('list').count() === 4, 'list has 4 items now after replacing list')
      assert(store.getState().get('map').count() === 2, 'map still has 2 items in it after replacing list')

      actions.updateBar('world')
      assert(store.getState().get('bar') === 'world', 'bar is now `world` after updating bar')
      assert(store.getState().get('list').count() === 4, 'list still has 4 items  after updating bar')
      assert(store.getState().get('map').count() === 2, 'map still has 2 items in it after updating bar')
    },
github Goyoo / node-k8s-client / test / kubectl_node.js View on Github external
kubectl.node.list(function(err, data){
			assert(!err && data)
			done(err)
		})
	})
github goatslacker / alt / test / index.js View on Github external
'snapshotting'() {
    myActions.updateName('bear')
    const snapshot = alt.takeSnapshot()
    assert.isString(snapshot, 'a snapshot json is returned')
    assert(JSON.parse(snapshot).MyStore.name === 'bear', 'the state is current')
    assert.isObject(JSON.parse(snapshot).AltSecondStore, 'the custom identifier name works')

    myActions.updateName('blossom')
    assert(myStore.getState().name === 'blossom', 'action was called, state was updated properly')
    assert(JSON.parse(snapshot).MyStore.name === 'bear', 'the snapshot is not affected by action')
  },
github microsoft / pxt / tests / pydecompile-test / pydecompilerunner.ts View on Github external
function fail(msg: string) {
    chai.assert(false, msg);
}
github invisible-college / democracy / packages / compile / src / compile.js View on Github external
return new Map(List(inputsToBuild.values()).map((val) => {
      const fn = val.get('filename')
      assert(val.get('source'), `${fn} contains null source`)
      return [ val.get('filename'), { content: val.get('source') } ]
    })) 
  }
github pluralsight-projects / Angular-AlbumStoreProductPage / src / spec / mocha-specs / part3 / product-service-getalbum-method-maps-response-to-json.spec.js View on Github external
"It doesn't look like you are declaring `private _albumUrl` keyword and assigning the contents of the `album.json` file to it."
    );

    const albumJsonFile = tsquery(
      ast,
      "PropertyDeclaration StringLiteral[value='../assets/album.json']"
    );

    assert(
      albumJsonFile.length > 0,
      "It doesn't look like you are declaring `private _albumUrl` keyword and assigning the contents of the `album.json` file to it."
    );

    const getAlbumMethod = tsquery(ast, 'Identifier[name="getAlbum"]');

    assert(
      getAlbumMethod.length > 0,
      "The ProductService doesn't have a method named `getAlbum()` yet."
    );

    const returnStatement = tsquery(
      ast,
      "MethodDeclaration:has(Identifier[name=getAlbum]) ReturnStatement"
    );

    assert(
      returnStatement.length > 0,
      "The `getAlbum()` doesn't have a `return` statement yet."
    );

    const thisStatement = tsquery(
      ast,