Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix l10n fallback tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhirsch committed Oct 3, 2017
1 parent 2270b53 commit 7a2b491
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
20 changes: 20 additions & 0 deletions test/server/unit/l10n-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const assert = require('assert');
const l10n = require('../../../server/src/l10n.js');

/* globals describe, it */

describe('l10n', () => {
before((done) => {
l10n.init().then((result) => { done() }, done);
});
describe('getUserLocales', () => {
it('should fall back to en-US if requested language has no localization', () => {
let locales = l10n.getUserLocales(['yo-LO']);
assert.ok(locales.includes('en-US'));
});
it('should fall back to en-US if requested language is missing', () => {
let locales = l10n.getUserLocales([]);
assert.ok(locales.includes('en-US'));
});
});
});
12 changes: 0 additions & 12 deletions test/server/unit/middleware/l10n-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,5 @@ describe('l10n middleware', () => {
assert(results.length === 1);
assert.equal('en-US', results[0]);
});
it('should return ["en-US"] if Accept-Language header value is "en-CA"', () => {
let mockRequest = { headers: { 'accept-language': 'en-CA' }};
let results = l10n.getLanguages(mockRequest);
assert(results.length === 1);
assert.equal('en-US', results[0]);
});
it('should return ["en-US"] if Accept-Language header value is "en"', () => {
let mockRequest = { headers: { 'accept-language': 'en' }};
let results = l10n.getLanguages(mockRequest);
assert(results.length === 1);
assert.equal('en-US', results[0]);
});
});
});

0 comments on commit 7a2b491

Please sign in to comment.