Skip to content

Commit f12d06b

Browse files
MoLowaduh95
authored andcommitted
fixes
1 parent 2dd1257 commit f12d06b

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

test/unit/auth.test.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,34 @@ const MOCKED_TOKEN = JSON.stringify({
1919

2020
describe('auth', async function() {
2121
it('asks for auth data if no ncurc is found', async function() {
22-
this.timeout(2000);
2322
await runAuthScript(
2423
undefined,
2524
[FIRST_TIME_MSG, MOCKED_TOKEN]
2625
);
2726
});
2827

2928
it('asks for auth data if ncurc is invalid json', async function() {
30-
this.timeout(2000);
3129
await runAuthScript(
3230
{ HOME: 'this is not json' },
3331
[FIRST_TIME_MSG, MOCKED_TOKEN]
3432
);
3533
});
3634

3735
it('returns ncurc data if valid in HOME', async function() {
38-
this.timeout(2000);
3936
await runAuthScript(
4037
{ HOME: { username: 'nyancat', token: '0123456789abcdef' } },
4138
[MOCKED_TOKEN]
4239
);
4340
});
4441

4542
it('returns ncurc data if valid in XDG_CONFIG_HOME', async function() {
46-
this.timeout(2000);
4743
await runAuthScript(
4844
{ HOME: { username: 'nyancat', token: '0123456789abcdef' } },
4945
[MOCKED_TOKEN]
5046
);
5147
});
5248

5349
it('prefers XDG_CONFIG_HOME/ncurc to HOME/.ncurc', async function() {
54-
this.timeout(2000);
5550
await runAuthScript(
5651
{
5752
HOME: { username: 'notnyancat', token: 'somewrongtoken' },
@@ -62,7 +57,6 @@ describe('auth', async function() {
6257
});
6358

6459
it("prints an error message if it can't generate a token", async function() {
65-
this.timeout(2000);
6660
await runAuthScript(
6761
{},
6862
[FIRST_TIME_MSG],
@@ -71,7 +65,6 @@ describe('auth', async function() {
7165
});
7266

7367
it('does not accept a non-string username', async function() {
74-
this.timeout(2000);
7568
await runAuthScript(
7669
{ HOME: { username: {}, token: '0123456789abcdef' } },
7770
[],
@@ -80,7 +73,6 @@ describe('auth', async function() {
8073
});
8174

8275
it('does not accept a non-string token', async function() {
83-
this.timeout(2000);
8476
await runAuthScript(
8577
{ HOME: { username: 'nyancat', token: 42 } },
8678
[],
@@ -89,7 +81,6 @@ describe('auth', async function() {
8981
});
9082

9183
it('does not accept an invalid username format', async function() {
92-
this.timeout(2000);
9384
await runAuthScript(
9485
{ HOME: { username: ' ^^^ ', token: '0123456789abcdef' } },
9586
[],
@@ -99,7 +90,6 @@ describe('auth', async function() {
9990
});
10091

10192
it('does not accept an invalid token format', async function() {
102-
this.timeout(2000);
10393
await runAuthScript(
10494
{ HOME: { username: 'nyancat', token: '@fhqwhgads' } },
10595
[],
@@ -108,15 +98,13 @@ describe('auth', async function() {
10898
});
10999

110100
it('permits capital letters in token format', async function() {
111-
this.timeout(2000);
112101
await runAuthScript(
113102
{ HOME: { username: 'nyancat', token: '0123456789ABCDEF' } },
114103
['{"github":"bnlhbmNhdDowMTIzNDU2Nzg5QUJDREVG"}']
115104
);
116105
});
117106

118107
it('permits underscores in token format', async function() {
119-
this.timeout(2000);
120108
await runAuthScript(
121109
{ HOME: { username: 'nyancat', token: 'ghp_0123456789ABCDEF' } },
122110
['{"github":"bnlhbmNhdDpnaHBfMDEyMzQ1Njc4OUFCQ0RFRg=="}']

test/unit/cli.test.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ describe('cli', () => {
4141

4242
describe('spinners', () => {
4343
beforeEach(() => {
44+
stream = new LogStream();
45+
cli = new CLI(stream);
4446
cli.startSpinner('foo');
4547
});
4648

@@ -59,20 +61,34 @@ describe('cli', () => {
5961
});
6062

6163
describe('write', () => {
64+
beforeEach(() => {
65+
stream = new LogStream();
66+
cli = new CLI(stream);
67+
});
6268
it('should write in stream', () => {
69+
const stream = new LogStream();
70+
const cli = new CLI(stream);
6371
cli.write('Getting commits...');
64-
assert.strictEqual(logResult(), 'Getting commits...');
72+
assert.strictEqual(strip(stream.toString()), 'Getting commits...');
6573
});
6674
});
6775

6876
describe('log', () => {
77+
beforeEach(() => {
78+
stream = new LogStream();
79+
cli = new CLI(stream);
80+
});
6981
it('should write in stream', () => {
7082
cli.log('Getting commits...');
7183
assert.strictEqual(logResult(), 'Getting commits...\n');
7284
});
7385
});
7486

7587
describe('table', () => {
88+
beforeEach(() => {
89+
stream = new LogStream();
90+
cli = new CLI(stream);
91+
});
7692
it('should print the first element with bold style and padding', () => {
7793
cli.table('Title', 'description');
7894
assert.strictEqual(logResult(),
@@ -81,6 +97,10 @@ describe('cli', () => {
8197
});
8298

8399
describe('separator', () => {
100+
beforeEach(() => {
101+
stream = new LogStream();
102+
cli = new CLI(stream);
103+
});
84104
it('should print a separator line with the specified text', () => {
85105
cli.separator('Separator');
86106
assert.strictEqual(
@@ -106,6 +126,10 @@ describe('cli', () => {
106126
});
107127

108128
describe('ok', () => {
129+
beforeEach(() => {
130+
stream = new LogStream();
131+
cli = new CLI(stream);
132+
});
109133
it('should print a success message', () => {
110134
cli.ok('Perfect!');
111135
assert.strictEqual(logResult(), ` ${success} Perfect!\n`);
@@ -119,6 +143,10 @@ describe('cli', () => {
119143
});
120144

121145
describe('warn', () => {
146+
beforeEach(() => {
147+
stream = new LogStream();
148+
cli = new CLI(stream);
149+
});
122150
it('should print a warning message', () => {
123151
cli.warn('Warning!');
124152
assert.strictEqual(logResult(), ` ${warning} Warning!\n`);
@@ -132,6 +160,10 @@ describe('cli', () => {
132160
});
133161

134162
describe('info', () => {
163+
beforeEach(() => {
164+
stream = new LogStream();
165+
cli = new CLI(stream);
166+
});
135167
it('should print an info message', () => {
136168
cli.info('Info!');
137169
assert.strictEqual(logResult(), ` ${info} Info!\n`);
@@ -144,6 +176,10 @@ describe('cli', () => {
144176
});
145177

146178
describe('error', () => {
179+
beforeEach(() => {
180+
stream = new LogStream();
181+
cli = new CLI(stream);
182+
});
147183
it('should print an error message', () => {
148184
cli.error('Error!');
149185
assert.strictEqual(logResult(), ` ${error} Error!\n`);
@@ -184,6 +220,7 @@ describe('cli', () => {
184220
questionType: cli.QUESTION_TYPE.INPUT
185221
});
186222
assert.strictEqual(cli.spinner.isSpinning, true);
223+
cli.stopSpinner('foo');
187224
});
188225
});
189226

0 commit comments

Comments
 (0)