Skip to content

Commit

Permalink
more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
icepeng committed Feb 10, 2017
1 parent ff91e05 commit b73299c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gulp.task('nsp', (cb) => {
});

gulp.task('pre-test', () =>
gulp.src('generators/**/*.js')
gulp.src(['generators/**/*.js', '!generators/**/templates/*.js'])
.pipe(excludeGitignore())
.pipe(istanbul({
includeUntested: true,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2 || ^4.0.0",
"eslint-plugin-react": "^6.9.0",
"fs-extra": "^2.0.0",
"yeoman-generator": "^1.0.0",
"yosay": "^1.2.1"
},
Expand Down
39 changes: 31 additions & 8 deletions test/api.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
/* global describe before it */
/* global describe before after it */
const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
const fs = require('fs-extra');

describe('generator-express-pgp-typescript:api', () => {
before(() => helpers.run(path.join(__dirname, '../generators/api'))
it('creates model files', () => helpers.run(path.join(__dirname, '../generators/api'))
.inTmpDir((dir) => {
fs.copySync(path.join(__dirname, '../generators/app/templates'), dir);
})
.withPrompts({
basicName: 'yoshi',
rest: false,
})
.withPrompts({
name: '',
})
.toPromise());
.toPromise()
.then(() => {
assert.file([
'src/model/repos/yoshi.ts',
]);
}));

it('creates files', () => {
assert.file([
'src/model/repos/yoshi.ts',
]);
});
it('creates model and route files', () => helpers.run(path.join(__dirname, '../generators/api'))
.inTmpDir((dir) => {
fs.copySync(path.join(__dirname, '../generators/app/templates'), dir);
})
.withPrompts({
basicName: 'yoshi',
rest: true,
plural: 'yoshies',
})
.withPrompts({
name: '',
})
.toPromise()
.then(() => {
assert.file([
'src/model/repos/yoshi.ts',
'src/routes/yoshi/index.ts',
]);
}));
});
15 changes: 14 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,13 @@ fs-exists-sync@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz#982d6893af918e72d08dec9e8673ff2b5a8d6add"

fs-extra@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-2.0.0.tgz#337352bded4a0b714f3eb84de8cea765e9d37600"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^2.1.0"

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
Expand Down Expand Up @@ -1374,7 +1381,7 @@ graceful-fs@^3.0.0:
dependencies:
natives "^1.1.0"

graceful-fs@^4.1.2:
graceful-fs@^4.1.2, graceful-fs@^4.1.6:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"

Expand Down Expand Up @@ -2002,6 +2009,12 @@ json3@3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1"

jsonfile@^2.1.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
optionalDependencies:
graceful-fs "^4.1.6"

jsonify@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
Expand Down

0 comments on commit b73299c

Please sign in to comment.