Skip to content

Commit 1338134

Browse files
fix: apply new prettier settings
1 parent f70c94e commit 1338134

File tree

12 files changed

+748
-668
lines changed

12 files changed

+748
-668
lines changed

Diff for: __tests__/index.test.js

+106-93
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import '@testing-library/jest-dom/extend-expect';
22

33
import stargazed, {
4-
htmlEscapeTable,
5-
getReadmeTemplate,
6-
buildReadmeContent,
7-
// writeReadmeContent,
4+
htmlEscapeTable,
5+
getReadmeTemplate,
6+
buildReadmeContent,
7+
// writeReadmeContent,
88
} from '../source/stargazed';
9-
import { validate } from '../source/utils/validate';
9+
import {validate} from '../source/utils/validate';
1010
// import { flashError } from '../source/utils/message';
11-
import { buildWorkflowContent } from '../source/utils/repo';
11+
import {buildWorkflowContent} from '../source/utils/repo';
1212

1313
import {
14-
inputContent,
15-
badInputToken,
16-
badInputRepo,
17-
badInputMessage,
18-
badInputUsername,
19-
goodInputValidation,
20-
// goodInputFalseValidation,
14+
inputContent,
15+
badInputToken,
16+
badInputRepo,
17+
badInputMessage,
18+
badInputUsername,
19+
goodInputValidation,
20+
// goodInputFalseValidation,
2121
} from '../mock/contentInput';
2222

2323
const pckg = require('../package.json');
@@ -26,84 +26,97 @@ const pckg = require('../package.json');
2626
// ? research a way to test something as it exits?
2727

2828
describe('Commands functional tests', () => {
29-
// test('should check basic input behavior of core function', async () => {
30-
// const response = await stargazed({
31-
// username: 'Jean-Luc-Picard',
32-
// token: '1701-D',
33-
// repo: 'Enterprise',
34-
// message: 'Make it so...',
35-
// sort: true,
36-
// workflow: true,
37-
// version: true,
38-
// });
39-
40-
// expect(response).toBe(pckg.version);
41-
// });
42-
43-
test('should static check htmlEscapeTable mlibing', async () => {
44-
expect(htmlEscapeTable['>']).toBe('>');
45-
expect(htmlEscapeTable['<']).toBe('&lt;');
46-
expect(htmlEscapeTable['[|]']).toBe('\\|');
47-
expect(htmlEscapeTable['\n']).toBe('');
48-
});
49-
50-
test('should show positive getReadmeTemplate() outcome', async () => {
51-
const template = await getReadmeTemplate();
52-
53-
expect(template).toBeTruthy();
54-
expect(template.slice(0, 9)).toBe('# Awesome');
55-
expect(template.length > 10).toBe(true);
56-
});
57-
58-
test('should show positive buildReadmeContent(context) outcome', async () => {
59-
const response = await buildReadmeContent(inputContent);
60-
61-
expect(response.match('Klingon')[0]).toBe('Klingon');
62-
expect(response.match('English')[0]).toBe('English');
63-
expect(response.match('Vulcan')[0]).toBe('Vulcan');
64-
expect(response.match('JavaScript')[0]).toBe('JavaScript');
65-
});
66-
67-
test('should show that the data is mlibed for workflow content', async () => {
68-
const response = await buildWorkflowContent('Jean-Luc-Picard', 'mock-repository');
69-
70-
expect(response).toBeTruthy();
71-
expect(response).toContain('cron');
72-
expect(response).toContain('Jean-Luc-Picard');
73-
expect(response.length > 0).toBe(true);
74-
});
75-
76-
test('should check validation good input/output - positive branch return null', async () => {
77-
expect(validate(goodInputValidation)).toBeNull();
78-
});
79-
80-
// test('should check validation good input with all false options - positive branch return null', async () => {
81-
// expect(validate(goodInputFalseValidation)).toBeNull();
82-
// });
83-
84-
test('should check bad inputs in validation behavior/paths', () => {
85-
const badTokenRes = () => {
86-
throw validate(badInputToken);
87-
};
88-
89-
expect(badTokenRes).toThrowError(new TypeError(`invalid option. Token must be a string primitive.`));
90-
91-
const badUsernameRes = () => {
92-
throw validate(badInputUsername);
93-
};
94-
95-
expect(badUsernameRes).toThrowError(new TypeError(`invalid option. Username must be a string primitive.`));
96-
97-
const badRepoRes = () => {
98-
throw validate(badInputRepo);
99-
};
100-
101-
expect(badRepoRes).toThrowError(new TypeError('invalid option. Repo name must be a string primitive.'));
102-
103-
const badMessageRes = () => {
104-
throw validate(badInputMessage);
105-
};
106-
107-
expect(badMessageRes).toThrowError(new TypeError('invalid option. Commit message must be a string primitive.'));
108-
});
29+
// test('should check basic input behavior of core function', async () => {
30+
// const response = await stargazed({
31+
// username: 'Jean-Luc-Picard',
32+
// token: '1701-D',
33+
// repo: 'Enterprise',
34+
// message: 'Make it so...',
35+
// sort: true,
36+
// workflow: true,
37+
// version: true,
38+
// });
39+
40+
// expect(response).toBe(pckg.version);
41+
// });
42+
43+
test('should static check htmlEscapeTable mlibing', async () => {
44+
expect(htmlEscapeTable['>']).toBe('&gt;');
45+
expect(htmlEscapeTable['<']).toBe('&lt;');
46+
expect(htmlEscapeTable['[|]']).toBe('\\|');
47+
expect(htmlEscapeTable['\n']).toBe('');
48+
});
49+
50+
test('should show positive getReadmeTemplate() outcome', async () => {
51+
const template = await getReadmeTemplate();
52+
53+
expect(template).toBeTruthy();
54+
expect(template.slice(0, 9)).toBe('# Awesome');
55+
expect(template.length > 10).toBe(true);
56+
});
57+
58+
test('should show positive buildReadmeContent(context) outcome', async () => {
59+
const response = await buildReadmeContent(inputContent);
60+
61+
expect(response.match('Klingon')[0]).toBe('Klingon');
62+
expect(response.match('English')[0]).toBe('English');
63+
expect(response.match('Vulcan')[0]).toBe('Vulcan');
64+
expect(response.match('JavaScript')[0]).toBe('JavaScript');
65+
});
66+
67+
test('should show that the data is mlibed for workflow content', async () => {
68+
const response = await buildWorkflowContent(
69+
'Jean-Luc-Picard',
70+
'mock-repository'
71+
);
72+
73+
expect(response).toBeTruthy();
74+
expect(response).toContain('cron');
75+
expect(response).toContain('Jean-Luc-Picard');
76+
expect(response.length > 0).toBe(true);
77+
});
78+
79+
test('should check validation good input/output - positive branch return null', async () => {
80+
expect(validate(goodInputValidation)).toBeNull();
81+
});
82+
83+
// test('should check validation good input with all false options - positive branch return null', async () => {
84+
// expect(validate(goodInputFalseValidation)).toBeNull();
85+
// });
86+
87+
test('should check bad inputs in validation behavior/paths', () => {
88+
const badTokenRes = () => {
89+
throw validate(badInputToken);
90+
};
91+
92+
expect(badTokenRes).toThrowError(
93+
new TypeError(`invalid option. Token must be a string primitive.`)
94+
);
95+
96+
const badUsernameRes = () => {
97+
throw validate(badInputUsername);
98+
};
99+
100+
expect(badUsernameRes).toThrowError(
101+
new TypeError(`invalid option. Username must be a string primitive.`)
102+
);
103+
104+
const badRepoRes = () => {
105+
throw validate(badInputRepo);
106+
};
107+
108+
expect(badRepoRes).toThrowError(
109+
new TypeError('invalid option. Repo name must be a string primitive.')
110+
);
111+
112+
const badMessageRes = () => {
113+
throw validate(badInputMessage);
114+
};
115+
116+
expect(badMessageRes).toThrowError(
117+
new TypeError(
118+
'invalid option. Commit message must be a string primitive.'
119+
)
120+
);
121+
});
109122
});

Diff for: mock/contentInput.js

+57-55
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,75 @@
11
export const inputContent = {
2-
languages: ['Klingon', 'English', 'Vulcan', 'JavaScript'],
3-
username: 'Jean-Luc-Picard',
4-
count: Object.keys([1, 2, 3, 4]).length,
5-
stargazed: {
6-
Klingon: [
7-
[1, 'URL', 'description', 'author', 1000],
8-
[2, 'URL', 'description', 'author', 2000],
9-
],
10-
English: [[2, 'URL', 'description', 'author', 2000]],
11-
Vulcan: [[3, 'URL', 'description', 'author', 3000]],
12-
JavaScript: [[4, 'URL', 'description', 'author', 4000]],
13-
},
14-
date: `${new Date().getDate()}--${new Date().getMonth() + 1}--${new Date().getFullYear()}`,
2+
languages: ['Klingon', 'English', 'Vulcan', 'JavaScript'],
3+
username: 'Jean-Luc-Picard',
4+
count: Object.keys([1, 2, 3, 4]).length,
5+
stargazed: {
6+
Klingon: [
7+
[1, 'URL', 'description', 'author', 1000],
8+
[2, 'URL', 'description', 'author', 2000],
9+
],
10+
English: [[2, 'URL', 'description', 'author', 2000]],
11+
Vulcan: [[3, 'URL', 'description', 'author', 3000]],
12+
JavaScript: [[4, 'URL', 'description', 'author', 4000]],
13+
},
14+
date: `${new Date().getDate()}--${
15+
new Date().getMonth() + 1
16+
}--${new Date().getFullYear()}`,
1517
};
1618

1719
export const goodInputValidation = {
18-
username: 'Jean-Luc-Picard',
19-
token: '1701-D',
20-
repo: 'Enterprise',
21-
message: 'Make it so...',
22-
sort: true,
23-
workflow: true,
24-
version: true,
20+
username: 'Jean-Luc-Picard',
21+
token: '1701-D',
22+
repo: 'Enterprise',
23+
message: 'Make it so...',
24+
sort: true,
25+
workflow: true,
26+
version: true,
2527
};
2628
export const goodInputFalseValidation = {
27-
username: 'Jean-Luc-Picard',
28-
token: '1701-D',
29-
repo: 'Enterprise',
30-
message: 'Make it so...',
31-
sort: false,
32-
workflow: false,
33-
version: false,
29+
username: 'Jean-Luc-Picard',
30+
token: '1701-D',
31+
repo: 'Enterprise',
32+
message: 'Make it so...',
33+
sort: false,
34+
workflow: false,
35+
version: false,
3436
};
3537

3638
export const badInputToken = {
37-
username: 'Jean-Luc-Picard',
38-
token: null,
39-
repo: 'Enterprise',
40-
message: 'Make it so...',
41-
sort: true,
42-
workflow: true,
43-
version: true,
39+
username: 'Jean-Luc-Picard',
40+
token: null,
41+
repo: 'Enterprise',
42+
message: 'Make it so...',
43+
sort: true,
44+
workflow: true,
45+
version: true,
4446
};
4547

4648
export const badInputUsername = {
47-
username: null,
48-
token: '1701-D',
49-
repo: 'Enterprise',
50-
message: 'Make it so...',
51-
sort: true,
52-
workflow: true,
53-
version: true,
49+
username: null,
50+
token: '1701-D',
51+
repo: 'Enterprise',
52+
message: 'Make it so...',
53+
sort: true,
54+
workflow: true,
55+
version: true,
5456
};
5557

5658
export const badInputRepo = {
57-
username: 'Jean Luc Picard',
58-
token: '1701-D',
59-
repo: null,
60-
message: 'Make it so...',
61-
sort: true,
62-
workflow: true,
63-
version: true,
59+
username: 'Jean Luc Picard',
60+
token: '1701-D',
61+
repo: null,
62+
message: 'Make it so...',
63+
sort: true,
64+
workflow: true,
65+
version: true,
6466
};
6567
export const badInputMessage = {
66-
username: 'Jean Luc Picard',
67-
token: '1701-D',
68-
repo: 'Enterprise',
69-
message: null,
70-
sort: true,
71-
workflow: true,
72-
version: true,
68+
username: 'Jean Luc Picard',
69+
token: '1701-D',
70+
repo: 'Enterprise',
71+
message: null,
72+
sort: true,
73+
workflow: true,
74+
version: true,
7375
};

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"validate.io-string-primitive": "^1.0.1"
5555
},
5656
"devDependencies": {
57-
"@abhijithvijayan/eslint-config": "0.14.1",
57+
"@abhijithvijayan/eslint-config": "^1.3.0",
5858
"@babel/core": "^7.9.0",
5959
"@babel/preset-env": "^7.9.0",
6060
"@testing-library/jest-dom": "^4.2.4",

0 commit comments

Comments
 (0)