Skip to content

Commit

Permalink
test: plugin API
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Nov 17, 2018
1 parent d908032 commit 9625a58
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/integration/plugins-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const Octokit = require('../../')

require('../mocha-node-setup')

describe('plugins', () => {
it('gets called in constructor', () => {
const MyOctokit = Octokit.plugin((octokit) => {
octokit.foo = 'bar'
})
const myClient = new MyOctokit()
expect(myClient.foo).to.equal('bar')
})

it('it does not override plugins of original constructor', () => {
const MyOctokit = Octokit.plugin((octokit) => {
octokit.foo = 'bar'
})
const myClient = new MyOctokit()
expect(myClient.foo).to.equal('bar')

const client = new Octokit()
expect(client.foo).to.equal(undefined)
})

it('receives client options', () => {
const MyOctokit = Octokit.plugin((octokit, options) => {
expect(options.foo).to.equal('bar')
})
MyOctokit({ foo: 'bar' })
})
})

0 comments on commit 9625a58

Please sign in to comment.