mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
* axios migration * controller tests * add missing deps * feeds * remove unused async * flags * locale-detect * messaging/middleware * remove log * meta * plugins * posts * search * topics/thumbs * user/emails * uploads.js * socket.io * cleaunup * test native fetch * cleanup * increase engine to 18 fix remaining tests * remove testing file * fix comments,typo * revert debug
36 lines
878 B
JavaScript
36 lines
878 B
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const nconf = require('nconf');
|
|
|
|
const db = require('./mocks/databasemock');
|
|
const meta = require('../src/meta');
|
|
const request = require('../src/request');
|
|
|
|
describe('Language detection', () => {
|
|
it('should detect the language for a guest', async () => {
|
|
await meta.configs.set('autoDetectLang', 1);
|
|
|
|
const { body } = await request.get(`${nconf.get('url')}/api/config`, {
|
|
headers: {
|
|
'Accept-Language': 'de-DE,de;q=0.5',
|
|
},
|
|
});
|
|
assert.ok(body);
|
|
assert.strictEqual(body.userLang, 'de');
|
|
});
|
|
|
|
it('should do nothing when disabled', async () => {
|
|
await meta.configs.set('autoDetectLang', 0);
|
|
|
|
const { body } = await request.get(`${nconf.get('url')}/api/config`, {
|
|
headers: {
|
|
'Accept-Language': 'de-DE,de;q=0.5',
|
|
},
|
|
});
|
|
|
|
assert.ok(body);
|
|
assert.strictEqual(body.userLang, 'en-GB');
|
|
});
|
|
});
|