afterEach(() => {
      document.body.removeChild(pwPinButton);
      document.body.removeChild(pwProjectInfo);
      document.body.removeChild(pwUserInfo);

      sinon.restore();
    });
    it('should not delete model and its dependents if an error is thrown on destroy', async () => {
      const author = await Author.forge().save();
      const post = await Post.forge().save({ authorId: author.get('author_id') });

      await Account.forge().save({ authorId: author.get('author_id') });
      await Comment.forge().save({ postId: post.get('post_id') });

      sinon.stub(Model, 'destroy').throws(new Error('foobar'));

      try {
        await author.destroy();

        should.fail();
      } catch (e) {
        e.message.should.equal('foobar');
      }

      const accounts = await Account.fetchAll();
      const authors = await Author.fetchAll();
      const comments = await Comment.fetchAll();
      const posts = await Post.fetchAll();

      accounts.length.should.equal(1);
      authors.length.should.equal(1);
      comments.length.should.equal(1);
      posts.length.should.equal(1);

      sinon.restore(Model);
    });
Example #3
0
 cache.drop(opts, function()
 {
     expect(count).to.equal(2);
     sinon.restore(cache.redis.del);
     cache.logger.error = saved;
     done();
 });
    projectsDB.remove({}, (err) => {
      if (err) {
        throw err
      }

      sinon.restore();
      done();
    });
test('validateListFromOptions works for armv7l host and target arch', t => {
  sinon.stub(process, 'arch').value('arm')
  sinon.stub(process, 'config').value({ variables: { arm_version: '7' } })

  t.deepEqual(targets.validateListFromOptions({}, 'arch'), ['armv7l'])

  sinon.restore()
})
test('hostArch cannot determine ARM version', t => {
  sinon.stub(process, 'arch').value('arm')
  sinon.stub(process, 'config').value({variables: {arm_version: '99'}})

  t.is(targets.hostArch(), 'arm')

  sinon.restore()
})
test('hostArch detects correctly configured armv7l Node', t => {
  sinon.stub(process, 'arch').value('arm')
  sinon.stub(process, 'config').value({variables: {arm_version: '7'}})

  t.is(targets.hostArch(), 'armv7l')

  sinon.restore()
})
Example #8
0
    it('should not override model prototype initialize method', async () => {
      sinon.spy(ModelPrototype, 'initialize');

      Model.forge();

      ModelPrototype.initialize.callCount.should.equal(1);

      sinon.restore(ModelPrototype);
    });
	afterEach(function () {
		sinon.restore();
		if (host !== undefined) {
			process.env.QUALITYWATCHER_ENDPOINT = host;
		}
		else {
			delete process.env.QUALITYWATCHER_ENDPOINT;
		}
	});
    it('should call prototype method `destroy` with given `options`', async () => {
      sinon.spy(Model, 'destroy');

      const author = await Author.forge().save();

      await author.destroy({ foo: 'bar' });

      Model.destroy.callCount.should.equal(1);
      Model.destroy.firstCall.args[0].should.have.properties({ foo: 'bar' });

      sinon.restore(Model);
    });
 afterEach(function (done) {
   sinon.restore()
   // Hangup everything
   parallel([
     (cb) => switchA.hangUp(switchB._peerInfo, cb),
     (cb) => switchA.hangUp(switchC._peerInfo, cb),
     (cb) => switchB.hangUp(switchA._peerInfo, cb),
     (cb) => switchB.hangUp(switchC._peerInfo, cb),
     (cb) => switchC.hangUp(switchA._peerInfo, cb),
     (cb) => switchC.hangUp(switchB._peerInfo, cb)
   ], done)
 })
Example #12
0
	it('supports request(url, callback)', function () {
		var end = sinon.stub(subject.Request.prototype, 'end').returnsThis();
		var spy = sinon.spy();
		var req = subject('http://www.example.com', spy);

		assert(req instanceof subject.Request);
		assert.equal(req.url, 'http://www.example.com');
		assert.equal(req.method, 'GET');

		sinon.assert.calledOnce(end);
		sinon.assert.calledWith(end, spy);

		sinon.restore(end);
	});
Example #13
0
        it('returns a call to edit passing a new admin secret', function () {
            const editStub = sinon.stub(models.ApiKey, 'edit').resolves();

            const fakeData = {
                id: 'TREVOR',
                type: 'admin'
            };
            const fakeOptions = {};

            const result = models.ApiKey.refreshSecret(fakeData, fakeOptions);

            should.equal(result, editStub.returnValues[0]);
            should.equal(editStub.args[0][0].id, 'TREVOR');
            should.equal(editStub.args[0][0].secret.length, 64);
            should.equal(editStub.args[0][1], fakeOptions);

            sinon.restore();
        });
Example #14
0
    test('> handling a middleware', function() {
      var mw = {
        onFetch: function onFetch() {
          return 'for testing purposes';
        }
      };
      var test = {};

      subject.proxyMethods(test);
      test.get('/', mw);

      sinon.assert.calledOnce(subject.add);
      sinon.restore(subject);

      chai.assert.lengthOf(subject.stack, 1);
      var match = subject.stack[0];
      chai.assert.equal(match.method, 'get');
      chai.assert.equal(match.handler(), mw.onFetch());
    });
    it('should rollback any query on given `transaction` if an error is thrown on model destroy', async () => {
      sinon.stub(Model, 'destroy').throws(new Error('foobar'));

      try {
        await repository.knex.transaction(transaction => Author.forge().save(null, { transacting: transaction })
          .then(() => Author.forge().save(null, { transacting: transaction }))
          .then(author => author.destroy({ transacting: transaction }))
        );

        should.fail();
      } catch (e) {
        e.message.should.equal('foobar');
      }

      const authors = await Author.fetchAll();

      authors.length.should.equal(0);

      sinon.restore(Model);
    });
 const after = function() {
   sinon.restore(consoleErrors);
 };
Example #17
0
 afterEach(function () {
     Sinon.restore();
     stdMocks.restore();
 });
Example #18
0
 teardown(function() {
   sinon.restore(subject);
 });
 afterEach(() => {
   sinon.restore();
 });
Example #20
0
		afterEach(function () {
			sinon.restore(Request.prototype.query);
		});
Example #21
0
 afterEach(function () {
     configUtils.restore();
     sinon.restore();
     generateFeedReset();
 });
 afterEach(function () {
   // restore the stubbed services
   sinon.restore();
 });
Example #23
0
  'tearDown': function(done) {
    sinon.restore();

    done();
  },
Example #24
0
 afterEach(function() {
     // restore the environment as it was before
     sinon.restore();
 });
Example #25
0
 afterEach(() => sinon.restore());
Example #26
0
tap.afterEach((done) => {
  sandbox.restore()
  done()
})
Example #27
0
function restore() {
  sinon.restore()
}
 afterEach(function () {
     nock.cleanAll();
     nock.enableNetConnect();
     sinon.restore();
 });
Example #29
0
 afterEach(function () {
     sinon.restore();
 });
Example #30
0
 afterEach(function () {
     configUtils.restore();
     sinon.restore();
 });