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.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
var assert = require('assert');
|
|
var nconf = require('nconf');
|
|
var request = require('request');
|
|
|
|
var db = require('./mocks/databasemock');
|
|
var meta = require('../src/meta');
|
|
|
|
describe('Language detection', function () {
|
|
it('should detect the language for a guest', function (done) {
|
|
meta.configs.set('autoDetectLang', 1, function (err) {
|
|
assert.ifError(err);
|
|
request(nconf.get('url') + '/api/config', {
|
|
headers: {
|
|
'Accept-Language': 'de-DE,de;q=0.5',
|
|
},
|
|
json: true,
|
|
}, function (err, res, body) {
|
|
assert.ifError(err);
|
|
assert.ok(body);
|
|
|
|
assert.strictEqual(body.userLang, 'de');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
|
|
it('should do nothing when disabled', function (done) {
|
|
meta.configs.set('autoDetectLang', 0, function (err) {
|
|
assert.ifError(err);
|
|
request(nconf.get('url') + '/api/config', {
|
|
headers: {
|
|
'Accept-Language': 'de-DE,de;q=0.5',
|
|
},
|
|
json: true,
|
|
}, function (err, res, body) {
|
|
assert.ifError(err);
|
|
assert.ok(body);
|
|
|
|
assert.strictEqual(body.userLang, 'en-GB');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
});
|