Skip to content

Commit c10f04d

Browse files
authored
Merge pull request #130 from reportportal/update-deps
Update deps. Add prettier
2 parents a8c098c + 3eaf291 commit c10f04d

14 files changed

+2611
-2595
lines changed

.eslintrc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
2-
"extends": "airbnb-base",
2+
"extends": [
3+
"airbnb-base",
4+
"plugin:prettier/recommended",
5+
"plugin:import/recommended"
6+
],
7+
"plugins": ["prettier"],
38
"globals": {
49
"expectAsync": true
510
},
@@ -8,7 +13,6 @@
813
"es6": true
914
},
1015
"rules": {
11-
"indent": ["error", 4],
1216
"max-len": ["error", 120],
1317
"valid-jsdoc": ["error", { "requireReturn": false }],
1418
"consistent-return": 0,

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"arrowParens": "always",
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"printWidth": 100
6+
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### Changed
22
- `token` configuration option was renamed to `apiKey` to maintain common convention.
33
- `@reportportal/client-javascript` bumped to version `5.0.12`.
4+
- Readme file updated.
45

56
## [5.0.5] - 2023-03-16
67
### Added

__tests__/getOptions.spec.js

Lines changed: 104 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -18,113 +18,119 @@
1818
const fs = require('fs');
1919
const path = require('path');
2020
const process = require('process');
21-
const {
22-
options,
23-
getAppOptions,
24-
getEnvOptions,
25-
} = require('../utils/getOptions');
21+
const { options, getAppOptions, getEnvOptions } = require('../utils/getOptions');
2622
const constants = require('../constants/index');
2723

2824
describe('Get Options script', () => {
29-
const OLD_ENV = process.env;
30-
const processCwdValue = process.cwd();
31-
32-
beforeEach(() => {
33-
jest.resetModules();
34-
process.env = { ...OLD_ENV };
35-
delete process.env.NODE_ENV;
25+
const OLD_ENV = process.env;
26+
const processCwdValue = process.cwd();
27+
28+
beforeEach(() => {
29+
jest.resetModules();
30+
process.env = { ...OLD_ENV };
31+
delete process.env.NODE_ENV;
32+
});
33+
34+
afterEach(() => {
35+
jest.clearAllMocks();
36+
process.env = OLD_ENV;
37+
});
38+
39+
describe('getEnvOptions', () => {
40+
test("should return empty envOptions object if environments don't set", () => {
41+
const envOptionsObject = getEnvOptions();
42+
43+
expect(envOptionsObject).toBeDefined();
44+
expect(envOptionsObject).toEqual({});
3645
});
3746

38-
afterEach(() => {
39-
jest.clearAllMocks();
40-
process.env = OLD_ENV;
47+
test('should return envOptions object with correct values', () => {
48+
const expectedEnvOptionsObject = {
49+
suiteName: 'suite name',
50+
output: 'output',
51+
classNameTemplate: 'class name',
52+
titleTemplate: 'title',
53+
};
54+
process.env = {
55+
JEST_SUITE_NAME: 'suite name',
56+
JEST_JUNIT_OUTPUT: 'output',
57+
JEST_JUNIT_CLASSNAME: 'class name',
58+
JEST_JUNIT_TITLE: 'title',
59+
};
60+
61+
const envOptionsObject = getEnvOptions();
62+
63+
expect(envOptionsObject).toBeDefined();
64+
expect(envOptionsObject).toEqual(expectedEnvOptionsObject);
4165
});
66+
});
4267

43-
describe('getEnvOptions', () => {
44-
test('should return empty envOptions object if environments don\'t set', () => {
45-
const envOptionsObject = getEnvOptions();
46-
47-
expect(envOptionsObject).toBeDefined();
48-
expect(envOptionsObject).toEqual({});
49-
});
50-
51-
test('should return envOptions object with correct values', () => {
52-
const expectedEnvOptionsObject = {
53-
suiteName: 'suite name',
54-
output: 'output',
55-
classNameTemplate: 'class name',
56-
titleTemplate: 'title',
57-
};
58-
process.env = {
59-
JEST_SUITE_NAME: 'suite name',
60-
JEST_JUNIT_OUTPUT: 'output',
61-
JEST_JUNIT_CLASSNAME: 'class name',
62-
JEST_JUNIT_TITLE: 'title',
63-
};
64-
65-
const envOptionsObject = getEnvOptions();
66-
67-
expect(envOptionsObject).toBeDefined();
68-
expect(envOptionsObject).toEqual(expectedEnvOptionsObject);
69-
});
70-
});
68+
describe('getAppOptions', () => {
69+
test('should return empty AppOptions object if fs.existsSync return false', () => {
70+
const pathToResolve = `${path.sep}path${path.sep}to${path.sep}directory`;
71+
jest.mock('fs');
72+
fs.existsSync = jest.fn();
73+
fs.existsSync.mockReturnValue(false);
7174

72-
describe('getAppOptions', () => {
73-
test('should return empty AppOptions object if fs.existsSync return false', () => {
74-
const pathToResolve = `${path.sep}path${path.sep}to${path.sep}directory`;
75-
jest.mock('fs');
76-
fs.existsSync = jest.fn();
77-
fs.existsSync.mockReturnValue(false);
78-
79-
const appOptionsObject = getAppOptions(pathToResolve);
80-
81-
expect(appOptionsObject).toBeDefined();
82-
expect(appOptionsObject).toEqual({});
83-
});
84-
85-
test('should return empty AppOptions object if fs.existsSync return true and type of options'
86-
+ ' is not [object Object]', () => {
87-
const spyProcessCwd = jest.spyOn(process, 'cwd');
88-
// eslint-disable-next-line max-len
89-
spyProcessCwd.mockReturnValue(`${processCwdValue}${path.sep}__tests__${path.sep}fixtures${path.sep}mockedPackageJsonString`);
90-
jest.mock('fs');
91-
fs.existsSync = jest.fn();
92-
fs.existsSync.mockReturnValue(true);
93-
94-
const appOptionsObject = getAppOptions(process.cwd());
95-
96-
expect(appOptionsObject).toBeDefined();
97-
expect(appOptionsObject).toEqual({});
98-
99-
spyProcessCwd.mockClear();
100-
});
101-
102-
test('should return AppOptions object if fs.existsSync return true and type of options'
103-
+ ' is [object Object]', () => {
104-
const spyProcessCwd = jest.spyOn(process, 'cwd');
105-
// eslint-disable-next-line max-len
106-
spyProcessCwd.mockReturnValue(`${processCwdValue}${path.sep}__tests__${path.sep}fixtures${path.sep}mockedPackageJsonObject`);
107-
jest.mock('fs');
108-
fs.existsSync = jest.fn();
109-
fs.existsSync.mockReturnValue(true);
110-
111-
const appOptionsObject = getAppOptions(process.cwd());
112-
113-
expect(appOptionsObject).toBeDefined();
114-
expect(appOptionsObject).toEqual({ keyOne: 'valueOne' });
115-
});
116-
});
75+
const appOptionsObject = getAppOptions(pathToResolve);
11776

118-
describe('options', () => {
119-
test('should return options object with empty reporterOptions object', () => {
120-
const expectedOptions = { ...constants.DEFAULT_OPTIONS };
121-
const spyProcessCwd = jest.spyOn(process, 'cwd');
122-
spyProcessCwd.mockReturnValue(processCwdValue);
123-
124-
const optionsObject = options();
77+
expect(appOptionsObject).toBeDefined();
78+
expect(appOptionsObject).toEqual({});
79+
});
12580

126-
expect(optionsObject).toBeDefined();
127-
expect(optionsObject).toEqual(expectedOptions);
128-
});
81+
test(
82+
'should return empty AppOptions object if fs.existsSync return true and type of options' +
83+
' is not [object Object]',
84+
() => {
85+
const spyProcessCwd = jest.spyOn(process, 'cwd');
86+
// eslint-disable-next-line max-len
87+
spyProcessCwd.mockReturnValue(
88+
`${processCwdValue}${path.sep}__tests__${path.sep}fixtures${path.sep}mockedPackageJsonString`,
89+
);
90+
jest.mock('fs');
91+
fs.existsSync = jest.fn();
92+
fs.existsSync.mockReturnValue(true);
93+
94+
const appOptionsObject = getAppOptions(process.cwd());
95+
96+
expect(appOptionsObject).toBeDefined();
97+
expect(appOptionsObject).toEqual({});
98+
99+
spyProcessCwd.mockClear();
100+
},
101+
);
102+
103+
test(
104+
'should return AppOptions object if fs.existsSync return true and type of options' +
105+
' is [object Object]',
106+
() => {
107+
const spyProcessCwd = jest.spyOn(process, 'cwd');
108+
// eslint-disable-next-line max-len
109+
spyProcessCwd.mockReturnValue(
110+
`${processCwdValue}${path.sep}__tests__${path.sep}fixtures${path.sep}mockedPackageJsonObject`,
111+
);
112+
jest.mock('fs');
113+
fs.existsSync = jest.fn();
114+
fs.existsSync.mockReturnValue(true);
115+
116+
const appOptionsObject = getAppOptions(process.cwd());
117+
118+
expect(appOptionsObject).toBeDefined();
119+
expect(appOptionsObject).toEqual({ keyOne: 'valueOne' });
120+
},
121+
);
122+
});
123+
124+
describe('options', () => {
125+
test('should return options object with empty reporterOptions object', () => {
126+
const expectedOptions = { ...constants.DEFAULT_OPTIONS };
127+
const spyProcessCwd = jest.spyOn(process, 'cwd');
128+
spyProcessCwd.mockReturnValue(processCwdValue);
129+
130+
const optionsObject = options();
131+
132+
expect(optionsObject).toBeDefined();
133+
expect(optionsObject).toEqual(expectedOptions);
129134
});
135+
});
130136
});

0 commit comments

Comments
 (0)