How to use power-assert - 10 common examples

To help you get started, we’ve selected a few power-assert 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 ahomu / Talkie / test / control.js View on Github external
it('click()', function() {
    let spy = sinon.spy(function(e) {
      // noop
    });

    let target = document.createElement('div');
    click(target).subscribe(spy);

    ClickEvent.simulate(target);
    assert(spy.calledOnce);
    ClickEvent.simulate(target);
    assert(spy.calledTwice);
    ClickEvent.simulate(target);
    assert(spy.calledThrice);
  });
github alibaba-fusion / next / test / select / index-spec.js View on Github external
it('should support keyCode up & down', () => {
        const dataSource = [
            { label: 'xxx', value: 'a' },
            { label: 'empty', value: 'b' },
        ];
        wrapper.setProps({
            dataSource,
            visible: true,
        });
        wrapper.find('input').simulate('keydown', { keyCode: 40 });
        wrapper.find('input').simulate('keydown', { keyCode: 40 });
        wrapper.update();
        assert(
            document.querySelectorAll('.next-menu-item.next-focused').length ===
                1
        );
        wrapper.find('input').simulate('keydown', { keyCode: 13 });
        wrapper.update();
        assert(wrapper.find('input').prop('value') === 'b');

        wrapper.find('input').simulate('keydown', { keyCode: 38 });
        wrapper.find('input').simulate('keydown', { keyCode: 27 });
        wrapper.find('input').simulate('keydown', { keyCode: 32 });
        wrapper.find('input').simulate('keydown', { keyCode: 8 });
        wrapper.find('input').simulate('keydown', { keyCode: 9 });

        // wrapper.find('input').simulate('keydown', {keyCode: 38});
        // wrapper.find('input').simulate('keydown', {keyCode: 13});
        // assert(wrapper.find('input').prop('value') === 'a');
github googleapis / nodejs-firestore / test / query.js View on Github external
assert.throws(() => {
      query.orderBy(Firestore.FieldPath.documentId())
          .startAt(firestore.doc('coll/doc/other/doc'));
    }, /'coll\/doc\/other\/doc' is not part of the query result set and cannot be used as a query boundary./);

    assert.throws(() => {
      query.orderBy(Firestore.FieldPath.documentId())
          .startAt(firestore.doc('coll/doc/coll_suffix/doc'));
    }, /'coll\/doc\/coll_suffix\/doc' is not part of the query result set and cannot be used as a query boundary./);

    assert.throws(() => {
      query.orderBy(Firestore.FieldPath.documentId())
          .startAt(firestore.doc('coll/doc'));
    }, /'coll\/doc' is not part of the query result set and cannot be used as a query boundary./);

    assert.throws(() => {
      query.orderBy(Firestore.FieldPath.documentId())
          .startAt(firestore.doc('coll/doc/coll/doc/coll/doc'));
    }, /Only a direct child can be used as a query boundary. Found: 'coll\/doc\/coll\/doc\/coll\/doc'./);

    // Validate that we can't pass a reference to a collection.
    assert.throws(() => {
      query.orderBy(Firestore.FieldPath.documentId()).startAt('doc/coll');
    }, /Only a direct child can be used as a query boundary. Found: 'coll\/doc\/coll\/doc\/coll'./);
  });
github reptar / reptar / test / unit / renderer / renderer.spec.js View on Github external
pluginManager.pluginApi.event.file.beforeRender(beforeSpy);
      pluginManager.pluginApi.event.file.afterRender(afterSpy);

      try {
        await instance.renderFileWithPlugins(
          file,
          {},
          PluginEvents.file.beforeRender,
          PluginEvents.file.afterRender
        );
      } catch (e) {
        // noop
      }

      assert.equal(beforeSpy.callCount, 1);
      assert.ok(beforeSpy.calledWith(file));

      assert.equal(file.render.callCount, 1);
      assert.ok(file.render.calledWith({}));

      assert.equal(afterSpy.callCount, 1);
      assert.ok(afterSpy.calledWith(file, renderContent));
    });
  });
github Automattic / mongoose / test / harmony / document.test_.js View on Github external
error = e;
      }

      assert.ok(!error);
      assert.equal(called, true);
      called = false;

      // The validator function above should now fail
      shouldSucceed = false;
      try {
        yield m.validate();
      } catch (e) {
        error = e;
      }

      assert.ok(error);
      assert.ok(error instanceof ValidationError);

      done();
    })();
  });
github formio / formio.js / test / wizards / simple.js View on Github external
.then(() => {
          // Write data
          const wizardData = {
            a: 'a',
            b: 'b'
          };
          Harness.testSubmission(form, {
            data: wizardData
          });
          assert.deepStrictEqual(form._seenPages, [0]);
          assert.equal(form.page, 0);
        })
        .then(() => {
github Automattic / mongoose / test / harmony / document.test_.js View on Github external
var error;
      var schema = new Schema({
        description: {type: String, required: true}
      });

      var Breakfast = db.model('breakfast', schema, getCollectionName());

      var goodBreakfast = new Breakfast({description: 'eggs & bacon'});

      try {
        yield goodBreakfast.save();
      } catch (e) {
        error = e;
      }

      assert.ifError(error);
      var result;
      try {
        result = yield Breakfast.findOne().exec();
      } catch (e) {
        error = e;
      }
      assert.ifError(error);
      assert.equal(result.description, 'eggs & bacon');

      // Should cause a validation error because `description` is required
      var badBreakfast = new Breakfast({});
      try {
        yield badBreakfast.save();
      } catch (e) {
        error = e;
      }
github fliphub / fliphub / modules / fosho / index.js View on Github external
const log = require('fliplog')
const power = require('power-assert')
const extend = require('lodash.assigninwith')
const exposeHidden = require('expose-hidden')
const {assert, should, assert2, should2} = require('./chai')
const {lcFirst, ucFirst} = require('./helpers')
const powers = require('./power')
const izz = require('./izz')

// https://github.com/avajs/ava/blob/2a206311d708361b294a21aa4c5bd199936d0824/lib/enhance-assert.js
let Fosho = {}
let debugMode = false
let logMode = false

// compatibility
power.true = power

// log if good to go
function gtg(key, args) {
  if (!logMode) return
  log
    .color('green')
    .text(key + '? fosho')
    .echo()
}

// scope it so it doesn't need to be passed in every time
let scoped = null

// https://github.com/avajs/ava#assertions
const foshizzle = (arg, t) => {
  if (!t && scoped) t = scoped
github meganetaaan / vue-8-puzzle / test / unit / specs / board.spec.ts View on Github external
assert.equal(board.blocks[0], 3)
    assert.equal(board.blocks[3], 0)
    assert.equal(board.blankpos, 3)

    board.swapRight(3)
    assert.equal(board.blocks[3], 4)
    assert.equal(board.blocks[4], 0)
    assert.equal(board.blankpos, 4)

    board.swapAbove(4)
    assert.equal(board.blocks[4], 1)
    assert.equal(board.blocks[1], 0)
    assert.equal(board.blankpos, 1)

    board.swapLeft(1)
    assert.equal(board.blocks[1], 3)
    assert.equal(board.blocks[0], 0)
    assert.equal(board.blankpos, 0)

    board.swapAbove(3)
    assert.equal(board.blocks[3], 0)
    assert.equal(board.blocks[0], 4)
    assert.equal(board.blankpos, 3)
  })
  it('should throw error when no-empty block swapped', () => {
github vanwagonet / middle-router / test / server.js View on Github external
it('cannot listen without a window object', () => {
        let router = Router()
        assert.throws(() => router.start(), 'start should throw without a window')
        assert.equal(router.isListening, false, 'isListening should still be false')
      })
    })