-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathyoutrack-base.spec.js
48 lines (42 loc) · 1.27 KB
/
youtrack-base.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import Joi from 'joi'
import { expect } from 'chai'
import nock from 'nock'
import { cleanUpNockAfterEach, defaultContext } from '../test-helpers.js'
import YoutrackBase from './youtrack-base.js'
class DummyYoutrackService extends YoutrackBase {
static route = { base: 'fake-base' }
async handle() {
const data = await this.fetch({
schema: Joi.any(),
url: 'https://shields.youtrack.cloud/api/issuesGetter/count?fields=count',
})
return { message: data.message }
}
}
describe('YoutrackBase', function () {
describe('auth', function () {
cleanUpNockAfterEach()
const config = {
public: {
services: {
youtrack: {
authorizedOrigins: ['https://shields.youtrack.cloud'],
},
},
},
private: {
youtrack_token: 'fake-key',
},
}
it('sends the auth information as configured', async function () {
const scope = nock('https://shields.youtrack.cloud')
.get('/api/issuesGetter/count?fields=count')
.matchHeader('Authorization', 'Bearer fake-key')
.reply(200, { message: 'fake message' })
expect(
await DummyYoutrackService.invoke(defaultContext, config, {}),
).to.not.have.property('isError')
scope.done()
})
})
})