Browse Source

Use Jest instead jasmine-node for testing

master
Dmitry Karpunin 5 years ago
parent
commit
8f5ea1de52
  1. 2
      .gitignore
  2. 6
      README.md
  3. 8
      README_CN.md
  4. 4791
      package-lock.json
  5. 17
      package.json
  6. 22
      spec/px-to-viewport.spec.js

2
.gitignore

@ -4,4 +4,4 @@ logs
npm-debug.log*
node_modules
.idea
postcss-px-to-em-master
yarn.lock

6
README.md

@ -161,7 +161,7 @@ add to your `postcss.config.js`
```js
module.exports = {
plugins: {
...
// ...
'postcss-px-to-viewport': {
// options
}
@ -171,9 +171,9 @@ module.exports = {
## Running the tests
In order to run tests, you need to install `jasmine-node` globally:
In order to run tests, you need to install dev-packages:
```
$ npm install jasmine-node -g
$ npm install
```
Then run the tests via npm script:
```

8
README_CN.md

@ -1,7 +1,7 @@
# postcss-px-to-viewport
[![NPM version](https://badge.fury.io/js/postcss-px-to-viewport.svg)](http://badge.fury.io/js/postcss-px-to-viewport)
[English](README.md) | 中文
[English](README.md) | 中文
将px单位转换为视口单位的 (vw, vh, vmin, vmax) 的 [PostCSS](https://github.com/postcss/postcss) 插件.
@ -161,7 +161,7 @@ gulp.task('css', function () {
```js
module.exports = {
plugins: {
...
// ...
'postcss-px-to-viewport': {
// options
}
@ -171,9 +171,9 @@ module.exports = {
## 测试
为了跑测试案例, 你需要全局安装 `jasmine-node` :
为了跑测试案例,您需要安装开发套件:
```
$ npm install jasmine-node -g
$ npm install
```
然后输入下面的命令:
```

4791
package-lock.json
File diff suppressed because it is too large
View File

17
package.json

@ -11,12 +11,6 @@
"bugs": "https://github.com/evrone/postcss-px-to-viewport/issues",
"homepage": "https://github.com/evrone/postcss-px-to-viewport",
"main": "index.js",
"scripts": {
"test": "jasmine-node spec"
},
"devDependencies": {
"jasmine-node": "~1.11.0"
},
"keywords": [
"css",
"units",
@ -30,8 +24,17 @@
"postcss",
"postcss-plugin"
],
"scripts": {
"test": "jest spec/*.spec.js"
},
"dependencies": {
"object-assign": ">=4.0.1",
"object-assign": ">=4.0.1"
},
"devDependencies": {
"jest": "^25.4.0",
"postcss": ">=5.0.2"
},
"peerDependencies": {
"postcss": ">=5.0.2"
}
}

22
spec/px-to-viewport.spec.js

@ -1,11 +1,9 @@
// Jasmine unit tests
// To run tests, run these commands from the project root:
// 1. `npm install -g jasmine-node`
// 2. `jasmine-node spec`
// 1. `npm install`
// 2. `npm test`
/* global describe, it, expect */
'use strict';
var postcss = require('postcss');
var pxToViewport = require('..');
var basicCSS = '.rule { font-size: 15px }';
@ -51,11 +49,11 @@ describe('px-to-viewport', function() {
expect(processed).toBe(expected);
});
it('should not replace units inside mediaQueries by default', function() {
var expected = '@media (min-width: 500px) { .rule { font-size: 16px } }';
var processed = postcss(pxToViewport()).process('@media (min-width: 500px) { .rule { font-size: 16px } }').css;
expect(processed).toBe(expected);
})
});
@ -211,7 +209,7 @@ describe('mediaQuery', function () {
expect(processed).toBe(expected);
});
it('should not replace px inside media queries if not opts.mediaQuery', function() {
var options = {
mediaQuery: false
@ -221,7 +219,7 @@ describe('mediaQuery', function () {
expect(processed).toBe(expected);
});
it('should replace px inside media queries if it has params orientation landscape and landscape option', function() {
var options = {
mediaQuery: true,
@ -563,7 +561,7 @@ describe('landscape', function() {
expect(processed).toBe(expected);
});
it('should not add landscape atRule in mediaQueries', function() {
var css = '@media (min-width: 500px) { .rule { font-size: 16px } }';
var expected = '@media (min-width: 500px) { .rule { font-size: 5vw } }';
@ -575,7 +573,7 @@ describe('landscape', function() {
expect(processed).toBe(expected);
});
it('should not replace values inside landscape atRule', function() {
var options = {
replace: false,
@ -586,7 +584,7 @@ describe('landscape', function() {
expect(processed).toBe(expected);
});
it('should add landscape atRule with specified landscapeWidth', function() {
var options = {
landscape: true,
@ -597,7 +595,7 @@ describe('landscape', function() {
expect(processed).toBe(expected);
});
it('should not add landscape atRule if it has no nodes', function() {
var css = '.rule { font-size: 15vw }';
var options = {

Loading…
Cancel
Save