Skip to content

Commit

Permalink
test: Add test for Fix #18 Selective I18N-target attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
t2ym committed Jun 24, 2016
1 parent ee96919 commit 0440b3e
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 1 deletion.
24 changes: 24 additions & 0 deletions test/expected/basic-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ <h1>{{text.h1_3}}</h1>{{text.text_4}}<span>{{text.span_5}}</span>
<text-attribute-element id="custom-attr" custom-text-attr1="{{model.custom-attr.custom-text-attr1}}" custom-text-attr2="{{model.custom-attr.custom-text-attr2}}" custom-text-attr3="{{model.custom-attr.custom-text-attr3}}" out-of-scope-attr="out of scope attr">
</text-attribute-element>

<text-attribute-element id="selective-attr" boolean-attr="" empty-attr="" string-attr="abc" i18n-target="{{model.selective-attr.i18n-target}}" i18n-target2="{{model.selective-attr.i18n-target2}}">
</text-attribute-element>
<text-attribute-element id="selective-attr2" boolean-attr="" boolean-attr2="" string-attr="aaa" i18n-target="{{model.selective-attr2.i18n-target}}">
</text-attribute-element>
<text-attribute-element id="selective-attr3" i18n-target6="{{model.selective-attr3.i18n-target6}}">
</text-attribute-element>
<text-attribute-element id="selective-attr4" boolean-attr="" i18n-target6="{{model.selective-attr4.i18n-target6}}" i18n-target7="unmatching i18n-target4 attribute">
</text-attribute-element>
<text-attribute-element id="selective-attr5" string-attr="xxx" i18n-target7="unmatching i18n-target7 attribute">
</text-attribute-element>

<span id="test-json-data-1">{{model.json-data-id.attr1}}</span>
<span id="test-json-data-2">{{model.json-data-id.i18n-target-attr}}</span>
<span id="test-json-data-3">{{model.template_2:json-data_1.attr1}}</span>
Expand Down Expand Up @@ -311,6 +322,19 @@ <h1>{{text.h1_3}}</h1>{{text.text_4}}<span>{{text.span_5}}</span>
"custom-text-attr2": "custom text attribute 2",
"custom-text-attr3": "custom text attribute 3"
},
"selective-attr": {
"i18n-target": "i18n-target attribute",
"i18n-target2": "i18n-target2 attribute"
},
"selective-attr2": {
"i18n-target": "i18n-target attribute 2"
},
"selective-attr3": {
"i18n-target6": "i18n-target6 attribute 2"
},
"selective-attr4": {
"i18n-target6": "i18n-target6 attribute 3"
},
"json-data-id": {
"attr1": "this attr1 is extracted",
"i18n-target-attr": "this attribute is also extracted"
Expand Down
13 changes: 13 additions & 0 deletions test/expected/simple-attribute-dom-bind.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@
"custom-text-attr2": "custom text attribute 2",
"custom-text-attr3": "custom text attribute 3"
},
"selective-attr": {
"i18n-target": "i18n-target attribute",
"i18n-target2": "i18n-target2 attribute"
},
"selective-attr2": {
"i18n-target": "i18n-target attribute 2"
},
"selective-attr3": {
"i18n-target6": "i18n-target6 attribute 2"
},
"selective-attr4": {
"i18n-target6": "i18n-target6 attribute 3"
},
"json-data-id": {
"attr1": "this attr1 is extracted",
"i18n-target-attr": "this attribute is also extracted"
Expand Down
27 changes: 27 additions & 0 deletions test/src/basic-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,33 @@ <h1>outermost header 1</h1>
out-of-scope-attr="out of scope attr">
</text-attribute-element>

<text-attribute-element
id="selective-attr"
boolean-attr empty-attr string-attr="abc"
i18n-target="i18n-target attribute"
i18n-target2="i18n-target2 attribute">
</text-attribute-element>
<text-attribute-element
id="selective-attr2"
boolean-attr boolean-attr2 string-attr="aaa"
i18n-target="i18n-target attribute 2">
</text-attribute-element>
<text-attribute-element
id="selective-attr3"
i18n-target6="i18n-target6 attribute 2">
</text-attribute-element>
<text-attribute-element
id="selective-attr4"
boolean-attr
i18n-target6="i18n-target6 attribute 3"
i18n-target7="unmatching i18n-target4 attribute">
</text-attribute-element>
<text-attribute-element
id="selective-attr5"
string-attr="xxx"
i18n-target7="unmatching i18n-target7 attribute">
</text-attribute-element>

<span id="test-json-data-1">{{model.json-data-id.attr1}}</span>
<span id="test-json-data-2">{{model.json-data-id.i18n-target-attr}}</span>
<span id="test-json-data-3">{{model.template_2:json-data_1.attr1}}</span>
Expand Down
44 changes: 44 additions & 0 deletions test/src/text-attribute-element.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,50 @@
-->
<link rel="import" href="../../../i18n-behavior.html">

<i18n-attr-repo>
<template id="custom">
<text-attribute-element custom-text-attr4="$"></text-attribute-element>
<text-attribute-element i18n-target></text-attribute-element>
<text-attribute-element i18n-target="boolean-attr,!boolean-attr2,string-attr=abc|def,empty-attr=,type1"></text-attribute-element>
<text-attribute-element i18n-target="boolean-attr,boolean-attr2,string-attr=aaa,type2"></text-attribute-element>
<text-attribute-element i18n-target="string-attr=aaa,string-attr2=bbb,type3"></text-attribute-element>
<text-attribute-element i18n-target="boolean-attr=,type4"></text-attribute-element>
<text-attribute-element i18n-target2="boolean-attr,!boolean-attr2,string-attr=abc|def,empty-attr=,type1"></text-attribute-element>
<text-attribute-element i18n-target2="boolean-attr,boolean-attr2,,string-attr=aaa,,type2"></text-attribute-element>
<text-attribute-element i18n-target2="string-attr=aaa,string-attr2=bbb,type3"></text-attribute-element>
<text-attribute-element i18n-target2="boolean-attr=,type4"></text-attribute-element>
<text-attribute-element i18n-target2="type5"></text-attribute-element>
<text-attribute-element i18n-target3="string-attr=aaa,type1"></text-attribute-element>
<text-attribute-element i18n-target3></text-attribute-element>
<text-attribute-element i18n-target4></text-attribute-element>
<text-attribute-element i18n-target4="string-attr=aaa,type1"></text-attribute-element>
<text-attribute-element i18n-target5></text-attribute-element>
<text-attribute-element i18n-target5="type1"></text-attribute-element>
<text-attribute-element i18n-target="boolean-attr=,type4"></text-attribute-element>
<text-attribute-element i18n-target="string-attr=aaa,string-attr2=bbb,type3"></text-attribute-element>
<text-attribute-element i18n-target="boolean-attr,,boolean-attr2,,string-attr=aaa"></text-attribute-element>
<text-attribute-element i18n-target="boolean-attr,!boolean-attr2,string-attr=abc|def,empty-attr=,type1"></text-attribute-element>
<text-attribute-element i18n-target></text-attribute-element>
<text-attribute-element i18n-target2="type5"></text-attribute-element>
<text-attribute-element i18n-target2="boolean-attr="></text-attribute-element>
<text-attribute-element i18n-target2="string-attr=aaa,string-attr2=bbb,type3"></text-attribute-element>
<text-attribute-element i18n-target2="boolean-attr,!boolean-attr2,,string-attr=abc|def,,empty-attr=,type1"></text-attribute-element>
<text-attribute-element i18n-target2="boolean-attr,,boolean-attr2,,string-attr=aaa,type2"></text-attribute-element>
<text-attribute-element i18n-target3="string-attr=aaa,type1"></text-attribute-element>
<text-attribute-element i18n-target3></text-attribute-element>
<text-attribute-element i18n-target4></text-attribute-element>
<text-attribute-element i18n-target4="string-attr=aaa,type1"></text-attribute-element>
<text-attribute-element i18n-target5></text-attribute-element>
<text-attribute-element i18n-target5="type1"></text-attribute-element>
<text-attribute-element i18n-target6="type5"></text-attribute-element>
<text-attribute-element i18n-target6="boolean-attr="></text-attribute-element>
<text-attribute-element i18n-target6="boolean-attr,boolean-attr2,type1"></text-attribute-element>
<text-attribute-element i18n-target6="boolean-attr,boolean-attr2,string-attr=aaa,type2"></text-attribute-element>
<text-attribute-element i18n-target7="string-attr=aaa,type1"></text-attribute-element>
<text-attribute-element i18n-target7="invalid!attr=aaa,typeX"></text-attribute-element>
</template>
</i18n-attr-repo>

<dom-module id="text-attribute-element">
<template text-attr="custom-text-attr1 custom-text-attr2" custom-text-attr3>
<span id="attr1">{{customTextAttr1}}</span>
Expand Down
60 changes: 59 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,65 @@ var attributesRepository_custom = p({
'text-attribute-element': {
'custom-text-attr1': true,
'custom-text-attr2': true,
'custom-text-attr3': true
'custom-text-attr3': true,
'custom-text-attr4': '$',
'i18n-target': {
'boolean-attr': {
'!boolean-attr2': {
'empty-attr': {
'string-attr=abc|def': 'type1'
}
},
'boolean-attr2': {
'string-attr=aaa': true
},
'': 'type4'
},
'string-attr=aaa': {
'string-attr2=bbb': 'type3'
},
'': true
},
'i18n-target2': {
'boolean-attr': {
'!boolean-attr2': {
'empty-attr': {
'string-attr=abc|def': 'type1'
}
},
'boolean-attr2': {
'string-attr=aaa': 'type2'
},
'': true
},
'string-attr=aaa': {
'string-attr2=bbb': 'type3'
},
'': 'type5'
},
'i18n-target3': {
'string-attr=aaa': 'type1',
'': true
},
'i18n-target4': {
'string-attr=aaa': 'type1',
'': true
},
'i18n-target5': 'type1',
'i18n-target6': {
'boolean-attr': {
'': true,
'boolean-attr2': {
'': 'type1',
'string-attr=aaa': 'type2',
}
},
'': 'type5'
},
'i18n-target7': {
'string-attr=aaa': 'type1',
'invalid!attr=aaa': 'typeX'
}
}
}, attributesRepository_standard);

Expand Down

0 comments on commit 0440b3e

Please sign in to comment.