Browse Source

Extract window function from browser-env

pull/2/head
Luke Childs 8 years ago
commit
72afe92e9e
  1. 3
      .gitignore
  2. 10
      .travis.yml
  3. 21
      LICENSE
  4. 19
      README.md
  5. 52
      package.json
  6. 8
      src/index.js
  7. 6
      test/types.js

3
.gitignore

@ -0,0 +1,3 @@
node_modules
.nyc_output
npm-debug.log

10
.travis.yml

@ -0,0 +1,10 @@
language: node_js
node_js:
- '6'
- '5'
- '4'
script: npm run lint && npm test
after_success: npm run coverage
notifications:
email:
on_success: never

21
LICENSE

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 Luke Childs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

19
README.md

@ -0,0 +1,19 @@
# window [![Build Status](https://travis-ci.org/lukechilds/window.svg?branch=master)](https://travis-ci.org/lukechilds/window) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/window/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/window?branch=master) [![npm](https://img.shields.io/npm/dm/window.svg)](https://www.npmjs.com/package/window)
> Exports a [`jsdom`](https://github.com/tmpvar/jsdom) window object.
## Install
```shell
npm install --save window
```
Or if you're just using for testing you'll probably want:
```shell
npm install --save-dev window
```
## License
MIT © Luke Childs

52
package.json

@ -0,0 +1,52 @@
{
"name": "window",
"version": "1.0.0",
"description": "Exports a jsdom window object.",
"main": "src/index.js",
"engines": {
"node": ">=4"
},
"scripts": {
"test": "nyc ava test",
"lint": "eslint src",
"coverage": "nyc report --reporter=text-lcov | coveralls"
},
"eslintConfig": {
"extends": "lukechilds",
"rules": {
"prefer-rest-params": "off"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/lukechilds/window.git"
},
"keywords": [
"export",
"jsdom",
"window",
"object",
"simulate",
"node",
"browser",
"environment",
"env"
],
"author": "Luke Childs <lukechilds123@gmail.com> (http://lukechilds.co.uk)",
"license": "MIT",
"bugs": {
"url": "https://github.com/lukechilds/window/issues"
},
"homepage": "https://github.com/lukechilds/window#readme",
"dependencies": {
"clone": "2.1.0",
"jsdom": "9.11.0"
},
"devDependencies": {
"ava": "^0.18.0",
"coveralls": "^2.11.13",
"eslint": "^3.5.0",
"eslint-config-lukechilds": "^1.9.0",
"nyc": "^10.0.0"
}
}

8
src/index.js

@ -0,0 +1,8 @@
const jsdom = require('jsdom');
const clone = require('clone');
// Function to return a window object.
// Accepts a jsdom config object.
// Config object must be cloned before passing through otherwise jsdom will add
// lots of properties to the original reference.
module.exports = window = (jsdomConfig = {}) => jsdom.jsdom('', clone(jsdomConfig)).defaultView;

6
test/types.js

@ -0,0 +1,6 @@
import test from 'ava';
import window from '../';
test('mergeImages is a function', t => {
t.is(typeof window, 'function');
});
Loading…
Cancel
Save