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.
nodebb/test/locale-detect.js

43 lines
1021 B
JavaScript

8 years ago
'use strict';
var assert = require('assert');
var nconf = require('nconf');
var request = require('request');
var db = require('./mocks/databasemock');
8 years ago
var meta = require('../src/meta');
describe('Language detection', function () {
it('should detect the language for a guest', function (done) {
meta.config.autoDetectLang = 1;
8 years ago
request(nconf.get('url') + '/api/config', {
headers: {
'Accept-Language': 'de-DE,de;q=0.5',
},
}, function (err, res, body) {
assert.ifError(err);
assert.ok(body);
assert.strictEqual(JSON.parse(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',
},
}, function (err, res, body) {
assert.ifError(err);
assert.ok(body);
assert.strictEqual(JSON.parse(body).userLang, 'en-GB');
done();
});
});
});
});