set up testing
This commit is contained in:
parent
7ac762c77f
commit
b97520fd9c
12
e2e/addngrx.test.ts
Normal file
12
e2e/addngrx.test.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import {cleanup, runCLI, runSchematic} from './utils';
|
||||||
|
|
||||||
|
describe('addNgRxToModule', () => {
|
||||||
|
beforeEach(cleanup);
|
||||||
|
|
||||||
|
it('should add ngrx to module', () => {
|
||||||
|
runCLI('new proj --skip-install ');
|
||||||
|
runSchematic('@nrwl/ext:addNgRxToModule', {cwd: 'proj'});
|
||||||
|
|
||||||
|
expect(1).toEqual(2);
|
||||||
|
}, 50000);
|
||||||
|
});
|
||||||
9
e2e/package.json__tmpl__
Normal file
9
e2e/package.json__tmpl__
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"name": "e2e",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"devDependencies": {
|
||||||
|
"@angular-devkit/schematics": "0.0.14",
|
||||||
|
"@angular/cli": "1.3.0",
|
||||||
|
"rxjs": "5.4.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
32
e2e/utils.ts
Normal file
32
e2e/utils.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import {execSync} from 'child_process';
|
||||||
|
|
||||||
|
export function runCLI(command: string, {cwd}: {cwd?: string} = {}): string {
|
||||||
|
cwd = cwd === undefined ? '' : cwd;
|
||||||
|
return execSync(`../node_modules/.bin/ng ${command}`, {cwd: `./tmp/${cwd}`}).toString();
|
||||||
|
}
|
||||||
|
export function runSchematic(command: string, {cwd}: {cwd?: string} = {}): string {
|
||||||
|
cwd = cwd === undefined ? '' : cwd;
|
||||||
|
return execSync(`../../node_modules/.bin/schematics ${command}`, {cwd: `./tmp/${cwd}`}).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// export function updateFile(f: string, content: string): void {
|
||||||
|
// writeFileSync(path.join(files.getCwd(), 'tmp', f), content);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// export function checkFilesExists(...expectedFiles: string[]) {
|
||||||
|
// expectedFiles.forEach(f => {
|
||||||
|
// const ff = f.startsWith('/') ? f : path.join(files.getCwd(), 'tmp', f);
|
||||||
|
// if (! files.exists(ff)) {
|
||||||
|
// throw new Error(`File '${ff}' does not exist`);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// export function readFile(f: string) {
|
||||||
|
// const ff = f.startsWith('/') ? f : path.join(files.getCwd(), 'tmp', f);
|
||||||
|
// return readFileSync(ff).toString();
|
||||||
|
// }
|
||||||
|
|
||||||
|
export function cleanup() {
|
||||||
|
execSync('rm -rf tmp && mkdir tmp');
|
||||||
|
}
|
||||||
22
package.json
22
package.json
@ -1,19 +1,27 @@
|
|||||||
{
|
{
|
||||||
"name": "AngularExt",
|
"name": "@nrwl/ext",
|
||||||
"version": "0.0.1n",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "./scripts/build.sh"
|
"build": "./scripts/build.sh",
|
||||||
|
"e2e": "yarn build && ./scripts/e2e.sh"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "2.4.2",
|
"typescript": "2.4.2",
|
||||||
"@types/node": "8.0.7",
|
"@types/node": "8.0.7",
|
||||||
"@types/jasmine": "2.5.53",
|
"@types/jasmine": "2.5.53",
|
||||||
|
"@angular-devkit/core": "0.0.10",
|
||||||
"@angular-devkit/core": "0.0.9",
|
"@angular-devkit/schematics": "0.0.16",
|
||||||
"@angular-devkit/schematics": "0.0.9"
|
"jest": "20.0.4"
|
||||||
},
|
},
|
||||||
"author": "Victor Savkin",
|
"author": "Victor Savkin",
|
||||||
"license": "MIT"
|
"license": "MIT",
|
||||||
|
"jest" : {
|
||||||
|
"modulePathIgnorePatterns": [
|
||||||
|
"tmp",
|
||||||
|
"files"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"schematics": "schematics/collection.json"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,4 +3,4 @@
|
|||||||
rm -rf build
|
rm -rf build
|
||||||
rm -rf tmp
|
rm -rf tmp
|
||||||
tsc
|
tsc
|
||||||
rsync -a --exclude=*.ts src/ build/
|
rsync -a --exclude=*.ts src/ build/src
|
||||||
|
|||||||
9
scripts/e2e.sh
Executable file
9
scripts/e2e.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
rm -rf node_modules/@nrwl
|
||||||
|
mkdir -p node_modules/@nrwl
|
||||||
|
cp -r build/src node_modules/@nrwl/ext
|
||||||
|
cp package.json node_modules/@nrwl/ext/package.json
|
||||||
|
|
||||||
|
rm -rf tmp
|
||||||
|
jest --maxWorkers=1 ./build/e2e
|
||||||
@ -2,8 +2,9 @@ import {apply, branchAndMerge, chain, mergeWith, Rule, template, Tree, url} from
|
|||||||
import { names } from "../name-utils";
|
import { names } from "../name-utils";
|
||||||
|
|
||||||
export default function (options: any): Rule {
|
export default function (options: any): Rule {
|
||||||
|
|
||||||
const templateSource = apply(url('./files'), [
|
const templateSource = apply(url('./files'), [
|
||||||
template({...options, tmpl: '', ...names(options.name)})
|
template({...options, tmpl: '', ...names('some')})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return chain([
|
return chain([
|
||||||
|
|||||||
@ -23,4 +23,4 @@ function toFileName(s: string): string {
|
|||||||
|
|
||||||
function toCapitalCase(s: string): string {
|
function toCapitalCase(s: string): string {
|
||||||
return s.charAt(0).toUpperCase() + s.substr(1);
|
return s.charAt(0).toUpperCase() + s.substr(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,4 +14,4 @@
|
|||||||
"tmp",
|
"tmp",
|
||||||
"node_modules"
|
"node_modules"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user