How to use the mocha-sugar-free.specify function in mocha-sugar-free

To help you get started, we’ve selected a few mocha-sugar-free 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 jsdom / jsdom / test / sizzle / index.js View on Github external
t("ID Selector on Form with an input that has a name of 'id'", "#lengthtest", ["lengthtest"]);

      t("ID selector with non-existant ancestor", "#asdfasdf #foobar", []); // bug #986

      deepEqual(Sizzle("div#form", document.body), [], "ID selector within the context of another element");

      t("Underscore ID", "#types_all", ["types_all"]);
      t("Dash ID", "#fx-queue", ["fx-queue"]);

      t("ID with weird characters in it", "#name\\+value", ["name+value"]);
    }
  }), {
    async: true
  });

  specify('class', test(function (window) {
    with (window) {

      t("Class Selector", ".blog", ["mark", "simon"]);
      t("Class Selector", ".GROUPS", ["groups"]);
      t("Class Selector", ".blog.link", ["simon"]);
      t("Class Selector w/ Element", "a.blog", ["mark", "simon"]);
      t("Parent Class Selector", "p .blog", ["mark", "simon"]);

      t("Class selector using UTF8", ".台北Táiběi", ["utf8class1"]);
      //t( "Class selector using UTF8", ".台北", ["utf8class1","utf8class2"] );
      t("Class selector using UTF8", ".台北Táiběi.台北", ["utf8class1"]);
      t("Class selector using UTF8", ".台北Táiběi, .台北", ["utf8class1", "utf8class2"]);
      t("Descendant class selector using UTF8", "div .台北Táiběi", ["utf8class1"]);
      t("Child class selector using UTF8", "form > .台北Táiběi", ["utf8class1"]);

      t("Escaped Class", ".foo\\:bar", ["foo:bar"]);
github jsdom / jsdom / test / sizzle / index.js View on Github external
broken("Only-child", ":only-child(n)");

      // Make sure attribute value quoting works correctly. See: #6093
      var attrbad = jQuery('<input id="attrbad1" name="foo.baz" value="2" type="hidden"><input id="attrbad2" name="foo[baz]" value="2" type="hidden">').appendTo("body");

      broken("Attribute not escaped", "input[name=foo.baz]", []);
      // Shouldn't be matching those inner brackets
      broken("Attribute not escaped", "input[name=foo[baz]]", []);

      attrbad.remove();
    }
  }), {
    async: true
  });

  specify('id', test(function (window) {
    with (window) {

      t("ID Selector", "#body", ["body"]);
      t("ID Selector w/ Element", "body#body", ["body"]);
      t("ID Selector w/ Element", "ul#first", []);
      t("ID selector with existing ID descendant", "#firstp #simon1", ["simon1"]);
      t("ID selector with non-existant descendant", "#firstp #foobar", []);
      t("ID selector using UTF8", "#台北Táiběi", ["台北Táiběi"]);
      t("Multiple ID selectors using UTF8", "#台北Táiběi, #台北", ["台北Táiběi", "台北"]);
      t("Descendant ID selector using UTF8", "div #台北", ["台北"]);
      t("Child ID selector using UTF8", "form &gt; #台北", ["台北"]);

      t("Escaped ID", "#foo\\:bar", ["foo:bar"]);
      t("Escaped ID with descendent", "#foo\\:bar span:not(:input)", ["foo_descendent"]);
      t("Escaped ID", "#test\\.foo\\[5\\]bar", ["test.foo[5]bar"]);
      t("Descendant escaped ID", "div #foo\\:bar", ["foo:bar"]);
github jsdom / jsdom / test / to-port-to-wpts / class-list.js View on Github external
assert.equal(el.classList[0], "foo");

    // add one token twice
    el.classList.add("foo", "foo");
    assert.equal(el.className, "foo");
    assert.equal(el.classList[0], "foo");

    // add two distinct tokens
    el.className = "";
    el.classList.add("foo", "bar");
    assert.equal(el.className, "foo bar");
    assert.equal(el.classList[0], "foo");
    assert.equal(el.classList[1], "bar");
  });

  specify(".add() throws if a token is empty", () => {
    function block() {
      el.classList.add("foo", "");
    }

    assert.throwsDomException(block, el.ownerDocument, "SyntaxError");
  });

  specify(".add() throws if a token contains whitespace", () => {
    function block() {
      el.classList.add("  foo", "bar");
    }

    assert.throwsDomException(block, el.ownerDocument, "InvalidCharacterError");
  });

  specify(".remove(tokens...) removes provided tokens", () => {
github jsdom / jsdom / test / to-port-to-wpts / inline-event-handlers.js View on Github external
error: errorObj
      });
      doc.defaultView.dispatchEvent(e);
    },
    {
      async: true
    }
  );

  const proxied = [
    "onblur", "onerror", "onfocus", "onload", "onresize", "onscroll", "onafterprint",
    "onbeforeprint", "onbeforeunload", "onhashchange", "onlanguagechange", "onmessage", "onoffline", "ononline",
    "onpagehide", "onpageshow", "onpopstate", "onstorage", "onunload"
  ];

  specify(
    "proxied body/window event handlers: setting on body as properties reflects on window",
    () => {
      const doc = (new JSDOM()).window.document;

      for (const name of proxied) {
        function handler() {
          // doesn't matter for this test
        }

        doc.body[name] = handler;
        assert.equal(doc.body[name], handler, `${name} should be set on the body correctly`);
        assert.equal(doc.defaultView[name], handler, `${name} should be set on the window correctly`);

        doc.body[name] = null;
        assert.equal(doc.body[name], null, `${name} should be unset on the body correctly`);
        assert.equal(doc.defaultView[name], null, `${name} should be unset on the window correctly`);
github jsdom / jsdom / test / sizzle / index.js View on Github external
.appendTo("#qunit-fixture").children();

      equal(a.length, 3, "Make sure the right number of elements were inserted.");
      equal(a[1].id, "tName2ID", "Make sure the right number of elements were inserted.");

      equal(Sizzle("[name=tName1]")[0], a[0], "Find elements that have similar IDs");
      equal(Sizzle("[name=tName2]")[0], a[1], "Find elements that have similar IDs");
      t("Find elements that have similar IDs", "#tName2ID", ["tName2ID"]);

      a.parent().remove();
    }
  }), {
    async: true
  });

  specify('multiple', test(function (window) {
    with (window) {
      t("Comma Support", "h2, #qunit-fixture p", ["qunit-banner", "qunit-userAgent", "firstp", "ap", "sndp", "en", "sap", "first"]);
      t("Comma Support", "h2 , #qunit-fixture p", ["qunit-banner", "qunit-userAgent", "firstp", "ap", "sndp", "en", "sap", "first"]);
      t("Comma Support", "h2 , #qunit-fixture p", ["qunit-banner", "qunit-userAgent", "firstp", "ap", "sndp", "en", "sap", "first"]);
      t("Comma Support", "h2,#qunit-fixture p", ["qunit-banner", "qunit-userAgent", "firstp", "ap", "sndp", "en", "sap", "first"]);
      t("Comma Support", "h2,#qunit-fixture p ", ["qunit-banner", "qunit-userAgent", "firstp", "ap", "sndp", "en", "sap", "first"]);
      t("Comma Support", "h2\t,\r#qunit-fixture p\n", ["qunit-banner", "qunit-userAgent", "firstp", "ap", "sndp", "en", "sap", "first"]);
    }
  }), {
    async: true
  });

  specify('child and adjacent', test(function (window) {
    with (window) {
      t("Child", "p > a", ["simon1", "google", "groups", "mark", "yahoo", "simon"]);
      t("Child", "p> a", ["simon1", "google", "groups", "mark", "yahoo", "simon"]);
github jsdom / jsdom / test / sizzle / index.js View on Github external
describe("sizzle", { skipIfBrowser: true }, () =&gt; {
  before(() =&gt; {
    testFile = fs.readFileSync(__dirname + '/files/index.html', 'utf-8');
  });

  specify('element', test(function (window) {
    with (window) {
      (function () {

        equal(Sizzle("").length, 0, "Empty selector returns an empty array");
        equal(Sizzle(" ").length, 0, "Empty selector returns an empty array");
        equal(Sizzle("\t").length, 0, "Empty selector returns an empty array");
        var form = document.getElementById("form");
        ok(!Sizzle.matchesSelector(form, ""), "Empty string passed to matchesSelector does not match");

        ok(Sizzle("*").length &gt;= 30, "Select all");
        var all = Sizzle("*"), good = true;
        for (var i = 0; i &lt; all.length; i++) {
          if (all[i].nodeType == 8) {
            good = false;
          }
        }
github jsdom / jsdom / test / sizzle / index.js View on Github external
t("Form element :text", "#form :text", ["text1", "text2", "hidden2", "name", "impliedText", "capitalText"]);
      t("Form element :radio:checked", "#form :radio:checked", ["radio2"]);
      t("Form element :checkbox:checked", "#form :checkbox:checked", ["check1"]);
      t("Form element :radio:checked, :checkbox:checked", "#form :radio:checked, #form :checkbox:checked", ["radio2", "check1"]);

      t("Selected Option Element", "#form option:selected", ["option1a", "option2d", "option3b", "option3c", "option4b", "option4c", "option4d", "option5a"]);
      t("Selected Option Element are also :checked", "#form option:checked", ["option1a", "option2d", "option3b", "option3c", "option4b", "option4c", "option4d", "option5a"]);
      t("Hidden inputs should be treated as enabled. See QSA test.", "#hidden1:enabled", ["hidden1"]);

      extraTexts.remove();
    }
  }), {
    async: true
  });

  specify('caching', test(function (window) {
    with (window) {
      Sizzle(":not(code)", document.getElementById("ap"));
      deepEqual(Sizzle(":not(code)", document.getElementById("foo")), q("sndp", "en", "yahoo", "sap", "anchor2", "simon"), "Reusing selector with new context");
    }
  }), {
    async: true
  });

  specify('query-memoization', test(function (window) {
    with (window) {
      equal(Sizzle('#foo').length, 1, '#foo query should return 1 element');
      var el = document.getElementById('foo');
      el.parentNode.removeChild(el);
      equal(Sizzle('#foo').length, 0, '#foo query should return 0 elements after removal');

      var oldAttrLen = Sizzle('p[lang=en]').length;
github jsdom / jsdom / test / jsdom / encoding.js View on Github external
assert.equal(window.document.characterSet, "UTF-16BE", "document.characterSet");
        assert.equal(window.document.body.textContent.trim(), "©");
        assert.equal(window.testutf8, "©");
        assert.equal(window.testiso88591, "©");

        t.done();
      },
      features: {
        FetchExternalResources: ["script"],
        ProcessExternalResources: ["script"]
      }
    });
  });

  specify("UTF-16LE", { async: true }, t => {
    jsdom.env({
      url: testHost + "/utf16le",
      done(err, window) {
        assert.ifError(err);

        assert.equal(window.document.characterSet, "UTF-16LE", "document.characterSet");
        assert.equal(window.document.body.textContent.trim(), "©");
        assert.equal(window.testutf8, "©");
        assert.equal(window.testiso88591, "©");

        t.done();
      },
      features: {
        FetchExternalResources: ["script"],
        ProcessExternalResources: ["script"]
      }
github jsdom / jsdom / test / jsdom / encoding.js View on Github external
assert.equal(window.document.characterSet, "UTF-8", "document.characterSet");
        assert.equal(window.document.body.textContent.trim(), "©");
        assert.equal(window.testutf8, "©");
        assert.equal(window.testiso88591, "©");

        t.done();
      },
      features: {
        FetchExternalResources: ["script"],
        ProcessExternalResources: ["script"]
      }
    });
  });

  specify("ISO-8859-1", { async: true }, t => {
    jsdom.env({
      url: testHost + "/iso88591",
      done(err, window) {
        assert.ifError(err);

        assert.equal(window.document.characterSet, "windows-1252", "document.characterSet");
        assert.equal(window.document.body.textContent.trim(), "©");
        assert.equal(window.testutf8, "©");
        assert.equal(window.testiso88591, "©");

        t.done();
      },
      features: {
        FetchExternalResources: ["script"],
        ProcessExternalResources: ["script"]
      }
github jsdom / jsdom / test / jsdom / encoding.js View on Github external
assert.equal(window.document.characterSet, "windows-1252", "document.characterSet");
        assert.equal(window.document.body.textContent.trim(), "©");
        assert.equal(window.testutf8, "©");
        assert.equal(window.testiso88591, "©");

        t.done();
      },
      features: {
        FetchExternalResources: ["script"],
        ProcessExternalResources: ["script"]
      }
    });
  });

  specify("UTF-16BE", { async: true }, t => {
    jsdom.env({
      url: testHost + "/utf16be",
      done(err, window) {
        assert.ifError(err);

        assert.equal(window.document.characterSet, "UTF-16BE", "document.characterSet");
        assert.equal(window.document.body.textContent.trim(), "©");
        assert.equal(window.testutf8, "©");
        assert.equal(window.testiso88591, "©");

        t.done();
      },
      features: {
        FetchExternalResources: ["script"],
        ProcessExternalResources: ["script"]
      }

mocha-sugar-free

Write mocha test cases without using globals or `this`. Browserify compatible. Mocha without the sugar.

MIT
Latest version published 6 years ago

Package Health Score

42 / 100
Full package analysis

Popular mocha-sugar-free functions