diff --git a/.babelrc b/.babelrc index 719a27e..719d26f 100644 --- a/.babelrc +++ b/.babelrc @@ -3,6 +3,9 @@ "plugins": ["transform-es3-member-expression-literals", "transform-es3-property-literals", "transform-class-properties"], "env": { "development": { + }, + "test": { + "plugins": [ "istanbul" ] } } } diff --git a/.gitignore b/.gitignore index d9731ab..d06916c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ coverage .coveralls.yml npm-debug.* .idea +.nyc_output diff --git a/README.md b/README.md index 961d247..037fb1d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,10 @@ Create a `iframe` or `new window` to print a part of page what you want. Considering the [a-x-/react-easy-print](https://github.com/a-x-/react-easy-print) if you don`t like to use these two methods -> travis is coming soon +[![NPM version](https://img.shields.io/npm/v/rc-print.svg?style=flat)](https://npmjs.org/package/rc-print) +[![Build Status](https://www.travis-ci.org/hanzhangyu/rc-print.svg?branch=master)](https://www.travis-ci.org/hanzhangyu/rc-print) +[![Coverage Status](https://coveralls.io/repos/github/hanzhangyu/rc-print/badge.svg?branch=master)](https://coveralls.io/github/hanzhangyu/rc-print?branch=master) +[![NPM downloads](http://img.shields.io/npm/dm/rc-print.svg?style=flat)](https://npmjs.org/package/rc-print) [中文前看这里](./README_zh-CN.md) diff --git a/package.json b/package.json index 0f0fc94..4692463 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-print", - "version": "0.1.0", + "version": "0.1.1", "description": "Create a iframe or new window to print easily", "repository": { "type": "git", @@ -16,13 +16,13 @@ "license": "MIT", "main": "lib/index.js", "scripts": { - "test": "mocha test/.setup.js test/**/*-test.js", + "test": "cross-env NODE_ENV=test nyc mocha", "build": "rimraf lib && babel src --out-dir lib && npm run demo", "demo": "webpack", "dev": "webpack --watch", "prepublish": "npm run build", "start": "webpack-dev-server --watch", - "coveralls": "coveralls" + "coveralls": "nyc report --reporter=text-lcov | coveralls" }, "dependencies": { "babel-runtime": "^6.11.6" @@ -33,6 +33,7 @@ "babel-eslint": "^7.2.3", "babel-jest": "^20.0.3", "babel-loader": "^6.2.0", + "babel-plugin-istanbul": "^4.1.4", "babel-plugin-transform-class-properties": "*", "babel-plugin-transform-es3-member-expression-literals": "*", "babel-plugin-transform-es3-property-literals": "*", @@ -41,6 +42,7 @@ "babel-preset-react-hmre": "^1.1.1", "babel-preset-stage-0": "^6.24.1", "coveralls": "^2.13.1", + "cross-env": "^5.0.5", "css-loader": "~0.16.0", "enzyme": "^2.8.2", "eslint": "^3.19.0", @@ -55,6 +57,7 @@ "jsx-loader": "~0.13.2", "jsdom": "^9.6.0", "mocha": "^3.0.2", + "nyc": "^11.1.0", "prop-types": "^15.0.0", "react": "^15.5.0", "react-dom": "^15.5.0", @@ -71,5 +74,16 @@ "files": [ "lib", "src" - ] + ], + "nyc": { + "include": [ + "src/**/*.js" + ], + "require": [ + "babel-register", + "./test/.setup.js" + ], + "sourceMap": false, + "instrument": false + } } diff --git a/test/.setup.js b/test/.setup.js index 718f402..20483ce 100644 --- a/test/.setup.js +++ b/test/.setup.js @@ -1,20 +1,5 @@ -require('babel-register')(); +import { jsdom } from 'jsdom'; -var jsdom = require('jsdom').jsdom; - -var exposedProperties = ['window', 'navigator', 'document']; - -global.document = jsdom(''); +global.document = jsdom('
', { url: 'http://localhost' }); global.window = document.defaultView; -Object.keys(document.defaultView).forEach((property) => { - if (typeof global[property] === 'undefined') { - exposedProperties.push(property); - global[property] = document.defaultView[property]; - } -}); - -global.navigator = { - userAgent: 'node.js' -}; - -documentRef = document; +global.navigator = global.window.navigator; \ No newline at end of file