Files
NodeBB/test/locale-detect.js
Barış Soner Uşaklı c15bdd4cf0 👋Request, 🐶 Fetch, closes #10341 (#12236)
* 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
2023-12-18 12:08:34 -05:00

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');
});
});