Skip to content

Commit

Permalink
test(progress): test progress callback
Browse files Browse the repository at this point in the history
  • Loading branch information
skolmer committed Nov 4, 2016
1 parent 61b0f0c commit 976d50e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
17 changes: 17 additions & 0 deletions __tests__/exportTranslationKeys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path'
import { exportTranslationKeys } from '../lib'
import silentLogger from './data/silentLogger'

global.console = silentLogger

describe('exportTranslationKeys', () => {
it('should fail if rootPath param is missing', (done) => {
Expand Down Expand Up @@ -59,6 +60,22 @@ describe('exportTranslationKeys', () => {
})
})

it('should report export progress', (done) => {
const rootPath = path.resolve(__dirname, './data')
let last = 0
exportTranslationKeys({
rootPath,
logger: { toConsole: true },
progress: (current, total, name) => {
expect(name).toBeDefined()
expect(current).toBeGreaterThan(last)
last = current
expect(total).toEqual(4)
if(current === 4) done()
}
})
})

it('should export grouped templates as array', (done) => {
const rootPath = path.resolve(__dirname, './data')
const filePath = path.resolve(__dirname, './data/grouped.js')
Expand Down
18 changes: 18 additions & 0 deletions __tests__/generateTranslationSchema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,24 @@ describe('i18n-tag-schema', () => {
})
})

it('should report schema progress', (done) => {
let last = 0
const filter = '\\.jsx?$'
const srcPath = path.resolve(__dirname, './data')
generateTranslationSchema({
srcPath,
filter,
logger: { toConsole: true },
progress: (current, total, name) => {
expect(name).toBeDefined()
expect(current).toBeGreaterThan(last)
last = current
expect(total).toEqual(4)
if(current === 4) done()
}
})
})

it('should match json string', (done) => {
const filter = '\\.jsx?$'
const srcPath = path.resolve(__dirname, './data')
Expand Down
18 changes: 18 additions & 0 deletions __tests__/validateTranslations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ describe('validateTranslations', () => {
})
})

it('should report validation progress', (done) => {
let last = 0
const schemaPath = path.resolve(__dirname, './data/schema.json')
const rootPath = path.resolve(__dirname, './data')
validateTranslations({
rootPath,
schemaPath,
logger: { toConsole: true },
progress: (current, total, name) => {
expect(name).toBeDefined()
expect(current).toBeGreaterThan(last)
last = current
expect(total).toEqual(2)
if(current === 2) done()
}
})
})

it('should validate translations', (done) => {
const schemaPath = path.resolve(__dirname, './data/schema.json')
const rootPath = path.resolve(__dirname, './data')
Expand Down

0 comments on commit 976d50e

Please sign in to comment.