File tree 4 files changed +36
-17
lines changed
4 files changed +36
-17
lines changed Original file line number Diff line number Diff line change @@ -26,10 +26,28 @@ describe("Line.getComment", () => {
26
26
} ) ;
27
27
28
28
describe ( "Line.isEmpty" , ( ) => {
29
- const line1 = new Line ( null , null ) ;
29
+ it ( "returns true if key is missing" , ( ) => {
30
+ const line = new Line ( null , 'Translation with missing key' ) ;
31
+
32
+ expect ( line . isEmpty ( ) ) . toEqual ( true ) ;
33
+ expect ( line . isComment ( ) ) . toEqual ( false ) ;
34
+
35
+ } ) ;
36
+
37
+ it ( "returns true if translation is missing" , ( ) => {
38
+ const line = new Line ( 'missing.translation.key' , null ) ;
39
+
40
+ expect ( line . isEmpty ( ) ) . toEqual ( true ) ;
41
+ expect ( line . isComment ( ) ) . toEqual ( false ) ;
30
42
31
- expect ( line1 . isEmpty ( ) ) . toEqual ( true ) ;
32
- expect ( line1 . isComment ( ) ) . toEqual ( false ) ;
43
+ } ) ;
44
+
45
+ it ( "returns true if both key and translation are missing" , ( ) => {
46
+ const line = new Line ( null , null ) ;
47
+
48
+ expect ( line . isEmpty ( ) ) . toEqual ( true ) ;
49
+ expect ( line . isComment ( ) ) . toEqual ( false ) ;
50
+ } ) ;
33
51
} ) ;
34
52
35
53
describe ( "Line" , ( ) => {
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ class Line {
86
86
}
87
87
88
88
isEmpty ( ) {
89
- return ! this . isComment ( ) && ! this . key ;
89
+ return ! this . isComment ( ) && ! ( this . key && this . value ) ;
90
90
}
91
91
92
92
isComment ( ) {
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ describe("SpreadsheetReader", () => {
122
122
} ) ;
123
123
} ) ;
124
124
125
- it ( "should omit sheet in map lines when extracting from any fail " , async ( ) => {
125
+ it ( "should omit sheet in map lines when extracting fail from any reason " , async ( ) => {
126
126
expect . assertions ( 4 ) ;
127
127
128
128
const sheetsList = [
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export class FileWriter {
23
23
24
24
fileContent = fileContent . toString ( ) ;
25
25
} catch {
26
- // file doesnt exist
26
+ // file doesnt exist yet
27
27
}
28
28
29
29
const valueToInsert = this . getTransformedLines ( lines , transformer ) ;
@@ -43,21 +43,22 @@ export class FileWriter {
43
43
const line = lines [ i ] ;
44
44
const isLastLine = i === lines . length - 1 ;
45
45
46
- if ( ! line . isEmpty ( ) ) {
47
- if ( line . isComment ( ) ) {
48
- valueToInsert += transformer . transformComment ( line . getComment ( ) ) ;
49
- } else if ( line . isPlural ( ) ) {
50
- if ( ! plurals [ line . key ] ) {
51
- plurals [ line . key ] = [ ] ;
52
- }
53
- plurals [ line . key ] . push ( line ) ;
54
- } else {
55
- valueToInsert += transformer . transformKeyValue ( line . key , line . value ) ;
46
+ if ( line . isEmpty ( ) ) {
47
+ continue ;
48
+ }
49
+
50
+ if ( line . isComment ( ) ) {
51
+ valueToInsert += transformer . transformComment ( line . getComment ( ) ) ;
52
+ } else if ( line . isPlural ( ) ) {
53
+ if ( ! plurals [ line . key ] ) {
54
+ plurals [ line . key ] = [ ] ;
56
55
}
56
+ plurals [ line . key ] . push ( line ) ;
57
+ } else {
58
+ valueToInsert += transformer . transformKeyValue ( line . key , line . value ) ;
57
59
}
58
60
59
61
if (
60
- line . key !== "" &&
61
62
! line . isPlural ( ) &&
62
63
( ! isLastLine || Object . keys ( plurals ) . length > 0 )
63
64
) {
You can’t perform that action at this time.
0 commit comments