1
1
import '@testing-library/jest-dom/extend-expect' ;
2
2
3
3
import stargazed , {
4
- htmlEscapeTable ,
5
- getReadmeTemplate ,
6
- buildReadmeContent ,
7
- // writeReadmeContent,
4
+ htmlEscapeTable ,
5
+ getReadmeTemplate ,
6
+ buildReadmeContent ,
7
+ // writeReadmeContent,
8
8
} from '../source/stargazed' ;
9
- import { validate } from '../source/utils/validate' ;
9
+ import { validate } from '../source/utils/validate' ;
10
10
// import { flashError } from '../source/utils/message';
11
- import { buildWorkflowContent } from '../source/utils/repo' ;
11
+ import { buildWorkflowContent } from '../source/utils/repo' ;
12
12
13
13
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,
21
21
} from '../mock/contentInput' ;
22
22
23
23
const pckg = require ( '../package.json' ) ;
@@ -26,84 +26,97 @@ const pckg = require('../package.json');
26
26
// ? research a way to test something as it exits?
27
27
28
28
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 ( '<' ) ;
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 ( '>' ) ;
45
+ expect ( htmlEscapeTable [ '<' ] ) . toBe ( '<' ) ;
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
+ } ) ;
109
122
} ) ;
0 commit comments