Skip to content

Commit b6283bb

Browse files
committed
🐛 Fix broken tests
1 parent 3f65ea7 commit b6283bb

File tree

4 files changed

+120
-122
lines changed

4 files changed

+120
-122
lines changed

__tests__/no-github-info-and-desc.spec.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1+
jest.mock('shelljs', () => {
2+
return {
3+
which: () => true,
4+
exec: (cmd) => {
5+
return {
6+
stdout: cmd === 'git config --get user.email'
7+
? 'cashblack.gmail.com'
8+
: 'Cash Black',
9+
};
10+
},
11+
};
12+
});
13+
14+
jest.mock('github-username', () => jest.fn().mockImplementation(() => {
15+
return Promise.reject();
16+
}));
17+
118
jest.mock('gh-user', () => jest.fn().mockImplementation(() => {
2-
return Promise.reject({});
19+
return Promise.reject();
320
}));
421

522
const path = require('path');

__tests__/normal.spec.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

app/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ const ghUser = require('gh-user');
55

66
module.exports = class extends Generator {
77
initializing() {
8+
this.user.github.username().then(console.log).catch((e) => {
9+
console.log('haha', e);
10+
return [];
11+
});
12+
813
const ghTask = this.user.github.username()
914
.then(un => Promise.all([un, ghUser(un)]))
1015
.then(([un, info]) => {
@@ -13,6 +18,8 @@ module.exports = class extends Generator {
1318
.catch(() => []);
1419

1520
return ghTask.then(([ username, homepage ]) => {
21+
console.log(this.user.git.email());
22+
1623
this.user.info = {
1724
name: this.user.git.name(),
1825
email: this.user.git.email(),
@@ -26,6 +33,8 @@ module.exports = class extends Generator {
2633
// Have Yeoman greet the user.
2734
this.log(yosay(`Welcome to the stunning ${chalk.red('generator-node-tsnext')}!`));
2835

36+
console.log(this.user.info);
37+
2938
const fallbackDescription =
3039
'Simple Node.js module to output greeting message, written in TypeScript';
3140
const prompts = [

package-lock.json

Lines changed: 93 additions & 79 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)