Skip to content

Commit

Permalink
test(update): use new config handling API (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
Silas Boyd-Wickizer committed May 19, 2019
1 parent 1fd10c4 commit 669352b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
22 changes: 12 additions & 10 deletions lib/swagger-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const expect = require('chai').expect
const nock = require('nock')

const Client = require('./swagger-client').Client
const Request = require('./backends/request')

const url = 'http://mock.kube.api'
const config = { url }

describe('lib.swagger-client', () => {
describe('.Client', () => {
Expand All @@ -28,8 +30,8 @@ describe('lib.swagger-client', () => {
})

it('creates a dynamically generated client', done => {
const config = { url }
const client = new Client({ config })
const backend = new Request(config)
const client = new Client({ backend })
client.loadSpec()
.then(() => {
expect(client.api.get).is.a('function')
Expand Down Expand Up @@ -59,8 +61,8 @@ describe('lib.swagger-client', () => {
})

it('creates a dynamically generated client', (done) => {
const config = { url }
const client = new Client({ config })
const backend = new Request(config)
const client = new Client({ backend })
client.loadSpec()
.then(() => {
expect(client.api.get).is.a('function')
Expand Down Expand Up @@ -90,8 +92,8 @@ describe('lib.swagger-client', () => {
})

it('returns an error message with the status code', (done) => {
const config = { url }
const client = new Client({ config })
const backend = new Request(config)
const client = new Client({ backend })
client.loadSpec()
.then(() => {
const err = new Error('This test should have caused an error')
Expand Down Expand Up @@ -124,8 +126,8 @@ describe('lib.swagger-client', () => {
})

it('returns an error message with the status code', (done) => {
const config = { url }
const client = new Client({ config })
const backend = new Request(config)
const client = new Client({ backend })
client.loadSpec()
.then(() => {
const err = new Error('This test should have caused an error')
Expand All @@ -141,8 +143,8 @@ describe('lib.swagger-client', () => {

describe('.constructor', () => {
it('creates a dynamically generated client synchronously based on version', () => {
const options = { config: {}, version: '1.9' }
const client = new Client(options)
const backend = new Request(config)
const client = new Client({ backend, version: '1.9' })
expect(client.api.get).is.a('function')
})

Expand Down
3 changes: 2 additions & 1 deletion scripts/typings.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ function main (args) {
}
const interfaces = []

const client = new Client({ spec, config: {} })
const backend = {}
const client = new Client({ backend, spec })
walk(client, interfaces)

const templateOptions = {
Expand Down

0 comments on commit 669352b

Please sign in to comment.