Skip to content

Commit

Permalink
Merge pull request #26 from Brightspace/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
dlockhart committed Feb 6, 2018
2 parents 8ce4eeb + 4230845 commit 3d38ffe
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
coverage/
package-lock.json
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js: stable
node_js: node
sudo: false
after_success:
- npm run report-coverage
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
},
"homepage": "https://github.com/Brightspace/frau-locale-provider",
"devDependencies": {
"chai": "^3.5.0",
"coveralls": "^2.13.1",
"eslint": "^3.19.0",
"eslint-config-brightspace": "^0.2.4",
"chai": "^4.1.2",
"coveralls": "^3.0.0",
"eslint": "^4.17.0",
"eslint-config-brightspace": "^0.4.0",
"istanbul": "^0.4.5",
"mocha": "^3.4.1",
"sinon": "^2.2.0"
"mocha": "^5.0.0",
"sinon": "^4.2.2"
}
}
4 changes: 2 additions & 2 deletions src/getHtmlLang.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ module.exports = function() {
}

var elems = window.document.getElementsByTagName('html');
if ( elems.length === 0 ) {
if (elems.length === 0) {
return { lang: config.defaultLangTag };
}

var lang = elems[0].getAttribute('lang');
if ( lang === null ) {
if (lang === null) {
return { lang: config.defaultLangTag };
}

Expand Down
4 changes: 2 additions & 2 deletions src/normalizeLangTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

module.exports = function(langTag) {

if ( langTag === undefined || langTag === null ) {
if (langTag === undefined || langTag === null) {
return '';
}

langTag = langTag.trim().toLowerCase();

var subtags = langTag.split('-');
if ( subtags.length < 2 ) {
if (subtags.length < 2) {
return langTag;
}

Expand Down
6 changes: 3 additions & 3 deletions src/resolveLang.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ function resolve(langTag, fallback) {

langTag = normalizeLangTag(langTag);

if ( config.regions.indexOf(langTag) > -1 ) {
if (config.regions.indexOf(langTag) > -1) {
return langTag;
}

if (config.aliases[langTag] !== undefined) {
return config.aliases[langTag];
}

if ( config.primary.indexOf(langTag) > -1 ) {
if (config.primary.indexOf(langTag) > -1) {
return langTag;
}

var subtags = langTag.split('-');
if ( subtags.length > 0 && config.primary.indexOf(subtags[0]) > -1 ) {
if (subtags.length > 0 && config.primary.indexOf(subtags[0]) > -1) {
return subtags[0];
}

Expand Down
6 changes: 3 additions & 3 deletions test/getHtmlLang.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ describe('getHtmlLang', function() {
/* no HTML elements */
function() {
global.window.document.getElementsByTagName = sinon.stub()
.returns([]);
.returns([]);
},
/* no lang attribute on HTML element */
function() {
global.window.document.getElementsByTagName = sinon.stub()
.returns([{getAttribute: sinon.stub().returns(null)}]);
}
].forEach(function(func, index) {
it('should return default ' + ( index + 1 ), function() {
it('should return default ' + (index + 1), function() {
func();
var value = getHtmlLang();
expect(value.lang).to.equal(config.defaultLangTag);
Expand All @@ -62,7 +62,7 @@ describe('getHtmlLang', function() {
it('should return null fallback when no data attribute', function() {
getAttribute.withArgs('data-lang-default').returns(null);
var value = getHtmlLang();
expect(value.fallback).to.not.be.defined;
expect(value.fallback).to.be.undefined;
});

it('should return fallback value', function() {
Expand Down
4 changes: 2 additions & 2 deletions test/isRtl.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ describe('isRtl', function() {
/* window.document.body is undefined */
function() { global.window.document.body = undefined; }
].forEach(function(func, index) {
it('should return false in error case ' + ( index + 1 ), function() {
it('should return false in error case ' + (index + 1), function() {
func();
var value = isRtl();
expect( value ).to.be.false;
expect(value).to.be.false;
});
});

Expand Down
4 changes: 2 additions & 2 deletions test/localeProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('localeProvider', function() {
describe('getLangTag', function() {

it('should have getLangTag defined', function() {
expect(localeProvider.getLangTag).to.be.defined;
expect(localeProvider.getLangTag).to.not.be.undefined;
});

it('should call getHtmlLang', function() {
Expand All @@ -43,7 +43,7 @@ describe('localeProvider', function() {
describe('isRtl', function() {

it('should have isRtl defined', function() {
expect(localeProvider.isRtl).to.be.defined;
expect(localeProvider.isRtl).to.not.be.undefined;
});

});
Expand Down

0 comments on commit 3d38ffe

Please sign in to comment.