import nock from 'nock' import chai, { expect } from 'chai' import chaiAsPromised from 'chai-as-promised' chai.use(chaiAsPromised) import * as utils from '../utils' describe('.ensureArray', () => { it('should convert a non-array into an array as the only index', () => { const str = 'str123' expect(Array.isArray(utils.ensureArray(str))).to.be.true }) }) describe('.prepareForQueryParams', () => { it('should return the correct results depending on the conditions', () => { let url = utils.prepareForQueryParams('/v2/appointment?apple=red&') expect(url).to.equal('/v2/appointment?apple=red&') url = utils.prepareForQueryParams(url + '/') expect(url).to.equal('/v2/appointment?apple=red&') url = utils.prepareForQueryParams('/v2/appointment?apple=red/') expect(url).to.equal('/v2/appointment?apple=red&') url = utils.prepareForQueryParams('/v2/appointment?apple=red?') expect(url).to.equal('/v2/appointment?apple=red?') url = utils.prepareForQueryParams('/v2/appointment/') expect(url).to.equal('/v2/appointment/?') url = utils.prepareForQueryParams('/v2/appointment') expect(url).to.equal('/v2/appointment?') }) })