@@ -21,6 +21,42 @@ describe('name-format Unit Tests', () => {
2121 expect ( response . node ) . toStrictEqual ( 'name' ) ;
2222 expect ( response . lintMessage ) . toStrictEqual ( 'Format should be all lowercase' ) ;
2323 } ) ;
24+
25+ test ( 'exceeds max length - LintIssue object should be returned' , ( ) => {
26+ const packageJsonData = {
27+ name : 'a' . padStart ( 215 )
28+ } ;
29+ const response = lint ( packageJsonData , 'error' ) ;
30+
31+ expect ( response . lintId ) . toStrictEqual ( 'name-format' ) ;
32+ expect ( response . severity ) . toStrictEqual ( 'error' ) ;
33+ expect ( response . node ) . toStrictEqual ( 'name' ) ;
34+ expect ( response . lintMessage ) . toStrictEqual ( 'name should be less than or equal to 214 characters.' ) ;
35+ } ) ;
36+
37+ test ( 'starts with . - LintIssue object should be returned' , ( ) => {
38+ const packageJsonData = {
39+ name : '.lowercase'
40+ } ;
41+ const response = lint ( packageJsonData , 'error' ) ;
42+
43+ expect ( response . lintId ) . toStrictEqual ( 'name-format' ) ;
44+ expect ( response . severity ) . toStrictEqual ( 'error' ) ;
45+ expect ( response . node ) . toStrictEqual ( 'name' ) ;
46+ expect ( response . lintMessage ) . toStrictEqual ( 'name should not start with . or _' ) ;
47+ } ) ;
48+
49+ test ( 'starts with _ - LintIssue object should be returned' , ( ) => {
50+ const packageJsonData = {
51+ name : '_lowercase'
52+ } ;
53+ const response = lint ( packageJsonData , 'error' ) ;
54+
55+ expect ( response . lintId ) . toStrictEqual ( 'name-format' ) ;
56+ expect ( response . severity ) . toStrictEqual ( 'error' ) ;
57+ expect ( response . node ) . toStrictEqual ( 'name' ) ;
58+ expect ( response . lintMessage ) . toStrictEqual ( 'name should not start with . or _' ) ;
59+ } ) ;
2460 } ) ;
2561
2662 describe ( 'when package.json does not have node' , ( ) => {
0 commit comments