Skip to content

Commit eedff22

Browse files
committed
test: options.mediaType.format and options.mediaType.previews
1 parent 9950f5f commit eedff22

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

test/defaults-test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('endpoint.defaults()', () => {
4444
const mock = fetchMock.sandbox()
4545
.get('https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos', [], {
4646
headers: {
47-
accept: 'application/vnd.github.v3+json',
47+
accept: 'application/vnd.foo-preview.raw+json,application/vnd.bar-preview.raw+json',
4848
authorization: 'token 0000000000000000000000000000000000000001',
4949
'user-agent': 'myApp/1.2.3'
5050
}
@@ -55,6 +55,10 @@ describe('endpoint.defaults()', () => {
5555
headers: {
5656
'user-agent': 'myApp/1.2.3'
5757
},
58+
mediaType: {
59+
format: 'raw+json',
60+
previews: ['foo', 'bar']
61+
},
5862
org: 'my-project',
5963
request: {
6064
fetch: mock

test/request-test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,4 +509,64 @@ describe('octokitRequest()', () => {
509509
expect(result.data).to.equal('funk')
510510
})
511511
})
512+
513+
it('options.mediaType.format', function () {
514+
const mock = fetchMock.sandbox()
515+
.mock('https://api.github.com/repos/octokit/request.js/issues/1', 'ok', {
516+
headers: {
517+
accept: 'application/vnd.github.v3.raw+json',
518+
authorization: 'token 0000000000000000000000000000000000000001',
519+
'user-agent': userAgent
520+
}
521+
})
522+
523+
return octokitRequest('GET /repos/:owner/:repo/issues/:number', {
524+
headers: {
525+
authorization: 'token 0000000000000000000000000000000000000001'
526+
},
527+
mediaType: {
528+
format: 'raw+json'
529+
},
530+
owner: 'octokit',
531+
repo: 'request.js',
532+
number: 1,
533+
request: {
534+
fetch: mock
535+
}
536+
})
537+
538+
.then(response => {
539+
expect(response.data).to.equal('ok')
540+
})
541+
})
542+
543+
it('options.mediaType.previews', function () {
544+
const mock = fetchMock.sandbox()
545+
.mock('https://api.github.com/repos/octokit/request.js/issues/1', 'ok', {
546+
headers: {
547+
accept: 'application/vnd.foo-preview+json,application/vnd.bar-preview+json',
548+
authorization: 'token 0000000000000000000000000000000000000001',
549+
'user-agent': userAgent
550+
}
551+
})
552+
553+
return octokitRequest('GET /repos/:owner/:repo/issues/:number', {
554+
headers: {
555+
authorization: 'token 0000000000000000000000000000000000000001'
556+
},
557+
mediaType: {
558+
previews: ['foo', 'bar']
559+
},
560+
owner: 'octokit',
561+
repo: 'request.js',
562+
number: 1,
563+
request: {
564+
fetch: mock
565+
}
566+
})
567+
568+
.then(response => {
569+
expect(response.data).to.equal('ok')
570+
})
571+
})
512572
})

0 commit comments

Comments
 (0)