Skip to content

Commit

Permalink
adds more functional tests
Browse files Browse the repository at this point in the history
cleans up lint errors

fixes starter kyt tests

fixes core rc version in starters
  • Loading branch information
delambo committed Feb 12, 2017
1 parent dc02875 commit 15f8f22
Show file tree
Hide file tree
Showing 37 changed files with 744 additions and 552 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage
**/node_modules
packages/starter-kyts
e2e_tests/fixtures

2 changes: 1 addition & 1 deletion bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ packages.forEach((pkg) => {
const dependencies = Object.assign({}, packageJSON.dependencies, packageJSON.devDependencies);
packages.forEach((spkg) => {
if (dependencies.hasOwnProperty(spkg.name)) { // eslint-disable-line no-prototype-builtins
const to = path.join(spkg.path, 'node_modules', spkg.name);
const to = path.join(pkg.path, 'node_modules', spkg.name);
shell.rm('-rf', to);
shell.ln('-sf', spkg.path, to);
logTask(`symlinked:\n${to} -> ${spkg.path}\n`);
Expand Down
5 changes: 5 additions & 0 deletions e2e_tests/fixtures/lintScript-default/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"lint-script": "kyt lint-script"
}
}
4 changes: 4 additions & 0 deletions e2e_tests/fixtures/lintScript-default/src/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

const test = 1;

module.exports = test;
5 changes: 5 additions & 0 deletions e2e_tests/fixtures/lintScript-fail/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"lint-script": "kyt lint-script"
}
}
4 changes: 4 additions & 0 deletions e2e_tests/fixtures/lintScript-fail/src/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

const test = 1

module.exports = test;
6 changes: 6 additions & 0 deletions e2e_tests/fixtures/lintScript-user-rc-with-ext/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "eslint-config-kyt",

"rules": {
}
}
5 changes: 5 additions & 0 deletions e2e_tests/fixtures/lintScript-user-rc-with-ext/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"lint-script": "kyt lint-script"
}
}
4 changes: 4 additions & 0 deletions e2e_tests/fixtures/lintScript-user-rc-with-ext/src/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

const test = 1;

module.exports = test;
6 changes: 6 additions & 0 deletions e2e_tests/fixtures/lintScript-user-rc/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "eslint-config-kyt",

"rules": {
}
}
5 changes: 5 additions & 0 deletions e2e_tests/fixtures/lintScript-user-rc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"lint-script": "kyt lint-script"
}
}
4 changes: 4 additions & 0 deletions e2e_tests/fixtures/lintScript-user-rc/src/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

const test = 1;

module.exports = test;
5 changes: 5 additions & 0 deletions e2e_tests/fixtures/lintStyle-default/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"lint-style": "kyt lint-style"
}
}
3 changes: 3 additions & 0 deletions e2e_tests/fixtures/lintStyle-default/src/test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.test {
color: green;
}
5 changes: 5 additions & 0 deletions e2e_tests/fixtures/lintStyle-fail/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"lint-style": "kyt lint-style"
}
}
3 changes: 3 additions & 0 deletions e2e_tests/fixtures/lintStyle-fail/src/test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#test {
color: green;
}
5 changes: 5 additions & 0 deletions e2e_tests/fixtures/lintStyle-scss/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"lint-style": "kyt lint-style"
}
}
3 changes: 3 additions & 0 deletions e2e_tests/fixtures/lintStyle-scss/src/test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.test {
color: green;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "stylelint-config-kyt",

"rules": {
}
}
5 changes: 5 additions & 0 deletions e2e_tests/fixtures/lintStyle-user-rc-with-ext/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"lint-style": "kyt lint-style"
}
}
3 changes: 3 additions & 0 deletions e2e_tests/fixtures/lintStyle-user-rc-with-ext/src/test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.test {
color: green;
}
6 changes: 6 additions & 0 deletions e2e_tests/fixtures/lintStyle-user-rc/.stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "stylelint-config-kyt",

"rules": {
}
}
5 changes: 5 additions & 0 deletions e2e_tests/fixtures/lintStyle-user-rc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"lint-style": "kyt lint-style"
}
}
3 changes: 3 additions & 0 deletions e2e_tests/fixtures/lintStyle-user-rc/src/test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.test {
color: green;
}
2 changes: 1 addition & 1 deletion e2e_tests/jest.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"testPathDirs": [
"<rootDir>/e2e_tests"
"<rootDir>/e2e_tests/tests"
]
}
14 changes: 0 additions & 14 deletions e2e_tests/tests/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,6 @@ describe('KYT CLI', () => {
expect(scripts['kyt:help']).toBe('kyt --help');
});

it('runs the lint command', () => {
const output = shell.exec(`${ypm} run lint-script`);
expect(output.code).toBe(0);
const outputArr = output.stdout.split('\n');
expect(outputArr.includes('✅ Your JS looks great ✨')).toBe(true);
});

it('runs the lint-style command', () => {
const output = shell.exec(`${ypm} run lint-style`);
expect(output.code).toBe(0);
const outputArr = output.stdout.split('\n');
expect(outputArr.includes('✅ Your styles look good! ✨')).toBe(true);
});

it('runs the tests command', () => {
const output = shell.exec(`${ypm} run test`);
expect(output.code).toBe(0);
Expand Down
60 changes: 60 additions & 0 deletions e2e_tests/tests/kyt-lintScript.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const path = require('path');
const shell = require('shelljs');

shell.config.silent = true;

const stageName = 'stage-script';
const getUsingLine = outputArr => outputArr.find(line => line.indexOf('Using ESLint file') > -1);

describe('kyt lint-script', () => {
beforeEach(() => {
shell.mkdir(stageName);
shell.cd(stageName);
shell.ln('-s',
path.join(process.cwd(), '../packages/kyt-core/node_modules'),
path.join(process.cwd(), 'node_modules'));
});

it('should exit the process with code 0 on lint success', () => {
shell.cp('-R', '../e2e_tests/fixtures/lintScript-default/.', '.');
const output = shell.exec('npm run lint-script');
expect(output.code).toBe(0);
});

it('should exit the process with code 1 on lint failure', () => {
shell.cp('-R', '../e2e_tests/fixtures/lintScript-fail/.', '.');
const output = shell.exec('npm run lint-script');
expect(output.code).toBe(1);
});

it('should bedazzle user on lint success', () => {
shell.cp('-R', '../e2e_tests/fixtures/lintScript-default/.', '.');
const output = shell.exec('npm run lint-script');
const outputArr = output.stdout.split('\n');
expect(output.code).toBe(0);
expect(outputArr.includes('✅ Your JS looks great ✨')).toBe(true);
});

it('should support a user .eslintrc with extension', () => {
shell.cp('-R', '../e2e_tests/fixtures/lintScript-user-rc-with-ext/.', '.');
const output = shell.exec('npm run lint-script');
const outputArr = output.stdout.split('\n');
const usingLine = getUsingLine(outputArr);
expect(output.code).toBe(0);
expect(usingLine.endsWith(`${stageName}/.eslintrc.json`)).toBe(true);
});

it('should support a user .eslintrc', () => {
shell.cp('-R', '../e2e_tests/fixtures/lintScript-user-rc/.', '.');
const output = shell.exec('npm run lint-script');
const outputArr = output.stdout.split('\n');
const usingLine = getUsingLine(outputArr);
expect(output.code).toBe(0);
expect(usingLine.endsWith(`${stageName}/.eslintrc`)).toBe(true);
});

afterEach(() => {
shell.cd('..');
shell.rm('-rf', stageName);
});
});
66 changes: 66 additions & 0 deletions e2e_tests/tests/kyt-lintStyle.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const path = require('path');
const shell = require('shelljs');

shell.config.silent = true;

const stageName = 'stage-style';
const getUsingLine = outputArr => outputArr.find(line => line.indexOf('Using Stylelint file') > -1);

describe('kyt lint-style', () => {
beforeEach(() => {
shell.mkdir(stageName);
shell.cd(stageName);
shell.ln('-s',
path.join(process.cwd(), '../packages/kyt-core/node_modules'),
path.join(process.cwd(), 'node_modules'));
});

it('should exit the process with code 0 on lint success', () => {
shell.cp('-R', '../e2e_tests/fixtures/lintStyle-default/.', '.');
const output = shell.exec('npm run lint-style');
expect(output.code).toBe(0);
});

it('should exit the process with code 1 on lint failure', () => {
shell.cp('-R', '../e2e_tests/fixtures/lintStyle-fail/.', '.');
const output = shell.exec('npm run lint-style');
expect(output.code).toBe(1);
});

it('should bedazzle user on lint success', () => {
shell.cp('-R', '../e2e_tests/fixtures/lintStyle-default/.', '.');
const output = shell.exec('npm run lint-style');
const outputArr = output.stdout.split('\n');
expect(output.code).toBe(0);
expect(outputArr.includes('✅ Your styles look good! ✨')).toBe(true);
});

it('should support a user .stylelintrc with extension', () => {
shell.cp('-R', '../e2e_tests/fixtures/lintStyle-user-rc-with-ext/.', '.');
const output = shell.exec('npm run lint-style');
const outputArr = output.stdout.split('\n');
const usingLine = getUsingLine(outputArr);
expect(output.code).toBe(0);
expect(usingLine.endsWith(`${stageName}/.stylelintrc.json`)).toBe(true);
});

it('should support a user .stylelintrc', () => {
shell.cp('-R', '../e2e_tests/fixtures/lintStyle-user-rc/.', '.');
const output = shell.exec('npm run lint-style');
const outputArr = output.stdout.split('\n');
const usingLine = getUsingLine(outputArr);
expect(output.code).toBe(0);
expect(usingLine.endsWith(`${stageName}/.stylelintrc`)).toBe(true);
});

it('should support .scss', () => {
shell.cp('-R', '../e2e_tests/fixtures/lintStyle-scss/.', '.');
const output = shell.exec('npm run lint-style');
expect(output.code).toBe(0);
});

afterEach(() => {
shell.cd('..');
shell.rm('-rf', stageName);
});
});
4 changes: 2 additions & 2 deletions packages/babel-preset-kyt-core/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ core-js@^2.4.0:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e"

debug@^2.2.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.0.tgz#bc596bcabe7617f11d9fa15361eded5608b8499b"
version "2.6.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351"
dependencies:
ms "0.7.2"

Expand Down
4 changes: 2 additions & 2 deletions packages/babel-preset-kyt-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-preset-kyt-react",
"version": "0.1.0",
"version": "0.1.1",
"description": "An opinionated babel preset for react apps, best used with kyt.",
"main": "lib/index.js",
"author": "NYTimes",
Expand All @@ -13,7 +13,7 @@
"babel-plugin-transform-react-inline-elements": "^6.8.0",
"babel-plugin-transform-react-jsx-source": "6.9.0",
"babel-plugin-transform-react-remove-prop-types": "0.2.10",
"babel-preset-kyt-core": "0.1.0-alpha.1",
"babel-preset-kyt-core": "0.1.0",
"babel-preset-react": "6.16.0"
},
"keywords": [
Expand Down
10 changes: 5 additions & 5 deletions packages/babel-preset-kyt-react/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,9 @@ babel-preset-es2017@^6.16.0:
babel-plugin-syntax-trailing-function-commas "^6.22.0"
babel-plugin-transform-async-to-generator "^6.22.0"

babel-preset-kyt-core@0.1.0-alpha.1:
version "0.1.0-alpha.1"
resolved "https://registry.yarnpkg.com/babel-preset-kyt-core/-/babel-preset-kyt-core-0.1.0-alpha.1.tgz#dc20288cbeca43f3266dc79b25f5527e8f00e909"
babel-preset-kyt-core@0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/babel-preset-kyt-core/-/babel-preset-kyt-core-0.1.0.tgz#4961c14e2420c4e0d37143c935ba61ec2c16c4d8"
dependencies:
babel-plugin-transform-es2015-modules-commonjs "6.16.0"
babel-plugin-transform-runtime "6.15.0"
Expand Down Expand Up @@ -545,8 +545,8 @@ core-js@^2.4.0:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e"

debug@^2.2.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.0.tgz#bc596bcabe7617f11d9fa15361eded5608b8499b"
version "2.6.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351"
dependencies:
ms "0.7.2"

Expand Down
Loading

0 comments on commit 15f8f22

Please sign in to comment.