API Integration Tests via jest (#10899)

* tests: experiment with api tests

* api tests are getting nice

* api: api testing ready for feedback
This commit is contained in:
Torkel Ödegaard
2018-02-14 10:26:20 +01:00
committed by GitHub
parent bb681cd498
commit ead1c300d7
11 changed files with 373 additions and 3 deletions

30
tests/api/client.ts Normal file
View File

@@ -0,0 +1,30 @@
const axios = require('axios');
export function getClient(options) {
return axios.create({
baseURL: 'http://localhost:3000',
timeout: 1000,
auth: {
username: options.username,
password: options.password,
},
});
}
export function getAdminClient() {
return getClient({
username: 'admin',
password: 'admin',
});
}
let client = getAdminClient();
client.callAs = function(user) {
return getClient({
username: user.login,
password: 'password',
});
};
export default client;