Skip to content

Commit

Permalink
Extract multi-line e2e tests into separate case
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasgeiter committed Mar 14, 2018
1 parent 8fed0e2 commit 527e186
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 15 deletions.
7 changes: 0 additions & 7 deletions tests/e2e/fixtures/js/example.expected.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"

#: tests/e2e/fixtures/js/view.jsx:23
msgid ""
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam\n"
"nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam\n"
"erat, sed diam voluptua."
msgstr ""

#: tests/e2e/fixtures/js/view.jsx:22
msgid "One new message"
msgid_plural "{{n}} new messages"
Expand Down
17 changes: 17 additions & 0 deletions tests/e2e/fixtures/js/multiline.expected.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"

#: tests/e2e/fixtures/js/multiline.js:1
msgid ""
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam\n"
" nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam\n"
" erat, sed diam voluptua."
msgstr ""

#: tests/e2e/fixtures/js/multiline.js:7
msgid ""
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam\n"
"nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam\n"
"erat, sed diam voluptua."
msgstr ""
11 changes: 11 additions & 0 deletions tests/e2e/fixtures/js/multiline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
translate(
`Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
erat, sed diam voluptua.`
);

translate_trim(
`Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
erat, sed diam voluptua.`
);
4 changes: 0 additions & 4 deletions tests/e2e/fixtures/js/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,5 @@ export class View extends React.Component {
refresh() {
let count = Math.round(Math.random() * 100);
alert(this.translations.plural(count, 'One new message', '{{n}} new messages'));
this.translations.get(
`Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
erat, sed diam voluptua.`);
}
}
29 changes: 25 additions & 4 deletions tests/e2e/js.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ describe('JavaScript E2E', () => {
arguments: {
text: 0,
context: 1
},
content: {
trimWhiteSpace: true,
preserveIndentation: false
}
}),
JsExtractors.callExpression('[this].translations.plural', {
Expand All @@ -30,4 +26,29 @@ describe('JavaScript E2E', () => {

expect(extractor.getPotString()).toBe(fs.readFileSync(__dirname + '/fixtures/js/example.expected.pot').toString());
});

test('multi-line', () => {
let extractor = new GettextExtractor();

extractor
.createJsParser([
JsExtractors.callExpression(['translate'], {
arguments: {
text: 0
}
}),
JsExtractors.callExpression(['translate_trim'], {
arguments: {
text: 0
},
content: {
trimWhiteSpace: true,
preserveIndentation: false
}
})
])
.parseFilesGlob('tests/e2e/fixtures/js/**/*.js');

expect(extractor.getPotString()).toBe(fs.readFileSync(__dirname + '/fixtures/js/multiline.expected.pot').toString());
});
});

0 comments on commit 527e186

Please sign in to comment.