You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.0 KiB
JavaScript
47 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const nconf = require('nconf');
|
|
const request = require('request');
|
|
|
|
const db = require('./mocks/databasemock');
|
|
const meta = require('../src/meta');
|
|
|
|
describe('Language detection', () => {
|
|
it('should detect the language for a guest', (done) => {
|
|
meta.configs.set('autoDetectLang', 1, (err) => {
|
|
assert.ifError(err);
|
|
request(`${nconf.get('url')}/api/config`, {
|
|
headers: {
|
|
'Accept-Language': 'de-DE,de;q=0.5',
|
|
},
|
|
json: true,
|
|
}, (err, res, body) => {
|
|
assert.ifError(err);
|
|
assert.ok(body);
|
|
|
|
assert.strictEqual(body.userLang, 'de');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
|
|
it('should do nothing when disabled', (done) => {
|
|
meta.configs.set('autoDetectLang', 0, (err) => {
|
|
assert.ifError(err);
|
|
request(`${nconf.get('url')}/api/config`, {
|
|
headers: {
|
|
'Accept-Language': 'de-DE,de;q=0.5',
|
|
},
|
|
json: true,
|
|
}, (err, res, body) => {
|
|
assert.ifError(err);
|
|
assert.ok(body);
|
|
|
|
assert.strictEqual(body.userLang, 'en-GB');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
});
|