profile: store preferred language in the database
This commit is contained in:
@@ -56,6 +56,7 @@ describe('Profile API', function () {
|
||||
expect(response.body.displayName).to.be.a('string');
|
||||
expect(response.body.password).to.not.be.ok();
|
||||
expect(response.body.salt).to.not.be.ok();
|
||||
expect(response.body.language).to.be('');
|
||||
});
|
||||
|
||||
it('fails with expired token', async function () {
|
||||
@@ -370,4 +371,54 @@ describe('Profile API', function () {
|
||||
expect(response.body).to.eql(defaultAvatar);
|
||||
});
|
||||
});
|
||||
|
||||
describe('language', function () {
|
||||
it('fails to set unknown language', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/language`)
|
||||
.query({ access_token: user.token })
|
||||
.send({ language: 'ta' })
|
||||
.ok(() => true);
|
||||
expect(response.statusCode).to.be(400);
|
||||
});
|
||||
|
||||
it('fails to set bad language', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/language`)
|
||||
.query({ access_token: user.token })
|
||||
.send({ language: 123 })
|
||||
.ok(() => true);
|
||||
expect(response.statusCode).to.be(400);
|
||||
});
|
||||
|
||||
it('fails to set unknown language', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/language`)
|
||||
.query({ access_token: user.token })
|
||||
.send({ language: 'ta' })
|
||||
.ok(() => true);
|
||||
expect(response.statusCode).to.be(400);
|
||||
});
|
||||
|
||||
it('set valid language', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/language`)
|
||||
.query({ access_token: user.token })
|
||||
.send({ language: 'en' });
|
||||
expect(response.statusCode).to.be(204);
|
||||
});
|
||||
|
||||
it('did set language', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/profile`).query({ access_token: user.token });
|
||||
expect(response.body.language).to.contain('en');
|
||||
});
|
||||
|
||||
it('reset valid language', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/language`)
|
||||
.query({ access_token: user.token })
|
||||
.send({ language: '' });
|
||||
expect(response.statusCode).to.be(204);
|
||||
});
|
||||
|
||||
it('did reset language', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/profile`).query({ access_token: user.token });
|
||||
expect(response.body.language).to.contain('');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user