diff --git a/.travis.yml b/.travis.yml index 4741432..ebb6a95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: node_js node_js: - 'node' - '6' -script: npm run lint && npm test +script: npm test after_success: npm run coverage notifications: email: diff --git a/package.json b/package.json index 7437d61..2835610 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,7 @@ "node": ">=4" }, "scripts": { - "test": "nyc ava test", - "lint": "xo", + "test": "xo && nyc ava", "coverage": "nyc report --reporter=text-lcov | coveralls" }, "xo": { diff --git a/test/fixtures/expectedProperties.json b/test/fixtures/expectedProperties.json new file mode 100644 index 0000000..94d23e3 --- /dev/null +++ b/test/fixtures/expectedProperties.json @@ -0,0 +1,213 @@ +[ + "DOMException", + "NamedNodeMap", + "Attr", + "Node", + "Element", + "DocumentFragment", + "HTMLDocument", + "Document", + "XMLDocument", + "CharacterData", + "Text", + "CDATASection", + "ProcessingInstruction", + "Comment", + "DocumentType", + "DOMImplementation", + "Event", + "CustomEvent", + "MessageEvent", + "ErrorEvent", + "HashChangeEvent", + "FocusEvent", + "PopStateEvent", + "UIEvent", + "MouseEvent", + "KeyboardEvent", + "TouchEvent", + "ProgressEvent", + "EventTarget", + "Location", + "History", + "Blob", + "File", + "FileList", + "DOMParser", + "FormData", + "HTMLElement", + "HTMLAnchorElement", + "HTMLAppletElement", + "HTMLAreaElement", + "HTMLAudioElement", + "HTMLBaseElement", + "HTMLBodyElement", + "HTMLBRElement", + "HTMLButtonElement", + "HTMLCanvasElement", + "HTMLDataElement", + "HTMLDataListElement", + "HTMLDialogElement", + "HTMLDirectoryElement", + "HTMLDivElement", + "HTMLDListElement", + "HTMLEmbedElement", + "HTMLFieldSetElement", + "HTMLFontElement", + "HTMLFormElement", + "HTMLFrameElement", + "HTMLFrameSetElement", + "HTMLHeadingElement", + "HTMLHeadElement", + "HTMLHRElement", + "HTMLHtmlElement", + "HTMLIFrameElement", + "HTMLImageElement", + "HTMLInputElement", + "HTMLLabelElement", + "HTMLLegendElement", + "HTMLLIElement", + "HTMLLinkElement", + "HTMLMapElement", + "HTMLMediaElement", + "HTMLMenuElement", + "HTMLMetaElement", + "HTMLMeterElement", + "HTMLModElement", + "HTMLObjectElement", + "HTMLOListElement", + "HTMLOptGroupElement", + "HTMLOptionElement", + "HTMLOutputElement", + "HTMLParagraphElement", + "HTMLParamElement", + "HTMLPreElement", + "HTMLProgressElement", + "HTMLQuoteElement", + "HTMLScriptElement", + "HTMLSelectElement", + "HTMLSourceElement", + "HTMLSpanElement", + "HTMLStyleElement", + "HTMLTableCaptionElement", + "HTMLTableCellElement", + "HTMLTableColElement", + "HTMLTableDataCellElement", + "HTMLTableElement", + "HTMLTableHeaderCellElement", + "HTMLTimeElement", + "HTMLTitleElement", + "HTMLTableRowElement", + "HTMLTableSectionElement", + "HTMLTemplateElement", + "HTMLTextAreaElement", + "HTMLTrackElement", + "HTMLUListElement", + "HTMLUnknownElement", + "HTMLVideoElement", + "StyleSheet", + "MediaList", + "CSSStyleSheet", + "CSSRule", + "CSSStyleRule", + "CSSMediaRule", + "CSSImportRule", + "CSSStyleDeclaration", + "StyleSheetList", + "XPathException", + "XPathExpression", + "XPathResult", + "XPathEvaluator", + "HTMLCollection", + "NodeFilter", + "NodeIterator", + "NodeList", + "XMLHttpRequestEventTarget", + "XMLHttpRequestUpload", + "DOMTokenList", + "URL", + "Window", + "_core", + "_globalProxy", + "__timers", + "_top", + "_parent", + "_frameElement", + "_document", + "_sessionHistory", + "_currentSessionHistoryEntryIndex", + "_length", + "_virtualConsole", + "length", + "window", + "frameElement", + "frames", + "self", + "parent", + "top", + "document", + "location", + "history", + "navigator", + "addEventListener", + "removeEventListener", + "dispatchEvent", + "setTimeout", + "setInterval", + "clearInterval", + "clearTimeout", + "__stopAllTimers", + "Image", + "Audio", + "postMessage", + "atob", + "btoa", + "FileReader", + "XMLHttpRequest", + "ArrayBuffer", + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Uint16Array", + "Int32Array", + "Uint32Array", + "Float32Array", + "Float64Array", + "stop", + "close", + "getComputedStyle", + "console", + "name", + "innerWidth", + "innerHeight", + "outerWidth", + "outerHeight", + "pageXOffset", + "pageYOffset", + "screenX", + "screenY", + "screenLeft", + "screenTop", + "scrollX", + "scrollY", + "scrollTop", + "scrollLeft", + "screen", + "alert", + "blur", + "confirm", + "createPopup", + "focus", + "moveBy", + "moveTo", + "open", + "print", + "prompt", + "resizeBy", + "resizeTo", + "scroll", + "scrollBy", + "scrollTo", + "toString" +] diff --git a/test/unit.js b/test/unit.js index 72a3f54..fd1511a 100644 --- a/test/unit.js +++ b/test/unit.js @@ -1,9 +1,23 @@ /* eslint new-cap: ["error", { "capIsNew": false }] */ import test from 'ava'; import Window from '../'; +import expectedProperties from './fixtures/expectedProperties'; test('jsdom config is passed through', t => { const userAgent = 'Custom user agent'; const window = new Window({ userAgent }); t.is(window.navigator.userAgent, userAgent); }); + +test('properties haven\'t changed', t => { + // These options need to be enabled so we can iterate on all properties + const window = new Window({ + features: { + FetchExternalResources: false, + ProcessExternalResources: false + } + }); + const properties = Object.getOwnPropertyNames(window); + + t.deepEqual(expectedProperties.sort(), properties.sort()); +});