Fixup profile avatar tests
This commit is contained in:
@@ -10,6 +10,9 @@ const common = require('./common.js'),
|
||||
expect = require('expect.js'),
|
||||
speakeasy = require('speakeasy'),
|
||||
superagent = require('superagent'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
paths = require('../../paths.js'),
|
||||
tokens = require('../../tokens.js');
|
||||
|
||||
describe('Profile API', function () {
|
||||
@@ -304,11 +307,13 @@ describe('Profile API', function () {
|
||||
describe('avatar', function () {
|
||||
let customAvatarSize = 0;
|
||||
|
||||
it('has no avatar by default (public route)', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/profile`)
|
||||
.query({ access_token: user.token });
|
||||
it('placeholder by default', async function () {
|
||||
const defaultAvatar = fs.readFileSync(path.join(paths.DASHBOARD_DIR, '/img/avatar-default-symbolic.svg'));
|
||||
|
||||
expect(response.body.avatarUrl).to.contain('/img/');
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/profile/avatar/${user.id}`);
|
||||
|
||||
expect(response.headers['content-type']).to.equal('image/svg+xml');
|
||||
expect(response.body).to.eql(defaultAvatar);
|
||||
});
|
||||
|
||||
it('can set custom avatar', async function () {
|
||||
@@ -345,7 +350,7 @@ describe('Profile API', function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/profile`)
|
||||
.query({ access_token: user.token });
|
||||
|
||||
expect(response.body.avatarUrl).to.contain('https://www.gravatar.com/avatar/');
|
||||
expect(response.body.avatarType).to.contain('gravatar');
|
||||
});
|
||||
|
||||
it('can unset avatar', async function () {
|
||||
@@ -357,10 +362,12 @@ describe('Profile API', function () {
|
||||
});
|
||||
|
||||
it('did unset avatar', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/profile`)
|
||||
.query({ access_token: user.token });
|
||||
const defaultAvatar = fs.readFileSync(path.join(paths.DASHBOARD_DIR, '/img/avatar-default-symbolic.svg'));
|
||||
|
||||
expect(response.body.avatarUrl).to.contain('/img/');
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/profile/avatar/${user.id}`);
|
||||
|
||||
expect(response.headers['content-type']).to.equal('image/svg+xml');
|
||||
expect(response.body).to.eql(defaultAvatar);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user