@reportportal/client-javascript 5.0.2 → 5.0.6

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.
@@ -1,142 +0,0 @@
1
- const os = require('os');
2
- const fs = require('fs');
3
- const glob = require('glob');
4
- const RPClient = require('../lib/report-portal-client.js');
5
- const RestClient = require('../lib/rest');
6
- const pjson = require('./../package.json');
7
-
8
- describe('Helpers', () => {
9
- const client = new RPClient({ token: 'token' });
10
-
11
- describe('formatName', () => {
12
- it('slice last 256 symbols', () => {
13
- expect(client.helpers.formatName(`a${'b'.repeat(256)}`)).toBe('b'.repeat(256));
14
- });
15
- it('leave 256 symbol name as is', () => {
16
- expect(client.helpers.formatName('c'.repeat(256))).toBe('c'.repeat(256));
17
- });
18
- it('leave 3 symbol name as is', () => {
19
- expect(client.helpers.formatName('abc')).toBe('abc');
20
- });
21
- it('complete with dots 2 symbol name', () => {
22
- expect(client.helpers.formatName('ab')).toBe('ab.');
23
- });
24
- });
25
-
26
- describe('now', () => {
27
- it('returns milliseconds from unix time', () => {
28
- expect(new Date() - client.helpers.now()).toBeLessThan(100); // less than 100 miliseconds difference
29
- });
30
- });
31
-
32
- describe('getServerResults', () => {
33
- it('calls RestClient#request', () => {
34
- spyOn(RestClient, 'request');
35
-
36
- client.helpers.getServerResult(
37
- 'http://localhost:80/api/v1',
38
- { userId: 1 },
39
- {
40
- headers: {
41
- 'X-Custom-Header': 'WOW',
42
- },
43
- },
44
- 'POST',
45
- );
46
-
47
- expect(RestClient.request).toHaveBeenCalledWith(
48
- 'POST',
49
- 'http://localhost:80/api/v1',
50
- { userId: 1 },
51
- {
52
- headers: {
53
- 'X-Custom-Header': 'WOW',
54
- },
55
- },
56
- );
57
- });
58
- });
59
-
60
- describe('readLaunchesFromFile', () => {
61
- it('should return the right ids', () => {
62
- spyOn(glob, 'sync').and.returnValue(['rplaunch-fileOne.tmp', 'rplaunch-fileTwo.tmp']);
63
-
64
- const ids = client.helpers.readLaunchesFromFile();
65
-
66
- expect(ids).toEqual(['fileOne', 'fileTwo']);
67
- });
68
- });
69
-
70
- describe('saveLaunchIdToFile', () => {
71
- it('should call fs.open method with right parameters', () => {
72
- spyOn(fs, 'open');
73
-
74
- client.helpers.saveLaunchIdToFile('fileOne');
75
-
76
- expect(fs.open).toHaveBeenCalledWith('rplaunch-fileOne.tmp', 'w', jasmine.any(Function));
77
- });
78
- });
79
-
80
- describe('getSystemAttribute', () => {
81
- it('should return correct system attributes', () => {
82
- spyOn(os, 'type').and.returnValue('osType');
83
- spyOn(os, 'arch').and.returnValue('osArchitecture');
84
- spyOn(os, 'totalmem').and.returnValue('1');
85
- const nodeVersion = process.version;
86
- const expectedAttr = [{
87
- key: 'client',
88
- value: `${pjson.name}|${pjson.version}`,
89
- system: true,
90
- }, {
91
- key: 'os',
92
- value: 'osType|osArchitecture',
93
- system: true,
94
- }, {
95
- key: 'RAMSize',
96
- value: '1',
97
- system: true,
98
- }, {
99
- key: 'nodeJS',
100
- value: nodeVersion,
101
- system: true,
102
- }];
103
-
104
- const attr = client.helpers.getSystemAttribute();
105
-
106
- expect(attr).toEqual(expectedAttr);
107
- });
108
- });
109
-
110
- describe('generateTestCaseId', () => {
111
- it('should return undefined if there is no codeRef', () => {
112
- const testCaseId = client.helpers.generateTestCaseId();
113
-
114
- expect(testCaseId).toEqual(undefined);
115
- });
116
-
117
- it('should return codeRef if there is no params', () => {
118
- const testCaseId = client.helpers.generateTestCaseId('codeRef');
119
-
120
- expect(testCaseId).toEqual('codeRef');
121
- });
122
-
123
- it('should return codeRef with parameters if there are all parameters', () => {
124
- const parameters = [
125
- {
126
- key: 'key',
127
- value: 'value',
128
- },
129
- { value: 'valueTwo' },
130
- { key: 'keyTwo' },
131
- {
132
- key: 'keyThree',
133
- value: 'valueThree',
134
- },
135
- ];
136
-
137
- const testCaseId = client.helpers.generateTestCaseId('codeRef', parameters);
138
-
139
- expect(testCaseId).toEqual('codeRef[value,valueTwo,valueThree]');
140
- });
141
- });
142
- });
@@ -1,75 +0,0 @@
1
- const PublicReportingAPI = require('../lib/publicReportingAPI');
2
- const { EVENTS } = require('../lib/constants/events');
3
-
4
- describe('PublicReportingAPI', () => {
5
- it('setDescription should trigger process.emit with correct parameters', () => {
6
- spyOn(process, 'emit');
7
-
8
- PublicReportingAPI.setDescription('text', 'suite');
9
-
10
- expect(process.emit).toHaveBeenCalledWith(EVENTS.SET_DESCRIPTION, {
11
- text: 'text',
12
- suite: 'suite',
13
- });
14
- });
15
-
16
- it('addAttributes should trigger process.emit with correct parameters', () => {
17
- spyOn(process, 'emit');
18
-
19
- PublicReportingAPI.addAttributes([{ value: 'value' }], 'suite');
20
-
21
- expect(process.emit).toHaveBeenCalledWith(EVENTS.ADD_ATTRIBUTES, {
22
- attributes: [{ value: 'value' }],
23
- suite: 'suite',
24
- });
25
- });
26
-
27
- it('addLog should trigger process.emit with correct parameters', () => {
28
- spyOn(process, 'emit');
29
-
30
- PublicReportingAPI.addLog({ level: 'INFO', message: 'message' }, 'suite');
31
-
32
- expect(process.emit).toHaveBeenCalledWith(EVENTS.ADD_LOG, {
33
- log: { level: 'INFO', message: 'message' },
34
- suite: 'suite',
35
- });
36
- });
37
-
38
- it('addLaunchLog should trigger process.emit with correct parameters', () => {
39
- spyOn(process, 'emit');
40
-
41
- PublicReportingAPI.addLaunchLog({ level: 'INFO', message: 'message' });
42
-
43
- expect(process.emit).toHaveBeenCalledWith(EVENTS.ADD_LAUNCH_LOG, { level: 'INFO', message: 'message' });
44
- });
45
-
46
- it('setTestCaseId should trigger process.emit with correct parameters', () => {
47
- spyOn(process, 'emit');
48
-
49
- PublicReportingAPI.setTestCaseId('testCaseId', 'suite');
50
-
51
- expect(process.emit).toHaveBeenCalledWith(EVENTS.SET_TEST_CASE_ID, {
52
- testCaseId: 'testCaseId',
53
- suite: 'suite',
54
- });
55
- });
56
-
57
- it('setLaunchStatus should trigger process.emit with correct parameters', () => {
58
- spyOn(process, 'emit');
59
-
60
- PublicReportingAPI.setLaunchStatus('passed');
61
-
62
- expect(process.emit).toHaveBeenCalledWith(EVENTS.SET_LAUNCH_STATUS, 'passed');
63
- });
64
-
65
- it('setStatus should trigger process.emit with correct parameters', () => {
66
- spyOn(process, 'emit');
67
-
68
- PublicReportingAPI.setStatus('passed', 'suite');
69
-
70
- expect(process.emit).toHaveBeenCalledWith(EVENTS.SET_STATUS, {
71
- status: 'passed',
72
- suite: 'suite',
73
- });
74
- });
75
- });