Skip to content

Commit

Permalink
Add tests for registering service with same url and/or method
Browse files Browse the repository at this point in the history
  • Loading branch information
rthewhite committed Oct 23, 2017
1 parent 4a9bf49 commit 57da1ad
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/http-server.spec.ts
Expand Up @@ -197,6 +197,49 @@ describe('Http server', () => {
const url = getSpy.getCall(1).args[0];
expect(url).to.equal('/testing/foobar');
});

it('should not throw an error when the same url with a different method is being registered', () => {
const serviceOne = {
method: HttpMethod.GET,
url: 'foobar',
handler: () => { return new Promise((resolve, reject) => {})}
};

const serviceTwo = {
method: HttpMethod.POST,
url: 'foobar',
handler: () => { return new Promise((resolve, reject) => {})}
};

function register() {
httpServer.registerService(serviceOne);
httpServer.registerService(serviceTwo);
}

expect(register).to.not.throw();
});


it('should throw an error when the same method on the same url is being registered', () => {
const serviceOne = {
method: HttpMethod.POST,
url: 'foobar',
handler: () => { return new Promise((resolve, reject) => {})}
};

const serviceTwo = {
method: HttpMethod.POST,
url: 'foobar',
handler: () => { return new Promise((resolve, reject) => {})}
};

function register() {
httpServer.registerService(serviceOne);
httpServer.registerService(serviceTwo);
}

expect(register).to.throw();
});
});

describe('start', () => {
Expand Down

0 comments on commit 57da1ad

Please sign in to comment.