Skip to content
This repository was archived by the owner on Feb 9, 2023. It is now read-only.

Replace mocha, nyc and chai with jest #40

Merged
merged 1 commit into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,390 changes: 6,388 additions & 3,002 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 12 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@
"*.js"
],
"scripts": {
"debug": "npm run mocha -- --inspect-brk",
"format": "prettier . --write",
"lint": "npm-run-all --parallel lint:*",
"lint:formatting": "prettier . --check",
"lint:js": "eslint . --cache --max-warnings=0",
"lint:md": "remark . --quiet --frail",
"mocha": "mocha --no-timeouts",
"release": "np",
"test": "nyc npm run mocha",
"watch": "mocha --watch"
"test": "jest",
"watch": "jest --watch"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -69,18 +67,16 @@
"@stylelint/remark-preset"
]
},
"nyc": {
"all": true,
"cache": true,
"check-coverage": true,
"exclude": [
"coverage/**",
"test{,s}/**",
"**/.{prettier,eslint,mocha}rc.{js,cjs}"
"jest": {
"collectCoverage": true,
"collectCoverageFrom": [
"**/*.js",
"!coverage/**",
"!test{,s}/**",
"!**/.{prettier,eslint,mocha}rc.{js,cjs}"
],
"reporter": [
"lcov",
"text"
"testMatch": [
"**/test/*.js"
]
},
"dependencies": {
Expand All @@ -90,18 +86,16 @@
"@stylelint/prettier-config": "^2.0.0",
"@stylelint/remark-preset": "^1.0.0",
"autoprefixer": "^9.7.6",
"chai": "^4.2.0",
"codecov": "^3.6.5",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-config-stylelint": "^12.0.0",
"husky": "^4.2.5",
"jest": "^26.1.0",
"json5": "^2.1.3",
"lint-staged": "^10.1.3",
"mocha": "^7.1.1",
"np": "^6.3.2",
"npm-run-all": "^4.1.5",
"nyc": "^15.0.1",
"postcss": ">=7.0.27",
"postcss-parser-tests": "^6.5.0",
"postcss-safe-parser": "^4.0.2",
Expand Down
9 changes: 4 additions & 5 deletions test/camel-case.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const camelCase = require('../camel-case');
const expect = require('chai').expect;
const unCamelCase = require('../un-camel-case');

const data = {
Expand Down Expand Up @@ -42,13 +41,13 @@ const symbols = Array.from('@*:;\n,(){} ');
describe('camelCase', () => {
testCases.forEach((testCase) => {
it(`${testCase.unCamel} => ${testCase.camel}`, () => {
expect(camelCase(testCase.unCamel)).to.equal(testCase.camel);
expect(camelCase(testCase.unCamel)).toBe(testCase.camel);
});
});
describe('symbols', () => {
symbols.forEach((symbol) => {
it(JSON.stringify(symbol), () => {
expect(camelCase(testCases.map((testCase) => testCase.unCamel).join(symbol))).to.equal(
expect(camelCase(testCases.map((testCase) => testCase.unCamel).join(symbol))).toBe(
testCases.map((testCase) => testCase.camel).join(symbol),
);
});
Expand All @@ -59,13 +58,13 @@ describe('camelCase', () => {
describe('unCamelCase', () => {
testCases.forEach((testCase) => {
it(`${testCase.camel} => ${testCase.unCamel}`, () => {
expect(unCamelCase(testCase.camel)).to.equal(testCase.unCamel);
expect(unCamelCase(testCase.camel)).toBe(testCase.unCamel);
});
});
describe('symbols', () => {
symbols.forEach((symbol) => {
it(JSON.stringify(symbol), () => {
expect(unCamelCase(testCases.map((testCase) => testCase.camel).join(symbol))).to.equal(
expect(unCamelCase(testCases.map((testCase) => testCase.camel).join(symbol))).toBe(
testCases.map((testCase) => testCase.unCamel).join(symbol),
);
});
Expand Down
25 changes: 12 additions & 13 deletions test/css-in-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const autoprefixer = require('autoprefixer');
const cases = require('postcss-parser-tests');
const expect = require('chai').expect;
const JSON5 = require('json5');
const objectStringify = require('../object-stringify');
const postcss = require('postcss');
Expand All @@ -14,7 +13,7 @@ describe('CSS in JS', () => {
from: '/fixtures/basic.js',
});

expect(document.nodes).to.lengthOf(0);
expect(document.nodes).toHaveLength(0);
});
it('glamorous', () => {
const code = `
Expand Down Expand Up @@ -47,7 +46,7 @@ describe('CSS in JS', () => {
from: '/fixtures/glamorous-prefix.jsx',
})
.then((result) => {
expect(result.content).equal(out);
expect(result.content).toBe(out);
});
});

Expand All @@ -66,9 +65,9 @@ describe('CSS in JS', () => {
).first.first.first;

decl.raws.prop.raw = 'WebkitBorderRadius';
expect(decl.prop).to.equal('-webkit-border-radius');
expect(decl.prop).toBe('-webkit-border-radius');
decl.raws.value.raw = '15px';
expect(decl.value).to.equal('15px');
expect(decl.value).toBe('15px');
});
it('atRule.raws.params.raw', () => {
const atRule = syntax.parse(
Expand All @@ -86,7 +85,7 @@ describe('CSS in JS', () => {
).first.first.first;

atRule.raws.params.raw = "(minWidth: ' + minWidth + ')";
expect(atRule.params).to.equal("(min-width: ' + minWidth + ')");
expect(atRule.params).toBe("(min-width: ' + minWidth + ')");
});
});

Expand All @@ -100,10 +99,10 @@ describe('CSS in JS', () => {
from: '/fixtures/glamorous-empty-object-literals.jsx',
});

expect(root.toString()).to.equal(code);
expect(root.toString()).toBe(code);

root.first.first.raws.after = '';
expect(root.toString()).to.equal(`
expect(root.toString()).toBe(`
import glm from 'glamorous';
const Component1 = glm.a({});
`);
Expand All @@ -121,9 +120,9 @@ describe('CSS in JS', () => {
from: '/fixtures/glamorous-float.jsx',
});

expect(root.first.first.first).to.haveOwnProperty('prop', 'float');
expect(root.first.first.first).toHaveProperty('prop', 'float');

expect(root.toString()).to.equal(`
expect(root.toString()).toBe(`
import glm from 'glamorous';
const Component1 = glm.a({
cssFloat: "left",
Expand All @@ -140,7 +139,7 @@ describe('CSS in JS', () => {
}),
];

expect(root.toString()).to.equal(`
expect(root.toString()).toBe(`
import glm from 'glamorous';
const Component1 = glm.a({
cssFloat: "right",
Expand All @@ -159,7 +158,7 @@ describe('CSS in JS', () => {
const jsSource = root.toString(objectStringify).trim();
const jsonSource = '{\n' + jsSource.replace(/,$/, '').replace(/[\s;]+$/gm, '') + '\n}';

expect(JSON5.parse(jsonSource)).be.ok;
expect(JSON5.parse(jsonSource)).toBeTruthy();
});
});
});
Expand All @@ -178,6 +177,6 @@ describe('CSS in JS', () => {
from: filename,
});

expect(document.nodes).to.have.lengthOf(2);
expect(document.nodes).toHaveLength(2);
});
});
51 changes: 22 additions & 29 deletions test/emotion.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const expect = require('chai').expect;
const fs = require('fs');
const syntax = require('../');

Expand All @@ -15,27 +14,24 @@ describe('javascript tests', () => {

code = code.toString();

expect(document.toString()).to.equal(code);
expect(document.nodes).to.lengthOf(4);
expect(document.toString()).toBe(code);
expect(document.nodes).toHaveLength(4);

document.nodes.forEach((root) => {
expect(root.last.toString()).to.be.a('string');
expect(root.source).to.haveOwnProperty('input');
expect(typeof root.last.toString()).toBe('string');
expect(root.source).toHaveProperty('input');

expect(code).to.includes(root.source.input.css);
expect(root.source.input.css.length).lessThan(code.length);
expect(root.source).to.haveOwnProperty('start').to.haveOwnProperty('line').to.greaterThan(1);
expect(code).toEqual(expect.stringContaining(root.source.input.css));
expect(root.source.input.css.length).toBeLessThan(code.length);
expect(root.source.start.line).toBeGreaterThan(1);

root.walk((node) => {
expect(node).to.haveOwnProperty('source');
expect(node).toHaveProperty('source');

expect(node.source)
.to.haveOwnProperty('input')
.to.haveOwnProperty('css')
.equal(root.source.input.css);
expect(node.source.input.css).toBe(root.source.input.css);

expect(node.source).to.haveOwnProperty('start').to.haveOwnProperty('line');
expect(node.source).to.haveOwnProperty('end').to.haveOwnProperty('line');
expect(node.source).toHaveProperty('start.line');
expect(node.source).toHaveProperty('end.line');
});
});
});
Expand All @@ -50,27 +46,24 @@ describe('javascript tests', () => {

code = code.toString();

expect(document.toString()).to.equal(code);
expect(document.nodes).to.lengthOf(6);
expect(document.toString()).toBe(code);
expect(document.nodes).toHaveLength(6);

document.nodes.forEach((root) => {
expect(root.last.toString()).to.be.a('string');
expect(root.source).to.haveOwnProperty('input');
expect(typeof root.last.toString()).toBe('string');
expect(root.source).toHaveProperty('input');

expect(code).to.includes(root.source.input.css);
expect(root.source.input.css.length).lessThan(code.length);
expect(root.source).to.haveOwnProperty('start').to.haveOwnProperty('line').to.greaterThan(1);
expect(code).toEqual(expect.stringContaining(root.source.input.css));
expect(root.source.input.css.length).toBeLessThan(code.length);
expect(root.source.start.line).toBeGreaterThan(1);

root.walk((node) => {
expect(node).to.haveOwnProperty('source');
expect(node).toHaveProperty('source');

expect(node.source)
.to.haveOwnProperty('input')
.to.haveOwnProperty('css')
.equal(root.source.input.css);
expect(node.source.input.css).toBe(root.source.input.css);

expect(node.source).to.haveOwnProperty('start').to.haveOwnProperty('line');
expect(node.source).to.haveOwnProperty('end').to.haveOwnProperty('line');
expect(node.source).toHaveProperty('start.line');
expect(node.source).toHaveProperty('end.line');
});
});
});
Expand Down
24 changes: 10 additions & 14 deletions test/glamorous.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const expect = require('chai').expect;
const fs = require('fs');
const syntax = require('../');

Expand All @@ -15,26 +14,23 @@ describe('javascript tests', () => {

code = code.toString();

expect(document.toString(syntax)).to.equal(code);
expect(document.nodes).to.lengthOf(5);
expect(document.toString(syntax)).toBe(code);
expect(document.nodes).toHaveLength(5);

document.nodes.forEach((root) => {
expect(root.source).to.haveOwnProperty('input');
expect(root.source).toHaveProperty('input');

expect(code).to.includes(root.source.input.css);
expect(root.source.input.css.length).lessThan(code.length);
expect(root.source).to.haveOwnProperty('start').to.haveOwnProperty('line').to.greaterThan(1);
expect(code).toEqual(expect.stringContaining(root.source.input.css));
expect(root.source.input.css.length).toBeLessThan(code.length);
expect(root.source.start.line).toBeGreaterThan(1);

root.walk((node) => {
expect(node).to.haveOwnProperty('source');
expect(node).toHaveProperty('source');

expect(node.source)
.to.haveOwnProperty('input')
.to.haveOwnProperty('css')
.equal(root.source.input.css);
expect(node.source.input.css).toBe(root.source.input.css);

expect(node.source).to.haveOwnProperty('start').to.haveOwnProperty('line');
expect(node.source).to.haveOwnProperty('end').to.haveOwnProperty('line');
expect(node.source).toHaveProperty('start.line');
expect(node.source).toHaveProperty('end.line');
});
});
});
Expand Down
Loading