Skip to content

Commit

Permalink
fix: missing verification and tests (#6)
Browse files Browse the repository at this point in the history
* add tests

* add verification
  • Loading branch information
mvandiest authored Nov 8, 2016
1 parent beb1f01 commit 5af975f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ const validators = {
throw new InvalidArgumentError('id')
}
},
entity_byHostname(hostname) {
if(isInvalidString(hostname)) {
throw new InvalidArgumentError('hostname');
}
},
content_getMany(type, filter) {
if(isInvalidString(type)) {
throw new InvalidArgumentError('type')
Expand Down
21 changes: 21 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,27 @@ describe('forteApi', () => {

describe('api.organizations', () => {

describe('.getOneByHostname(hostname)', () => {
const invalidHostnames = [null, undefined, {}]
invalidHostnames.forEach((hostname) => {
it(`should throw for hostname '${hostname}'`, () => {
assert.throws(() => { api.organizations.getOneByHostname(hostname) }, InvalidArgumentError)
})
})

const validHostnames = ['www.domain.com', 'dealer.domain.com']
validHostnames.forEach((hostname) => {
const expected = expectedUri(ApiPaths.organizations.getOneByHostname(hostname))
it(`should GET uri: ${expected}`, () => {
const getOneByHostnameMock = mockapi.get(expected, 200)

return api.organizations.getOneByHostname(hostname).then(() => {
getOneByHostnameMock.done()
})
})
})
})

describe('.getMany(filter)', () => {
const invalidFilters = [null, undefined, {}]
invalidFilters.forEach((filter) => {
Expand Down

0 comments on commit 5af975f

Please sign in to comment.