-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the AngularJS filter name configurable independently of the attr…
…ibute names.
- Loading branch information
Showing
7 changed files
with
157 additions
and
2 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
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,121 @@ | ||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
var testExtract = require('./utils').testExtract; | ||
|
||
describe('Extracting custom filters but standard attribute', function () { | ||
|
||
it('works for the simple case', function () { | ||
var files = [ | ||
'test/fixtures/filter-custom-standard-attribute.html' | ||
]; | ||
var catalog = testExtract(files, { | ||
filterName: 'trans' | ||
}); | ||
|
||
assert.equal(catalog.items.length, 3); | ||
|
||
assert.equal(catalog.items[0].msgid, 'Hello'); | ||
assert.equal(catalog.items[0].msgstr, ''); | ||
assert.equal(catalog.items[0].references.length, 1); | ||
assert.deepEqual(catalog.items[0].references, ['test/fixtures/filter-custom-standard-attribute.html:4']); | ||
|
||
assert.equal(catalog.items[1].msgid, 'Label'); | ||
assert.equal(catalog.items[1].msgstr, ''); | ||
assert.equal(catalog.items[1].references.length, 1); | ||
assert.deepEqual(catalog.items[1].references, ['test/fixtures/filter-custom-standard-attribute.html:3']); | ||
|
||
assert.equal(catalog.items[2].msgid, 'Second'); | ||
assert.equal(catalog.items[2].msgstr, ''); | ||
assert.equal(catalog.items[2].references.length, 1); | ||
assert.deepEqual(catalog.items[2].references, ['test/fixtures/filter-custom-standard-attribute.html:5']); | ||
}); | ||
|
||
it('works for concatenated filter strings', function () { | ||
var files = [ | ||
'test/fixtures/multifilter-custom-standard-attribute.html' | ||
]; | ||
var catalog = testExtract(files, { | ||
filterName: 'trans' | ||
}); | ||
|
||
assert.equal(catalog.items.length, 3); | ||
|
||
assert.equal(catalog.items[0].msgid, 'Hello'); | ||
assert.equal(catalog.items[0].msgstr, ''); | ||
assert.equal(catalog.items[0].references.length, 1); | ||
assert.deepEqual(catalog.items[0].references, ['test/fixtures/multifilter-custom-standard-attribute.html:4']); | ||
|
||
assert.equal(catalog.items[1].msgid, 'Label'); | ||
assert.equal(catalog.items[1].msgstr, ''); | ||
assert.equal(catalog.items[1].references.length, 1); | ||
assert.deepEqual(catalog.items[1].references, ['test/fixtures/multifilter-custom-standard-attribute.html:3']); | ||
|
||
assert.equal(catalog.items[2].msgid, 'World'); | ||
assert.equal(catalog.items[2].msgstr, ''); | ||
assert.equal(catalog.items[2].references.length, 1); | ||
assert.deepEqual(catalog.items[2].references, ['test/fixtures/multifilter-custom-standard-attribute.html:5']); | ||
}); | ||
|
||
it('works on filter strings using escaped quotes', function () { | ||
var files = [ | ||
'test/fixtures/escaped_quotes-custom-standard-attribute.html' | ||
]; | ||
var catalog = testExtract(files, { | ||
filterName: 'trans' | ||
}); | ||
|
||
assert.equal(catalog.items.length, 3); | ||
|
||
assert.equal(catalog.items[0].msgid, 'Hello'); | ||
assert.equal(catalog.items[0].msgstr, ''); | ||
assert.equal(catalog.items[0].references.length, 1); | ||
assert.deepEqual(catalog.items[0].references, ['test/fixtures/escaped_quotes-custom-standard-attribute.html:4']); | ||
|
||
assert.equal(catalog.items[1].msgid, 'Label'); | ||
assert.equal(catalog.items[1].msgstr, ''); | ||
assert.equal(catalog.items[1].references.length, 1); | ||
assert.deepEqual(catalog.items[1].references, ['test/fixtures/escaped_quotes-custom-standard-attribute.html:3']); | ||
|
||
assert.equal(catalog.items[2].msgid, 'World'); | ||
assert.equal(catalog.items[2].msgstr, ''); | ||
assert.equal(catalog.items[2].references.length, 1); | ||
assert.deepEqual(catalog.items[2].references, ['test/fixtures/escaped_quotes-custom-standard-attribute.html:5']); | ||
}); | ||
|
||
it('works on filter strings in multiple expression attributes', function () { | ||
var files = [ | ||
'test/fixtures/filter-in-multiple-expression-attributes-custom-standard-attribute.html' | ||
]; | ||
var catalog = testExtract(files, { | ||
filterName: 'trans' | ||
}); | ||
|
||
assert.equal(catalog.items.length, 5); | ||
|
||
assert.equal(catalog.items[0].msgid, 'Label'); | ||
assert.equal(catalog.items[0].msgstr, ''); | ||
assert.equal(catalog.items[0].references.length, 1); | ||
assert.deepEqual(catalog.items[0].references, ['test/fixtures/filter-in-multiple-expression-attributes-custom-standard-attribute.html:3']); | ||
|
||
assert.equal(catalog.items[1].msgid, 'expr1'); | ||
assert.equal(catalog.items[1].msgstr, ''); | ||
assert.equal(catalog.items[1].references.length, 1); | ||
assert.deepEqual(catalog.items[1].references, ['test/fixtures/filter-in-multiple-expression-attributes-custom-standard-attribute.html:4']); | ||
|
||
assert.equal(catalog.items[2].msgid, 'expr2'); | ||
assert.equal(catalog.items[2].msgstr, ''); | ||
assert.equal(catalog.items[2].references.length, 1); | ||
assert.deepEqual(catalog.items[2].references, ['test/fixtures/filter-in-multiple-expression-attributes-custom-standard-attribute.html:4']); | ||
|
||
assert.equal(catalog.items[3].msgid, 'expr3'); | ||
assert.equal(catalog.items[3].msgstr, ''); | ||
assert.equal(catalog.items[3].references.length, 1); | ||
assert.deepEqual(catalog.items[3].references, ['test/fixtures/filter-in-multiple-expression-attributes-custom-standard-attribute.html:4']); | ||
|
||
assert.equal(catalog.items[4].msgid, 'expr4'); | ||
assert.equal(catalog.items[4].msgstr, ''); | ||
assert.equal(catalog.items[4].references.length, 1); | ||
assert.deepEqual(catalog.items[4].references, ['test/fixtures/filter-in-multiple-expression-attributes-custom-standard-attribute.html:4']); | ||
}); | ||
}); |
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,7 @@ | ||
<html> | ||
<body> | ||
<label translate>Label</label> | ||
<input type="text" placeholder="{{"Hello"|trans}}" /> | ||
<input type="text" placeholder="{{'World'|trans}}" /> | ||
</body> | ||
</html> |
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,7 @@ | ||
<html> | ||
<body> | ||
<label translate>Label</label> | ||
<input type="text" placeholder="{{'Hello'|trans}}" /> | ||
<span>{{'Second'|trans}}</span> | ||
</body> | ||
</html> |
6 changes: 6 additions & 0 deletions
6
test/fixtures/filter-in-multiple-expression-attributes-custom-standard-attribute.html
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,6 @@ | ||
<html> | ||
<body> | ||
<label translate>Label</label> | ||
<my-directive expr1="'expr1' | trans" expr2="'expr2' | trans" expr3="'expr3' | trans" expr4="'expr4' | trans"></my-directive> | ||
</body> | ||
</html> |
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,7 @@ | ||
<html> | ||
<body> | ||
<label translate>Label</label> | ||
<input type="text" placeholder="{{'Hello'|trans|lowercase}}" /> | ||
<span>{{'World'|trans|lowercase}}</span> | ||
</body> | ||
</html> |