Skip to content

Commit

Permalink
fix failure message when only adding/removing one key
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbay committed Oct 23, 2016
1 parent becb79c commit 890ae5f
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "i18next-json-sync",
"version": "1.2.0-alpha2",
"version": "1.2.0",
"description": "keep i18next json resource files in sync",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/ActionRecorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default class ActionRecorder {

public hasAnyActions() {
return this.hasAnyErrors() ||
this.addedKeys.length > 1 ||
this.removedKeys.length > 1;
this.addedKeys.length > 0 ||
this.removedKeys.length > 0;
}

public flushToConsole() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
exports[`test adds-removes-keys-report:locales/de.json 1`] = `
exports[`test check-adds-removes-keys:locales/de.json 1`] = `
"{
remove_de: remove,
remove_de_too: remove also
}"
`;

exports[`test adds-removes-keys-report:locales/en.json 1`] = `
exports[`test check-adds-removes-keys:locales/en.json 1`] = `
"{
add_me: add,
keep_me: keep
}"
`;

exports[`test adds-removes-keys-report:locales/pt-BR.json 1`] = `
exports[`test check-adds-removes-keys:locales/pt-BR.json 1`] = `
"{
keep_me: don\'t change,
remove_me: remove
}"
`;

exports[`test adds-removes-keys-report:stderr.txt 1`] = `
exports[`test check-adds-removes-keys:stderr.txt 1`] = `
"
THROWN:
Error: [i18next-json-sync] check failed -- keys are out of sync. Run again without check mode to synchronize files
...
"
`;

exports[`test adds-removes-keys-report:stdout.txt 1`] = `
exports[`test check-adds-removes-keys:stdout.txt 1`] = `
"Missing keys in actual/locales/de.json: add_me, keep_me
Orphaned keys found in actual/locales/de.json: remove_de, remove_de_too
Missing keys in actual/locales/pt-BR.json: add_me
Expand Down
File renamed without changes.
25 changes: 25 additions & 0 deletions tests/check-adds-removes-single-key/__snapshots__/runner.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
exports[`test check-adds-removes-single-key:locales/de.json 1`] = `
"{
keep_me: keep de
}"
`;

exports[`test check-adds-removes-single-key:locales/en.json 1`] = `
"{
add_me: add,
keep_me: keep en
}"
`;

exports[`test check-adds-removes-single-key:stderr.txt 1`] = `
"
THROWN:
Error: [i18next-json-sync] check failed -- keys are out of sync. Run again without check mode to synchronize files
...
"
`;

exports[`test check-adds-removes-single-key:stdout.txt 1`] = `
"Missing keys in actual/locales/de.json: add_me
"
`;
5 changes: 5 additions & 0 deletions tests/check-adds-removes-single-key/options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { IOptions } from '../../src';
const options: IOptions = {
check: true
};
export = options;
3 changes: 3 additions & 0 deletions tests/check-adds-removes-single-key/project/locales/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"keep_me": "keep de"
}
4 changes: 4 additions & 0 deletions tests/check-adds-removes-single-key/project/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"add_me": "add",
"keep_me": "keep en"
}

0 comments on commit 890ae5f

Please sign in to comment.