Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxingloh committed Jan 14, 2021
1 parent 8d10c88 commit a176f82
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 38 deletions.
13 changes: 10 additions & 3 deletions __tests__/labeler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,18 @@ describe('main core and context', () => {
}
},
pulls: {
listCommits(params) {
return {
data: []
listCommits: {
endpoint: {
// @ts-ignore
merge() {
return {}
}
}
}
},
// @ts-ignore
paginate(params): Promise<any[]> {
return Promise.resolve([])
}
}
})
Expand Down
54 changes: 29 additions & 25 deletions __tests__/matcher/commits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ import {Config} from '../../src/config'
async function getMatchedLabels(config: Config): Promise<string[]> {
return await match({
pulls: {
// @ts-ignore
listCommits(params) {
// @ts-ignore
return commits[params.pull_number]
listCommits: {
endpoint: {
// @ts-ignore
merge(params) {
return {pull_number: params.pull_number}
}
}
}
},
// @ts-ignore
paginate(params): Promise<any[]> {
// @ts-ignore
return Promise.resolve(commits[params.pull_number])
}
}, config)
}
Expand All @@ -20,33 +28,29 @@ const config: Config = {
{
label: 'feat',
matcher: {
commits: '^commit: .*'
commits: '^feat: .*'
}
}
]
}

const commits = {
1: {
data: [
{
commit: {message: 'no-commit:'},
},
{
commit: {message: 'feat: commit'},
}
]
},
2: {
data: [
{
commit: {message: 'init'}
},
{
commit: {message: 'commit: yes yes yes'}
}
]
},
1: [
{
commit: {message: 'no-commit:'},
},
{
commit: {message: 'commit: commit'},
}
],
2: [
{
commit: {message: 'init'}
},
{
commit: {message: 'feat: yes yes yes'}
}
],
}

describe('commits', function () {
Expand Down
11 changes: 6 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/matcher/commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export default async function match(
client.pulls.listCommits.endpoint.merge({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
pull_number: number,
pull_number: number
})
);
)

// @ts-ignore
const messages: string[] = responses.map(c => c.commit.message)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const messages: string[] = responses.map((c: any) => c.commit.message)

return matchers
.filter(value => {
Expand Down

0 comments on commit a176f82

Please sign in to comment.