Skip to content

Commit

Permalink
Merge pull request #9 from Turbo87/tests
Browse files Browse the repository at this point in the history
Use Jest for tests instead of Mocha, Chai and NYC
  • Loading branch information
10xjs committed Sep 29, 2017
2 parents f1197ee + 34e6f84 commit 05bf4cc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ node_js:
- 'stable'

after_success:
- npm run coveralls
- cat coverage/lcov.info | node_modules/.bin/coveralls
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"description": "Convert a locale id string (LCID) to a unicode regional indicator symbol.",
"main": "index.js",
"scripts": {
"test": "./node_modules/.bin/nyc ./node_modules/.bin/mocha",
"coveralls": "./node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls"
"test": "jest --coverage"
},
"repository": {
"type": "git",
Expand All @@ -25,9 +24,7 @@
},
"homepage": "https://github.com/10xjs/locale-emoji#readme",
"devDependencies": {
"chai": "^3.5.0",
"coveralls": "^2.11.16",
"mocha": "^3.2.0",
"nyc": "^10.1.2"
"jest": "^21.1.0"
}
}
13 changes: 6 additions & 7 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var expect = require('chai').expect;
var localeEmoji = require('.');

describe('localeEmoji', function() {
Expand All @@ -17,15 +16,15 @@ describe('localeEmoji', function() {
'sk_Latin_SK': '🇸🇰',
};

it('converts LCIDs to flag emojis', function() {
Object.keys(tests).forEach(function(from) {
expect(localeEmoji(from)).to.equal(tests[from]);
Object.keys(tests).forEach(function(from) {
var to = tests[from];

it(from + ' -> ' + to, function() {
expect(localeEmoji(from)).toEqual(to);
});
});

it('should return a empty string for invalid input', function() {
Object.keys(tests).forEach(function(from) {
expect(localeEmoji('potato')).to.equal('');
});
expect(localeEmoji('potato')).toEqual('');
});
});

0 comments on commit 05bf4cc

Please sign in to comment.