index.js 1.1 KB

1234567891011121314151617181920212223
  1. var dom = require("../../lib/jsdom/level1/core").dom.level1.core;
  2. exports.tests = {
  3. addmetatohead: function(test) {
  4. var window = require("../../lib/jsdom/browser/index").windowAugmentation(dom);
  5. var meta = window.document.createElement("meta");
  6. window.document.getElementsByTagName("head").item(0).appendChild(meta);
  7. var elements = window.document.getElementsByTagName("head").item(0).childNodes;
  8. test.strictEqual(elements.item(elements.length-1), meta, 'last element should be the new meta tag');
  9. test.ok(window.document.innerHTML.indexOf("<meta>") > -1, 'meta should have open tag');
  10. test.strictEqual(window.document.innerHTML.indexOf("</meta>"), -1, 'meta should not be stringified with a closing tag');
  11. test.done();
  12. },
  13. ensure_a_default_window_has_a_window_location_href: function(test) {
  14. var window = require("../../lib/jsdom/browser/index").windowAugmentation(dom);
  15. var rurl = /^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/,
  16. urlParts = rurl.exec(window.location.href);
  17. test.ok(urlParts.length > 1, 'url shouldnt be blank');
  18. test.done();
  19. }
  20. };