settings: move language and tz into cloudron.js
This commit is contained in:
@@ -451,4 +451,91 @@ describe('Cloudron API', function () {
|
||||
expect(response.body.devices.some(d => d.mountpoint === '/')).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('time_zone', function () {
|
||||
it('succeeds', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/cloudron/time_zone`)
|
||||
.query({ access_token: owner.token });
|
||||
expect(response.statusCode).to.equal(200);
|
||||
expect(response.body.timeZone).to.be('UTC');
|
||||
});
|
||||
|
||||
it('cannot set tz with missing timeZone', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/cloudron/time_zone`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ foo: 'bar' })
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(400);
|
||||
});
|
||||
|
||||
it('cannot set language with invalid timeZone', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/cloudron/time_zone`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ timeZone: 'doesnotexist' })
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(400);
|
||||
});
|
||||
|
||||
it('can set time zone', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/cloudron/time_zone`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ timeZone: 'Africa/Johannesburg' });
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
});
|
||||
|
||||
it('did set time zone', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/cloudron/time_zone`)
|
||||
.query({ access_token: owner.token });
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
expect(response.body.timeZone).to.equal('Africa/Johannesburg');
|
||||
});
|
||||
});
|
||||
|
||||
describe('language', function () {
|
||||
it('can get default language', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/cloudron/language`)
|
||||
.query({ access_token: owner.token });
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
expect(response.body.language).to.equal('en');
|
||||
});
|
||||
|
||||
it('cannot set language with missing language', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/cloudron/language`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ foo: 'bar' })
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(400);
|
||||
});
|
||||
|
||||
it('cannot set language with invalid language', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/cloudron/language`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ language: 'doesnotexist' })
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(400);
|
||||
});
|
||||
|
||||
it('can set language', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/cloudron/language`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ language: 'de' });
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
});
|
||||
|
||||
it('did set language', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/cloudron/language`)
|
||||
.query({ access_token: owner.token });
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
expect(response.body.language).to.equal('de');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user