@@ -24,48 +24,72 @@ describe("validate", () => {
2424 } ) ;
2525
2626 describe ( "throws" , ( ) => {
27- [
28- [
29- "[UI//UX:API] xxxx" ,
30- "Invalid type, expected one of Bugfix, Feature, Refactor, Testing, Documentation, VPAT, UI/UX, Dependency, DevDependency. Got UI//UX." ,
31- ] ,
32- [
33- "[UI\\/UX:API] xxxx" ,
34- "Invalid title format, must start with [<TYPE>:<MODULE>] and have space before description." ,
35- ] ,
36- [
37- "[Refactor:RainbowGrades]" ,
38- "Invalid title format, must start with [<TYPE>:<MODULE>] and have space before description." ,
39- ] ,
40- [
41- "[BugFix:TAGrading] xxxx" ,
42- "Invalid type, expected one of Bugfix, Feature, Refactor, Testing, Documentation, VPAT, UI/UX, Dependency, DevDependency. Got BugFix." ,
43- ] ,
44- [
45- "[Dependency:Autograding] xxxx" ,
46- "No allowed module for Dependency, expected [Dependency]. Got [Dependency:Autograding]." ,
47- ] ,
48- [
49- "[SYSADMINACTION][Refactor:Autograding] xxxx" ,
50- "Invalid title format, must start with [<TYPE>:<MODULE>] and have space before description." ,
51- ] ,
27+ describe ( "error parsing" , ( ) => {
5228 [
53- "[DevDependency:Autograding] xxxx" ,
54- "No allowed module for DevDependency, expected [DevDependency]. Got [DevDependency:Autograding]." ,
55- ] ,
56- [
57- "[Bugfix:Submission] a" ,
58- "Too short a message, expected at least 2 characters, got 1 characters." ,
59- ] ,
29+ [
30+ "[Refactor:RainbowGrades]" ,
31+ "Invalid title format, must start with [<TYPE>:<MODULE>] and have space before description." ,
32+ ] ,
33+ [
34+ "[SYSADMINACTION][Refactor:Autograding] xxxx" ,
35+ "Invalid title format, must start with [<TYPE>:<MODULE>] and have space before description." ,
36+ ] ,
37+ ] . forEach ( ( [ value , expectedException ] ) => {
38+ it ( `checkTitle should throw: ${ value } ` , ( ) => {
39+ expect ( ( ) => checkTitle ( value ) ) . to . throw ( expectedException ) ;
40+ } ) ;
41+ } ) ;
42+ } ) ;
43+
44+ describe ( "specific format errors" , ( ) => {
6045 [
61- "[Bugfix:Submission] 01234567890123456789012345678901234567890" ,
62- "Too long a message, expected at most 40 characters, got 41 characters." ,
63- ] ,
64- ] . forEach ( ( [ value , expectedException ] ) => {
65- it ( `checkTitle should throw: ${ value } ` , ( ) => {
66- expect ( ( ) => checkTitle ( value ) ) . to . throw ( expectedException ) ;
46+ [
47+ "[UI//UX:API] xxxx" ,
48+ "Invalid type, expected one of Bugfix, Feature, Refactor, Testing, Documentation, VPAT, UI/UX, Dependency, DevDependency. Got UI//UX." ,
49+ ] ,
50+ [
51+ "[UI\\/UX:API] xxxx" ,
52+ "Invalid type, expected one of Bugfix, Feature, Refactor, Testing, Documentation, VPAT, UI/UX, Dependency, DevDependency. Got UI\\/UX." ,
53+ ] ,
54+ [
55+ "[BugFix:TAGrading] xxxx" ,
56+ "Invalid type, expected one of Bugfix, Feature, Refactor, Testing, Documentation, VPAT, UI/UX, Dependency, DevDependency. Got BugFix." ,
57+ ] ,
58+ [
59+ "[Dependency:Autograding] xxxx" ,
60+ "No allowed module for Dependency, expected [Dependency]. Got [Dependency:Autograding]." ,
61+ ] ,
62+ [
63+ "[DevDependency:Autograding] xxxx" ,
64+ "No allowed module for DevDependency, expected [DevDependency]. Got [DevDependency:Autograding]." ,
65+ ] ,
66+ [
67+ "[Bugfix:Submission] a" ,
68+ "Too short a message, expected at least 2 characters, got 1 characters." ,
69+ ] ,
70+ [
71+ "[Bugfix:Submission] 01234567890123456789012345678901234567890" ,
72+ "Too long a message, expected at most 40 characters, got 41 characters." ,
73+ ] ,
74+ ] . forEach ( ( [ value , expectedException ] ) => {
75+ it ( `checkTitle should throw: ${ value } ` , ( ) => {
76+ expect ( ( ) => checkTitle ( value ) ) . to . throw (
77+ `Errors detected in title:\n - ${ expectedException } `
78+ ) ;
79+ } ) ;
6780 } ) ;
6881 } ) ;
82+
83+ it ( "should show multiple format errors at once" , ( ) => {
84+ expect ( ( ) =>
85+ checkTitle (
86+ "[Fake:Error] this message is much too long and it should be shortened"
87+ )
88+ ) . to . throw ( `Errors detected in title:
89+ - Invalid type, expected one of Bugfix, Feature, Refactor, Testing, Documentation, VPAT, UI/UX, Dependency, DevDependency. Got Fake.
90+ - Invalid module, expected one of Submission, Autograding, Forum, Notifications, TAGrading, InstructorUI, SubminiPolls, HelpQueue, CourseMaterials, Plagiarism, RainbowGrades, System, Developer, API. Got Error.
91+ - Too long a message, expected at most 40 characters, got 56 characters.` ) ;
92+ } ) ;
6993 } ) ;
7094 } ) ;
7195} ) ;
0 commit comments