11import {
22 getConventionalCommitTypes ,
3- lintPullRequest ,
3+ isConventionalCommitTitleValid ,
44 isBotIgnored ,
55} from "./lint.js" ;
66import { context } from "@actions/github" ;
@@ -27,7 +27,7 @@ describe("getConvetionalCommitTypes tests", () => {
2727 } ) ;
2828} ) ;
2929
30- describe ( "lintPullRequest tests" , ( ) => {
30+ describe ( "isConventionalCommitTitleValid tests" , ( ) => {
3131 const tests = [
3232 { args : "feat: test" , expected : true } ,
3333 { args : "feat(test): test" , expected : true } ,
@@ -42,7 +42,7 @@ describe("lintPullRequest tests", () => {
4242
4343 tests . forEach ( ( { args, expected } ) => {
4444 it ( `should pass or fail linting ['${ args } ', '${ expected } ']` , async ( ) => {
45- expect ( await lintPullRequest ( args ) ) . toBe ( expected ) ;
45+ expect ( await isConventionalCommitTitleValid ( args ) ) . toBe ( expected ) ;
4646 } ) ;
4747 } ) ;
4848
@@ -54,31 +54,43 @@ describe("lintPullRequest tests", () => {
5454 it ( "should pass if subject matches pattern" , async ( ) => {
5555 vi . spyOn ( core , "getInput" ) . mockReturnValue ( "matching" ) ;
5656
57- expect ( await lintPullRequest ( `feat: matching` ) ) . toBe ( true ) ;
58- expect ( await lintPullRequest ( `feat(test): matching` ) ) . toBe ( true ) ;
57+ expect ( await isConventionalCommitTitleValid ( `feat: matching` ) ) . toBe ( true ) ;
58+ expect ( await isConventionalCommitTitleValid ( `feat(test): matching` ) ) . toBe (
59+ true ,
60+ ) ;
5961 } ) ;
6062
6163 it ( "should fail if subject does not match pattern" , async ( ) => {
6264 vi . spyOn ( core , "getInput" ) . mockReturnValue ( "not-matching" ) ;
6365
64- expect ( await lintPullRequest ( `feat: matching` ) ) . toBe ( false ) ;
65- expect ( await lintPullRequest ( `feat(test): matching` ) ) . toBe ( false ) ;
66+ expect ( await isConventionalCommitTitleValid ( `feat: matching` ) ) . toBe (
67+ false ,
68+ ) ;
69+ expect ( await isConventionalCommitTitleValid ( `feat(test): matching` ) ) . toBe (
70+ false ,
71+ ) ;
6672 } ) ;
6773
6874 it ( "should handle empty subject pattern" , async ( ) => {
6975 vi . spyOn ( core , "getInput" ) . mockReturnValue ( "" ) ;
7076
71- expect ( await lintPullRequest ( "feat: test" ) ) . toBe ( true ) ;
72- expect ( await lintPullRequest ( "feat(test): test" ) ) . toBe ( true ) ;
77+ expect ( await isConventionalCommitTitleValid ( "feat: test" ) ) . toBe ( true ) ;
78+ expect ( await isConventionalCommitTitleValid ( "feat(test): test" ) ) . toBe (
79+ true ,
80+ ) ;
7381 } ) ;
7482
7583 it ( "should handle complex regex" , async ( ) => {
7684 vi . spyOn ( core , "getInput" ) . mockReturnValue (
7785 "[a-z]{1,5}[0-9]{1,3}[!@#]HELLO" ,
7886 ) ;
7987
80- expect ( await lintPullRequest ( "feat: ab11@HELLO" ) ) . toBe ( true ) ;
81- expect ( await lintPullRequest ( "feat(test): ddd999!HELLO" ) ) . toBe ( true ) ;
88+ expect ( await isConventionalCommitTitleValid ( "feat: ab11@HELLO" ) ) . toBe (
89+ true ,
90+ ) ;
91+ expect (
92+ await isConventionalCommitTitleValid ( "feat(test): ddd999!HELLO" ) ,
93+ ) . toBe ( true ) ;
8294 } ) ;
8395 } ) ;
8496} ) ;
0 commit comments