forked from ariatemplates/ariatemplates
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix ariatemplates#1087 HTML Select Widget updation of datamodel on ch…
…ange
- Loading branch information
smadapathi
committed
Apr 15, 2014
1 parent
6259bee
commit 276f3f0
Showing
5 changed files
with
140 additions
and
0 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
69 changes: 69 additions & 0 deletions
69
test/aria/html/select/onchange/DataModelOnChangeTestCase.js
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 @@ | ||
/* | ||
* Copyright 2012 Amadeus s.a.s. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
Aria.classDefinition({ | ||
$classpath : "test.aria.html.select.onchange.DataModelOnChangeTestCase", | ||
$extends : "aria.jsunit.TemplateTestCase", | ||
$dependencies : ["aria.utils.Dom", "aria.html.Select", "aria.utils.SynEvents"], | ||
$constructor : function () { | ||
this.$TemplateTestCase.constructor.call(this); | ||
|
||
this.data = { | ||
selectedOption : "EURO", | ||
onChangeOption : "" | ||
}; | ||
this.setTestEnv({ | ||
template : "test.aria.html.select.onchange.DataModelOnChangeTpl", | ||
data : this.data | ||
}); | ||
|
||
}, | ||
$prototype : { | ||
runTemplateTest : function () { | ||
|
||
var document = Aria.$window.document; | ||
var selectWidgets = this.testDiv.getElementsByTagName("select"); | ||
|
||
// we know there's only one | ||
var selectWidget = selectWidgets[0]; | ||
this.assertEquals(selectWidget.selectedIndex, 0, "The selected Index should be %2 but was %1 "); | ||
|
||
// to be nullified in the callback of the click action | ||
this.selectWidget = selectWidget; | ||
this.selectWidget.focus(); | ||
|
||
this.synEvent.type(this.selectWidget, "[down][down][enter]", { | ||
fn : function () { | ||
this.templateCtxt.$focus("justToFocusOut"); | ||
this.waitFor({ | ||
condition : function () { | ||
return this.data.onChangeOption !== ""; | ||
}, | ||
callback : this.afterChange | ||
}); | ||
|
||
}, | ||
scope : this | ||
}); | ||
}, | ||
|
||
afterChange : function () { | ||
this.assertEquals(this.data.selectedOption, "POUND", "Selected Option should be %2 but was %1"); | ||
this.assertEquals(this.data.onChangeOption, "POUND", "Changed Option should be %2 but was %1"); | ||
this.end(); | ||
} | ||
|
||
} | ||
}); |
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,42 @@ | ||
/* | ||
* Copyright 2012 Amadeus s.a.s. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
{Template { | ||
$classpath : "test.aria.html.select.onchange.DataModelOnChangeTpl", | ||
$wlibs : { | ||
html : "aria.html.HtmlLibrary" | ||
}, | ||
$hasScript : true | ||
}} | ||
|
||
{macro main()} | ||
|
||
{var myStringOptions = ["EURO","FRANC SUISSE","POUND"]/} | ||
|
||
{@html:Select{ | ||
options : myStringOptions, | ||
bind : { | ||
value : { | ||
inside : data, | ||
to : "selectedOption" | ||
} | ||
}, | ||
on :{ | ||
change:myFunc | ||
} | ||
}/} | ||
<input {id "justToFocusOut"/}> | ||
{/macro} | ||
{/Template} |
23 changes: 23 additions & 0 deletions
23
test/aria/html/select/onchange/DataModelOnChangeTplScript.js
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,23 @@ | ||
/* | ||
* Copyright 2012 Amadeus s.a.s. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
Aria.tplScriptDefinition({ | ||
$classpath : "test.aria.html.select.onchange.DataModelOnChangeTplScript", | ||
$prototype : { | ||
myFunc : function () { | ||
this.data.onChangeOption = this.data.selectedOption; | ||
} | ||
} | ||
}); |