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

Commit

Permalink
Merge 3f99dc0 into e156ba9
Browse files Browse the repository at this point in the history
  • Loading branch information
SerayaEryn committed Sep 29, 2019
2 parents e156ba9 + 3f99dc0 commit 70d3117
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 97 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: ci

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [8.x, 10.x, 12.x]

steps:
- uses: actions/checkout@v1

- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: |
npm install
- name: Run Tests & generate coverage
run: |
npm run coveralls
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel: true

- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/*
coverage
.nyc_output
package-lock.json
package-lock.json
benchmark/node_modules
6 changes: 0 additions & 6 deletions .npmignore

This file was deleted.

6 changes: 6 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"all": true,
"check-coverage": true,
"reporter": [ "lcov", "text" ],
"include": [ "lib" ]
}
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# fast-translation

[![Build Status](https://travis-ci.org/SerayaEryn/fast-translation.svg?branch=master)](https://travis-ci.org/SerayaEryn/fast-translation)
![Build Status](https://github.com/SerayaEryn/fast-translation/workflows/ci/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/SerayaEryn/fast-translation/badge.svg?branch=master)](https://coveralls.io/github/SerayaEryn/fast-translation?branch=master)
[![NPM version](https://img.shields.io/npm/v/fast-translation.svg?style=flat)](https://www.npmjs.com/package/fast-translation) [![Greenkeeper badge](https://badges.greenkeeper.io/SerayaEryn/fast-translation.svg)](https://greenkeeper.io/)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
Expand Down
1 change: 1 addition & 0 deletions benchmark/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
2 changes: 1 addition & 1 deletion benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ suite
.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').map('name'))
})
.run({ 'async': true })
.run({ async: true })
6 changes: 6 additions & 0 deletions benchmark/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"benchmark": "^2.1.4",
"i18next": "^17.0.0"
}
}
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@
"description": "A performant and simple module for handling translations.",
"main": "lib/FastTranslation.js",
"scripts": {
"unit": "tap test/*.test.js",
"unit": "ava test/*.test.js",
"test": "npm run lint && npm run unit",
"lint": "standard lib/* test/*.test.js benchmark/*",
"coveralls": "npm run unit -- --cov",
"coverage": "npm run coveralls && tap --coverage-report=lcov",
"lint": "standard lib/* test/*.test.js benchmark/*.js",
"coveralls": "nyc npm test",
"coverage": "nyc npm test && nyc report --reporter=html",
"benchmark": "node benchmark/benchmark.js"
},
"author": "Denis Fäcke",
"license": "MIT",
"devDependencies": {
"benchmark": "^2.1.4",
"coveralls": "^3.0.2",
"ava": "^2.4.0",
"express": "^4.16.3",
"i18next": "^17.0.0",
"standard": "^14.0.0",
"tap": "^14.0.0"
"nyc": "^14.1.1",
"standard": "^14.0.0"
},
"repository": {
"type": "git",
Expand All @@ -38,5 +36,8 @@
"localization",
"i18n",
"translate"
],
"files": [
"lib"
]
}
27 changes: 13 additions & 14 deletions test/filesource.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use strict'

const tap = require('tap')
const test = tap.test
const test = require('ava')
const Translation = require('../lib/Translator')
const FileSource = require('../lib/sources/FileSource')
const FileSource = require('..').FileSource
const path = require('path')

test('should laod translation from file', (t) => {
test('should load translation from file', (t) => {
t.plan(5)

const translation = new Translation({
Expand All @@ -18,29 +17,29 @@ test('should laod translation from file', (t) => {
return number === 1 ? 0 : 1
})
.use(new FileSource({
filePath: path.join(__dirname, `/locales/__language_____namespace__.json`)
filePath: path.join(__dirname, '/locales/__language_____namespace__.json')
}))
.initialize()
.then(() => {
t.strictEquals(translation.translate('unknown.key', {
t.is(translation.translate('unknown.key', {
language: 'de',
namespace: 'DE'
}), 'unknown.key')
t.strictEquals(translation.translate('test.title', {
t.is(translation.translate('test.title', {
language: 'de',
namespace: 'DE'
}), 'undefined singular')
t.strictEquals(translation.translate('test.title', {
t.is(translation.translate('test.title', {
count: 1,
language: 'de',
namespace: 'DE'
}), '1 singular')
t.strictEquals(translation.translate('test.title', {
t.is(translation.translate('test.title', {
count: 2,
language: 'de',
namespace: 'DE'
}), '2 plural')
t.strictEquals(translation.translate('test.title', {
t.is(translation.translate('test.title', {
count: 0,
language: 'de',
namespace: 'DE'
Expand All @@ -60,11 +59,11 @@ test('Should reject on missing file', (t) => {
return number === 1 ? 0 : 1
})
.use(new FileSource({
filePath: path.join(__dirname, `/locales/__language_____namespace__.json`)
filePath: path.join(__dirname, '/locales/__language_____namespace__.json')
}))
.initialize()
.catch((err) => {
t.ok(err)
t.truthy(err)
})
})

Expand All @@ -80,10 +79,10 @@ test('Should reject on invalid json file', (t) => {
return number === 1 ? 0 : 1
})
.use(new FileSource({
filePath: path.join(__dirname, `/locales/__language_____namespace__.json`)
filePath: path.join(__dirname, '/locales/__language_____namespace__.json')
}))
.initialize()
.catch((err) => {
t.ok(err)
t.truthy(err)
})
})
28 changes: 15 additions & 13 deletions test/httpsource.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use strict'

const tap = require('tap')
const test = tap.test
const test = require('ava')
const Translation = require('../lib/Translator')
const HttpSource = require('../lib/sources/HttpSource')
const HttpSource = require('..').HttpSource
const http = require('http')

test('should load translations from http server', (t) => {
test.cb('should load translations from http server', (t) => {
t.plan(5)

const express = require('express')
Expand Down Expand Up @@ -39,34 +38,35 @@ test('should load translations from http server', (t) => {
.initialize()
.then(() => {
server.unref()
t.strictEquals(translation.translate('unknown.key', {
t.is(translation.translate('unknown.key', {
language: 'de',
namespace: 'DE'
}), 'unknown.key')
t.strictEquals(translation.translate('test.title', {
t.is(translation.translate('test.title', {
language: 'de',
namespace: 'DE'
}), 'undefined singular')
t.strictEquals(translation.translate('test.title', {
t.is(translation.translate('test.title', {
count: 1,
language: 'de',
namespace: 'DE'
}), '1 singular')
t.strictEquals(translation.translate('test.title', {
t.is(translation.translate('test.title', {
count: 2,
language: 'de',
namespace: 'DE'
}), '2 plural')
t.strictEquals(translation.translate('test.title', {
t.is(translation.translate('test.title', {
count: 0,
language: 'de',
namespace: 'DE'
}), '0 plural')
t.end()
})
})
})

test('', (t) => {
test.cb('should handle server error', (t) => {
t.plan(1)

const express = require('express')
Expand Down Expand Up @@ -95,12 +95,13 @@ test('', (t) => {
.initialize()
.catch((err) => {
server.unref()
t.ok(err)
t.truthy(err)
t.end()
})
})
})

test('Should reject on invalid json', (t) => {
test.cb('Should reject on invalid json', (t) => {
t.plan(1)

const express = require('express')
Expand Down Expand Up @@ -128,7 +129,8 @@ test('Should reject on invalid json', (t) => {
.initialize()
.catch((err) => {
server.unref()
t.ok(err)
t.truthy(err)
t.end()
})
})
})
Loading

0 comments on commit 70d3117

Please sign in to comment.