Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions endpoints/getting-started/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"scripts": {
"start": "node app.js",
"test": "repo-tools test run --cmd ava -- -T 20s --verbose test/*.test.js"
"test": "repo-tools test run --cmd mocha -- test/*.test.js --timeout=20000"
},
"dependencies": {
"body-parser": "^1.18.3",
Expand All @@ -23,7 +23,7 @@
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"ava": "^0.25.0",
"mocha": "^6.0.0",
"proxyquire": "^2.1.0",
"sinon": "^7.2.7",
"supertest": "^4.0.0"
Expand Down
33 changes: 15 additions & 18 deletions endpoints/getting-started/test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const path = require('path');
const proxyquire = require('proxyquire').noPreserveCache();
const request = require('supertest');
const sinon = require('sinon');
const test = require('ava');
const assert = require('assert');
const tools = require('@google-cloud/nodejs-repo-tools');

const SAMPLE_PATH = path.join(__dirname, '../app.js');
Expand All @@ -42,40 +42,37 @@ function getSample() {
};
}

test.beforeEach(tools.stubConsole);
test.afterEach.always(tools.restoreConsole);
beforeEach(tools.stubConsole);
afterEach(tools.restoreConsole);

test.cb('should echo a message', t => {
request(getSample().app)
it('should echo a message', async () => {
await request(getSample().app)
.post('/echo')
.send({message: 'foo'})
.expect(200)
.expect(response => {
t.is(response.body.message, 'foo');
})
.end(t.end);
assert.strictEqual(response.body.message, 'foo');
});
});

test.cb('should try to parse encoded info', t => {
request(getSample().app)
it('should try to parse encoded info', async () => {
await request(getSample().app)
.get('/auth/info/googlejwt')
.expect(200)
.expect(response => {
t.deepEqual(response.body, {id: 'anonymous'});
})
.end(t.end);
assert.deepStrictEqual(response.body, {id: 'anonymous'});
});
});

test.cb('should successfully parse encoded info', t => {
request(getSample().app)
it('should successfully parse encoded info', async () => {
await request(getSample().app)
.get('/auth/info/googlejwt')
.set(
'X-Endpoint-API-UserInfo',
Buffer.from(JSON.stringify({id: 'foo'})).toString('base64')
)
.expect(200)
.expect(response => {
t.deepEqual(response.body, {id: 'foo'});
})
.end(t.end);
assert.deepStrictEqual(response.body, {id: 'foo'});
});
});