-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit tests for current functionality
- Loading branch information
Showing
7 changed files
with
275 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const testCase = require('../helpers/test-case'); | ||
|
||
describe('nested elements', function() { | ||
testCase({ | ||
name: 'Br inside text', | ||
input: ` | ||
<span> | ||
Hello | ||
<br /> | ||
world | ||
</span>`, | ||
output: ` | ||
<span> | ||
{{t "Hello <br /> world" htmlSafe=true}} | ||
</span>` | ||
}); | ||
|
||
testCase({ | ||
name: 'No br at the end of the translation', | ||
input: ` | ||
<span> | ||
Hello | ||
<br /> | ||
world | ||
<br /> | ||
</span>`, | ||
output: ` | ||
<span> | ||
{{t "Hello <br /> world" htmlSafe=true}} | ||
<br /> | ||
</span>` | ||
}); | ||
|
||
testCase({ | ||
name: 'No br at the start of the translation', | ||
input: ` | ||
<span> | ||
<br /> | ||
Hello | ||
<br /> | ||
world | ||
</span>`, | ||
output: ` | ||
<span> | ||
<br /> | ||
{{t "Hello <br /> world" htmlSafe=true}} | ||
</span>` | ||
}); | ||
|
||
testCase({ | ||
name: 'No br at the start/end of the translation', | ||
input: ` | ||
<span> | ||
<br /> | ||
<br /> | ||
Hello | ||
<br /> | ||
world | ||
<br /> | ||
</span>`, | ||
output: ` | ||
<span> | ||
<br /> | ||
<br /> | ||
{{t "Hello <br /> world" htmlSafe=true}} | ||
<br /> | ||
</span>` | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const testCase = require('../helpers/test-case'); | ||
|
||
describe('Empty text', function() { | ||
testCase({ | ||
name: 'Remove empty elements from start and begining of a translation', | ||
input: ` | ||
<strong></strong> | ||
<strong></strong> | ||
This is | ||
<strong></strong> | ||
`, | ||
output: ` | ||
<strong></strong> | ||
<strong></strong> | ||
{{t "This is"}} | ||
<strong></strong> | ||
` | ||
}); | ||
|
||
testCase({ | ||
name: 'Do not remove empty elements inside translation.', | ||
input: ` | ||
This is | ||
<strong></strong> | ||
text. | ||
`, | ||
output: ` | ||
{{t "This is <strong></strong> text." htmlSafe=true}} | ||
` | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
const testCase = require('../helpers/test-case'); | ||
|
||
describe('grouping allowed elements', function() { | ||
testCase({ | ||
name: 'merge html elements without element-modifiers', | ||
input: ` | ||
<div> | ||
<i>a</i> | ||
<em>b</em> | ||
<b>c</b> | ||
<strong>d</strong> | ||
<bold>e</bold> | ||
<span>f</span> | ||
<a>g</a> | ||
<div>Not Formatting Element</div> | ||
<code>h</code> | ||
<br /> | ||
<sup>i</sup> | ||
<sub>j</sub> | ||
</div> | ||
`, | ||
output: ` | ||
<div> | ||
{{t "<i>a</i> <em>b</em> <b>c</b> <strong>d</strong> <bold>e</bold> <span>f</span> <a>g</a>" htmlSafe=true}} | ||
<div>{{t "Not Formatting Element"}}</div> | ||
{{t "<code>h</code> <br /> <sup>i</sup> <sub>j</sub>" htmlSafe=true}} | ||
</div> | ||
` | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const testCase = require('../helpers/test-case'); | ||
|
||
describe('test of auditboard-icons', function() { | ||
testCase({ | ||
name: 'icon not translated', | ||
input: ` | ||
<i class="auditboard-icons fs-14 mr-3">lock_fill</i> Changes | ||
`, | ||
output: ` | ||
<i class="auditboard-icons fs-14 mr-3">lock_fill</i> {{t "Changes"}} | ||
` | ||
}); | ||
|
||
testCase({ | ||
name: 'i translated', | ||
input: ` | ||
<i class="fs-14 mr-3">This is</i> nice text. | ||
`, | ||
output: ` | ||
{{t "<i class='fs-14 mr-3'>This is</i> nice text." htmlSafe=true}} | ||
` | ||
}); | ||
|
||
testCase({ | ||
name: 'i translated', | ||
input: `<i class="fs-14 mr-3">This is nice text.</i>`, | ||
output: `<i class="fs-14 mr-3">{{t "This is nice text."}}</i>` | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const testCase = require('../helpers/test-case'); | ||
|
||
describe('test modifiers', function() { | ||
testCase({ | ||
name: 'merge html elements without element-modifiers', | ||
input: ` | ||
This is | ||
<strong>interesting</strong> | ||
text. | ||
`, | ||
output: ` | ||
{{t "This is <strong>interesting</strong> text." htmlSafe=true}} | ||
` | ||
}); | ||
|
||
testCase({ | ||
name: 'do not merge html elements if they have element-modifiers', | ||
input: ` | ||
This is | ||
<strong {{on 'click' this.doSomething}}>interesting</strong> | ||
text. | ||
`, | ||
output: ` | ||
{{t "This is"}} | ||
<strong {{on 'click' this.doSomething}}>{{t "interesting"}}</strong> | ||
{{t "text."}} | ||
` | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters