Files
shields/services/jira/jira-sprint.spec.js
chris48s 13d75e0607 upgrade to prettier 2 (#5051)
* arrowParens: avoid
* remove trailingComma setting
2020-05-05 21:07:43 +01:00

52 lines
1.2 KiB
JavaScript

'use strict'
const { expect } = require('chai')
const nock = require('nock')
const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers')
const JiraSprint = require('./jira-sprint.service')
const {
user,
pass,
host,
config,
sprintId,
sprintQueryString,
} = require('./jira-test-helpers')
describe('JiraSprint', function () {
cleanUpNockAfterEach()
it('sends the auth information as configured', async function () {
const scope = nock(`https://${host}`)
.get('/jira/rest/api/2/search')
.query(sprintQueryString)
// This ensures that the expected credentials are actually being sent with the HTTP request.
// Without this the request wouldn't match and the test would fail.
.basicAuth({ user, pass })
.reply(200, {
total: 2,
issues: [
{ fields: { resolution: { name: 'done' } } },
{ fields: { resolution: { name: 'Unresolved' } } },
],
})
expect(
await JiraSprint.invoke(
defaultContext,
config,
{
sprintId,
},
{ baseUrl: `https://${host}/jira` }
)
).to.deep.equal({
label: 'completion',
message: '50%',
color: 'orange',
})
scope.done()
})
})