it('default settings set to INFO and metrics off', function() {
     log.init({logging:{}});
     log.error("This is an error");
     log.warn("This is a warn");
     log.info("This is an info");
     log.debug("This is a debug");
     log.trace("This is a trace");
     log.log({level:log.METRIC,msg:"testMetric"});
     sinon.assert.calledWithMatch(util.log,"[error] This is an error");
     sinon.assert.calledWithMatch(util.log,"[warn] This is a warn");
     sinon.assert.calledWithMatch(util.log,"[info] This is an info");
     sinon.assert.neverCalledWithMatch(util.log,"[debug] This is a debug");
     sinon.assert.neverCalledWithMatch(util.log,"[trace] This is a trace");
     sinon.assert.neverCalledWithMatch(util.log,"[metric] ");
 });
 it('ignores lower level messages and metrics', function() {
     var settings = {logging: { console: { level: 'warn', metrics: false } } };
     log.init(settings);
     log.error("This is an error");
     log.warn("This is a warn");
     log.info("This is an info");
     log.debug("This is a debug");
     log.trace("This is a trace");
     log.log({level:log.METRIC,msg:"testMetric"});
     sinon.assert.calledWithMatch(util.log,"[error] This is an error");
     sinon.assert.calledWithMatch(util.log,"[warn] This is a warn");
     sinon.assert.neverCalledWithMatch(util.log,"[info] This is an info");
     sinon.assert.neverCalledWithMatch(util.log,"[debug] This is a debug");
     sinon.assert.neverCalledWithMatch(util.log,"[trace] This is a trace");
     sinon.assert.neverCalledWithMatch(util.log,"[metric] ");
 });
Example #3
0
 it('should save the correct settings to storage with the setParams() method', function () {
   // Checking the invalid parameters:
   competitions.setParams({
     delay: null,
     rates: null,
     displayTime: null,
     audio: null
   });
   // sinon-chai doesn't support neverCalledWithMatch :(
   sinon
     .assert
     .neverCalledWithMatch(kango.storage.setItem, sinon.match.string, null);
   // Checking the valid parameters:
   competitions.setParams({
     delay: 15,
     rates: [1, 2, 3, 5],
     displayTime: 5,
     audio: false
   });
   expect(kango.storage.setItem)
     .to.have.been.calledWithExactly('competition_delay', 15)
     .to.have.been.calledWithExactly('competition_rates', [1, 2, 3, 5])
     .to.have.been.calledWithExactly('competition_displayTime', 5)
     .to.have.been.calledWithExactly('competition_audio', false);
 });
function testNine() {
  let callback = sinon.stub().returns(42);
  callback({ x: 5, y: 5 });
  callback.calledWithMatch({ x: 5 });
  callback.alwaysCalledWithMatch({ y: 5 });
  callback.neverCalledWithMatch({ x: 6 });
  callback.notCalledWithMatch({ x: 6 });
  sinon.assert.calledWithMatch(callback, { x: 5 });
  sinon.assert.alwaysCalledWithMatch(callback, { y: 5 });
  sinon.assert.neverCalledWithMatch(callback, { x: 6 });
}
    it('does nothing if connection is already closed', function* () {
      conn.close();

      var setTimeoutSpy = sandbox.spy(global, 'setTimeout');

      // This normally wouldn't happen (timer would alread be removed)
      // This test is just for coverage
      conn.checkAlive();

      // Make sure setTimeout isn't called
      sinon.assert.neverCalledWithMatch(setTimeoutSpy, sinon.match.func, config.pingInterval);
    });
 it('no logger used if custom logger handler does not exist', function() {
     var settings = {logging: { customLogger: { level: 'trace', metrics: true } } };
     log.init(settings);
     log.error("This is an error");
     log.warn("This is a warn");
     log.info("This is an info");
     log.debug("This is a debug");
     log.trace("This is a trace");
     log.log({level:log.METRIC,msg:"testMetric"});
     sinon.assert.neverCalledWithMatch(util.log,"[error] This is an error");
     sinon.assert.neverCalledWithMatch(util.log,"[warn] This is a warn");
     sinon.assert.neverCalledWithMatch(util.log,"[info] This is an info");
     sinon.assert.neverCalledWithMatch(util.log,"[debug] This is a debug");
     sinon.assert.neverCalledWithMatch(util.log,"[trace] This is a trace");
     sinon.assert.neverCalledWithMatch(util.log,"[metric] ");
 });
 updateUser({ message }, { hull: hullSpy(s, spy), ship: s }).then(() => {
   sinon.assert.calledWith(spy, "account");
   sinon.assert.calledWith(spy, "traits", TESTS.simple.result);
   sinon.assert.neverCalledWithMatch(spy, "track");
   done();
 });
 updateUser({ message }, { hull: hullSpy(s, spy), ship: s }).then(() => {
   sinon.assert.calledWith(spy, "account", { domain: "facebook.com" });
   sinon.assert.calledWith(spy, "traits", {});
   sinon.assert.neverCalledWithMatch(spy, "track");
   done();
 });
 updateUser({ message }, { hull: hullSpy(s, spy), ship: s }).then(() => {
   sinon.assert.neverCalledWithMatch(spy, "traits");
   sinon.assert.neverCalledWithMatch(spy, "track");
   done();
 });
Example #10
0
 }, function () {
   sinon.assert.neverCalledWithMatch(testAdapter.log.writeln, /Existing.*Replacement.*Diff/);
   sinon.assert.called(testAdapter.diff);
   done();
 });