Skip to content

Commit

Permalink
Set up automated testing
Browse files Browse the repository at this point in the history
Supertest integration tests. TODO: Create tests for each working use case
  • Loading branch information
gustapp committed Jan 22, 2019
1 parent c1c1c89 commit 1ea523e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
2 changes: 2 additions & 0 deletions functions/package.json
Expand Up @@ -22,9 +22,11 @@
"@types/chai": "^4.1.7",
"@types/jest": "^23.3.13",
"@types/sinon": "^7.0.4",
"@types/supertest": "^2.0.7",
"chai": "^4.2.0",
"jest": "^23.6.0",
"sinon": "^7.2.3",
"supertest": "^3.4.1",
"ts-jest": "^23.10.5",
"ts-sinon": "^1.0.12",
"tslint": "~5.8.0",
Expand Down
36 changes: 10 additions & 26 deletions functions/test/hello-world.spec.ts
Expand Up @@ -4,34 +4,18 @@ import {} from "ts-jest";
import * as chai from "chai";
const expect = chai.expect;

import * as sinon from "ts-sinon";
const stubObject = sinon.stubObject;
import * as request from 'supertest';

interface Test {
method(): string;
}
const url = 'http://localhost:8010/ganimedes-d9ecd/us-central1';

describe("HelloWorld function", ()=> {
describe("GET /helloWorld - ping function endpoint", ()=> {

it("Should return message `Hello, let's chat!`", () => {
it("Should return greeting: `Hello! Lets chat!`", () => {

const req = {
body: {},
get: ''
};

const res = {
send: {
calledOnce: false,
firstCall: {
args: ''
}
}
};

helloWorld(req, res);

expect(res.send.calledOnce).to.equal(true);
expect(res.send.firstCall.args).to.be(`Hello, let's chat!`);
return request(url).get('/helloWorld')
.expect(200)
.expect(response => {
expect(response.text).to.be.equal(`Hello! Lets chat!`);
});
});
})
});

0 comments on commit 1ea523e

Please sign in to comment.