Skip to content

Commit dc8c33f

Browse files
authored
Merge pull request #99 from austinandrews/feature
Feature
2 parents a8f66c2 + add1fcf commit dc8c33f

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: node_js
22

33
node_js:
4-
- node
5-
4+
- 16
5+
66
env:
77
global: PATH=/opt/python/3.7.1/bin:$PATH
88

__tests__/ProcessLogHelper.test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import {makeArrayOfObjects, buildOptionsObj} from '../src/components/helper/processLogHelper.js';
2+
import React from 'react';
3+
4+
describe('makeArrayOfObjects', () => {
5+
it('returns an array', () => {
6+
const string = `Hello from Docker!
7+
8+
This message shows that your installation appears to be working correctly.
9+
10+
`;
11+
const result = makeArrayOfObjects(string);
12+
expect(result).toBeInstanceOf(Array);
13+
});
14+
15+
it('each element in returned array is of type object', () => {
16+
const processLog = 'this is the timestamp\nthis is the log message\nthis is the second timestamp\nthis is the second log message';
17+
const result = makeArrayOfObjects(processLog);
18+
19+
let output = false;
20+
21+
if(result.every((element) => typeof element === 'object')){
22+
output = true;
23+
}
24+
25+
expect(output).toEqual(true);
26+
});
27+
28+
it('each object in returned array has timeStamp and logMsg properties', () => {
29+
const processLog = 'this_is_the_first_timestampZ this is the first log message\nthere is no second time stamp but there is a second log message';
30+
const result = makeArrayOfObjects(processLog);
31+
32+
let output = false;
33+
34+
if(result.every((element) =>
35+
element.timeStamp && element.logMsg
36+
)){
37+
output = true;
38+
}
39+
40+
expect(output).toEqual(true);
41+
});
42+
43+
it('log lines without timestamp will have "----" as value of timestamp property, otherwise the value will be timestamp', () => {
44+
const processLog = 'this_is_the_first_timestampZ this is the first log message\nthere is no second time stamp but there is a second log message\n \n ';
45+
const result = makeArrayOfObjects(processLog);
46+
47+
expect(result[0].timeStamp).toEqual('this_is_the_first_timestampZ');
48+
expect(result[0].logMsg).toEqual('this is the first log message');
49+
expect(result[1].timeStamp).toEqual('----');
50+
expect(result[1].logMsg).toEqual('there is no second time stamp but there is a second log message');
51+
});
52+
53+
it('when passed empty string, should return {timeStamp: \'\', logMsg: \'\'}', () => {
54+
55+
const result = makeArrayOfObjects('');
56+
57+
expect(result[0].timeStamp).toEqual('');
58+
expect(result[0].logMsg).toEqual('');
59+
});
60+
});

src/components/tabs/Yml.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const Yml = () => {
9696
const directoryPath = filePath.replace(ymlRegex, '');
9797
setFilePath(directoryPath);
9898
setYmlFileName(ymlFileName);
99-
};
99+
}
100100
};
101101
}, []);
102102

0 commit comments

Comments
 (0)