How to use the qunit.ok function in qunit

To help you get started, we’ve selected a few qunit 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 haberman / dblbook / tests / tests.js View on Github external
qunit.ok(account.db === db, "created account has correct db");
  qunit.ok(account.parent === db.getRealRoot(), "created account top as parent");
  qunit.ok(account.children.size == 0, "created account has no children");

  var account1_guid = account.data.guid;

  var sub = db.createAccount(act({"name":"Sub", "parent_guid":account1_guid}));
  qunit.ok(sub, "create account 2");

  qunit.ok(account.children.size == 1, "now Test account has sub-account");

  // Move account to the top level.
  sub.update(act({"name":"Sub"}));

  qunit.ok(db.getRealRoot().children.size == 2, "top-level now has two accounts");
  qunit.ok(account.children.size == 0, "Test no longer has sub-account");

  throws(function() {
    db.createAccount(act({"name":"Test"}))
  }, "can't create account with duplicate name");

  qunit.ok(db.createAccount(act({ "guid": "EXPLICIT GUID", "name": "YO"})),
     "can create an account with an explicit GUID set.");
});
github videojs / videojs-contrib-media-sources / test / videojs-contrib-media-sources.js View on Github external
window.MediaSource.isTypeSupported = function(mime) {
    return true;
  };

  QUnit.ok(
    new videojs.MediaSource({ mode: 'flash' }) instanceof FlashMediaSource,
    'forced flash'
  );

  QUnit.ok(
      new videojs.MediaSource({ mode: 'html5' }) instanceof HtmlMediaSource,
    'forced html5'
  );

  // 'auto' should use native mediasources when they're available
  QUnit.ok(
    new videojs.MediaSource() instanceof HtmlMediaSource,
    'used html5'
  );

  window.MediaSource.isTypeSupported = function(mime) {
    return false;
  };

  // 'auto' should use flash when native mediasources are not available
  QUnit.ok(
    new videojs.MediaSource() instanceof FlashMediaSource,
      'used flash'
  );
});
github thejohnfreeman / jfdoc / test / cases / param.js View on Github external
q.test("tags", function () {
    q.expect(2);
    q.ok(Array.isArray(this.params), "parameters exist");
    q.strictEqual(this.params.length, 5, "number of parameters");
  });
github thejohnfreeman / jfdoc / test / cases / class.js View on Github external
q.test("kind", function () {
    q.expect(4);
    q.ok(this.Foo1.classDoclet, "Foo1 has a class doclet");
    q.strictEqual(this.Foo1.classDoclet.kind, "class", "Foo1 is a class");
    q.ok(this.Foo2.classDoclet, "Foo2 has a class doclet");
    q.strictEqual(this.Foo2.classDoclet.kind, "class", "Foo2 is a class");
  });
github thejohnfreeman / jfdoc / test / cases / namespace.js View on Github external
q.test("scope", function () {
    q.expect(6);
    q.ok(this.decls, "global decls");
    q.strictEqual(Object.keys(this.decls).length, 2, "number of namespaces");
    q.ok(this.Foo1, "Foo1 exists");
    q.ok(this.Foo1 instanceof jfdoc.Scope, "Foo1 is a scope");
    q.ok(this.Foo2, "Foo2 exists");
    q.ok(this.Foo2 instanceof jfdoc.Scope, "Foo2 is a scope");
  });
github thejohnfreeman / jfdoc / test / cases / namespace.js View on Github external
q.test("scope", function () {
    q.expect(6);
    q.ok(this.decls, "global decls");
    q.strictEqual(Object.keys(this.decls).length, 2, "number of namespaces");
    q.ok(this.Foo1, "Foo1 exists");
    q.ok(this.Foo1 instanceof jfdoc.Scope, "Foo1 is a scope");
    q.ok(this.Foo2, "Foo2 exists");
    q.ok(this.Foo2 instanceof jfdoc.Scope, "Foo2 is a scope");
  });
github thejohnfreeman / jfdoc / test / cases / class.js View on Github external
q.test("scope", function () {
    q.expect(5);
    q.strictEqual(Object.keys(this.decls).length, 2, "number of classes");
    q.ok(this.Foo1, "Foo1 exists");
    q.ok(this.Foo1 instanceof jfdoc.Scope, "Foo1 is a scope");
    q.ok(this.Foo2, "Foo2 exists");
    q.ok(this.Foo2 instanceof jfdoc.Scope, "Foo2 is a scope");
  });
github haberman / dblbook / tests / tests.js View on Github external
var notified3 = 0;
  var testAccount = db.getRealRoot().children.get("Test");
  qunit.ok(testAccount);
  var testAccountGuid = testAccount.data.guid;
  testAccount.subscribe(this, function() {
    notified3 += 1;
  });

  db.createAccount(act({"name":"Sub", "parent_guid":testAccountGuid}));
  var sub = testAccount.children.get("Sub");
  qunit.ok(sub);
  equal(notified3, 1);
  equal(notified2, 1);
  equal(notified, 2);

  qunit.ok(db.createAccount(act({"name":"Test5"})), "create account 5");
  equal(notified3, 1);
  equal(notified2, 2);
  equal(notified, 2);

  var notified4 = 0;
  var subscriber2 = {};
  db.getRealRoot().subscribe(subscriber2, function() {
    notified4 += 1;
  });

  qunit.ok(db.createAccount(act({"name":"Test6"})), "create account 6");
  equal(notified4, 1);
  equal(notified3, 1);
  equal(notified2, 3);
  equal(notified, 2);
github haberman / dblbook / tests / tests.js View on Github external
qunit.ok(db.createAccount(act({"name":"Test6"})), "create account 6");
  equal(notified4, 1);
  equal(notified3, 1);
  equal(notified2, 3);
  equal(notified, 2);

  sub.update(act({"name": "WasSub"}))
  equal(notified4, 2);
  equal(notified3, 2);
  equal(notified2, 4);
  equal(notified, 2);

  db.getRealRoot().unsubscribe(this);
  testAccount.unsubscribe(this);
  qunit.ok(db.createAccount(act({"name":"Test7"})), "create account 7");
  equal(notified4, 3);
  equal(notified3, 2);
  equal(notified2, 4);
  equal(notified, 2);
});
github haberman / dblbook / tests / tests.js View on Github external
model.DB.open().then(function(db) {
      qunit.ok(false);
      done();
    }, function() {
      err = true;