@testrevolution/bugbug-cli 8.16.2 → 9.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@testrevolution/bugbug-cli",
3
3
  "description": "BugBug CLI",
4
- "version": "8.16.2",
4
+ "version": "9.4.2",
5
5
  "keywords": [
6
6
  "automation",
7
7
  "cli",
@@ -0,0 +1,76 @@
1
+ const commands = require('../commands');
2
+ const config = require('../utils/config');
3
+ const runMainProcess = require('../index');
4
+ const { VERSION } = require('../settings');
5
+
6
+ jest.mock('../commands');
7
+ jest.mock('../utils/helper');
8
+
9
+ describe('main process', () => {
10
+ const originalProcessExit = process.exit;
11
+
12
+ beforeAll(() => {
13
+ process.exit = jest.fn();
14
+ });
15
+
16
+ beforeEach(() => {
17
+ jest.spyOn(config, 'initConfigDir').mockImplementation(() => Promise.resolve());
18
+ });
19
+
20
+ afterEach(() => {
21
+ jest.clearAllMocks();
22
+ });
23
+
24
+ afterAll(() => {
25
+ process.exit = originalProcessExit;
26
+ });
27
+
28
+ it('should call config command', async () => {
29
+ // Arrange
30
+ const args = ['node', './bugbug', 'config', 'set-token', 1234];
31
+ process.argv = args;
32
+
33
+ // Act
34
+ await runMainProcess();
35
+
36
+ // Assert
37
+ expect(commands.config).toHaveBeenCalledWith({ _: args.slice(2) });
38
+ });
39
+
40
+ it('should call remote command', async () => {
41
+ // Arrange
42
+ const args = ['node', './bugbug', 'remote', 'test'];
43
+ process.argv = args;
44
+
45
+ // Act
46
+ await runMainProcess();
47
+
48
+ // Assert
49
+ expect(commands.remote).toHaveBeenCalledWith({ _: args.slice(2) });
50
+ });
51
+
52
+ it('should call help command', async () => {
53
+ // Arrange
54
+ const args = ['node', './bugbug', 'help'];
55
+ process.argv = args;
56
+
57
+ // Act
58
+ await runMainProcess();
59
+
60
+ // Assert
61
+ expect(commands.help).toHaveBeenCalledWith({ _: args.slice(2) });
62
+ });
63
+
64
+ it('should call version command', async () => {
65
+ // Arrange
66
+ const args = ['node', './bugbug', 'version'];
67
+ process.argv = args;
68
+ jest.spyOn(console, 'log').mockImplementation(() => {});
69
+
70
+ // Act
71
+ await runMainProcess();
72
+
73
+ // Assert
74
+ expect(console.log).toHaveBeenCalledWith(VERSION);
75
+ });
76
+ });
package/src/index.js CHANGED
@@ -19,8 +19,10 @@ module.exports = async () => {
19
19
  const args = minimist(process.argv.slice(2));
20
20
  const cmd = args._[0] || 'help';
21
21
  let exitCode;
22
+
22
23
  await helper.overrideSettings(args);
23
- api.mountAxiosInterceptors(args.debug);
24
+ api.mountAxiosInterceptors(`${args.debug}` === 'true');
25
+
24
26
  switch (cmd) {
25
27
  case 'config':
26
28
  exitCode = await commands.config(args);
package/src/utils/api.js CHANGED
@@ -26,14 +26,14 @@ const printResponseData = (response) => {
26
26
  });
27
27
  };
28
28
 
29
- const interceptResponseSuccess = (isDebugEnabled) => (response) => {
29
+ const interceptResponseSuccess = (isDebugEnabled = false) => (response) => {
30
30
  if (isDebugEnabled) {
31
31
  printResponseData(response);
32
32
  }
33
33
  return response;
34
34
  };
35
35
 
36
- const interceptResponseError = (spinner, isDebugEnabled) => (error) => {
36
+ const interceptResponseError = (spinner, isDebugEnabled = false) => (error) => {
37
37
  const { response } = error;
38
38
  if (response && isDebugEnabled) {
39
39
  printResponseData(response);