-
-
Notifications
You must be signed in to change notification settings - Fork 168
/
analytics.test.ts
62 lines (55 loc) · 2.06 KB
/
analytics.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { expect, test } from '@oclif/test';
import { fileCleanup } from '../../helpers';
const analyticsConfigFilePath = './test/fixtures/.asyncapi-analytics';
describe('config:analytics', () => {
beforeEach(() => {
process.env = Object.assign(process.env, { ASYNCAPI_METRICS_CONFIG_PATH: analyticsConfigFilePath });
});
afterEach(() => {
fileCleanup(analyticsConfigFilePath);
});
describe('with disable flag', () => {
test
.stderr()
.stdout()
.command(['config:analytics', '--disable'])
.it('should show a successful message once the analytics are disabled', async (ctx, done) => {
expect(ctx.stdout).to.equal('\nAnalytics disabled.\n\n');
expect(ctx.stderr).to.equal('');
done();
});
});
describe('with enable flag', () => {
test
.stderr()
.stdout()
.command(['config:analytics', '--enable'])
.it('should show a successful message once the analytics are enabled', (ctx, done) => {
expect(ctx.stdout).to.equal('\nAnalytics enabled.\n\n');
expect(ctx.stderr).to.equal('');
done();
});
});
describe('with no flags', () => {
test
.stderr()
.stdout()
.command(['config:analytics'])
.it('should show informational message when no flags are used', (ctx, done) => {
expect(ctx.stdout).to.equal('\nPlease append the "--disable" flag to the command in case you prefer to disable analytics, or use the "--enable" flag if you want to enable analytics back again. In case you do not know the analytics current status, then you can append the "--status" flag to be aware of it.\n\n');
expect(ctx.stderr).to.equal('');
done();
});
});
describe('with status flag', () => {
test
.stderr()
.stdout()
.command(['config:analytics', '--status'])
.it('should show a different informational message depending on the analytics status', (ctx, done) => {
expect(ctx.stdout).to.contain('\nAnalytics are ');
expect(ctx.stderr).to.equal('');
done();
});
});
});