mirror of
https://github.com/status-im/github-comment-manager.git
synced 2025-02-19 20:58:09 +00:00
add test for formatting of comments
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
27da010e8a
commit
203d5f2072
@ -7,22 +7,59 @@ import Comments from '../src/comments'
|
||||
|
||||
let comments, client, builds
|
||||
|
||||
const BUILDS = [
|
||||
{
|
||||
id: 'ID-1',
|
||||
commit: 'COMMIT-1',
|
||||
success: true,
|
||||
platform: 'PLATFORM-1',
|
||||
duration: 'DURATION-1',
|
||||
url: 'URL-1',
|
||||
pkg_url: 'PKG_URL-1',
|
||||
},
|
||||
{
|
||||
id: 'ID-2',
|
||||
commit: 'COMMIT-2',
|
||||
success: false,
|
||||
platform: 'PLATFORM-2',
|
||||
duration: 'DURATION-2',
|
||||
url: 'URL-2',
|
||||
pkg_url: 'PKG_URL-2',
|
||||
},
|
||||
]
|
||||
|
||||
/* expected comment based on given builds */
|
||||
const COMMENT = `
|
||||
### Jenkins Builds
|
||||
| :grey_question: | Commit | :hash: | Finished | Duration | Platform | Result |
|
||||
|-|-|-|-|-|-|-|
|
||||
| :heavy_check_mark: | COMMIT-1 | [ID-1](URL-1) | Invalid Date | DURATION-1 | \`PLATFORM-1\` | [:package: package](PKG_URL-1) |
|
||||
| | | | | | | |
|
||||
| :x: | COMMIT-2 | [ID-2](URL-2) | Invalid Date | DURATION-2 | \`PLATFORM-2\` | [:page_facing_up: build log](PKG_URL-2consoleText) |
|
||||
`
|
||||
|
||||
describe('Comments', () => {
|
||||
before(() => {
|
||||
beforeEach(() => {
|
||||
//client = sinon.createStubInstance(Octokit, {what: 2})
|
||||
builds = sinon.createStubInstance(Builds, {
|
||||
getBuilds: []
|
||||
getBuilds: BUILDS,
|
||||
})
|
||||
comments = new Comments(client, 'owner', 'repo', builds)
|
||||
})
|
||||
|
||||
describe('renderComment', () => {
|
||||
it('should fail with no builds', async () => {
|
||||
builds.getBuilds.returns([])
|
||||
try {
|
||||
await comments.renderComment('PR')
|
||||
} catch(err) {
|
||||
expect(err.message).to.eq('No builds exist for this PR')
|
||||
}
|
||||
})
|
||||
|
||||
it('should render correctly', async () => {
|
||||
let body = await comments.renderComment('PR')
|
||||
expect(body).to.eq(COMMENT)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user