Skip to content

Commit

Permalink
WIP: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lenadax committed Nov 25, 2024
1 parent 23b7a06 commit b811dd5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions js/tests/test_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ QUnit.module('AutocompleteWidget', hooks => {

QUnit.module('parse_source()', () => {
QUnit.test('function 1', assert => {
let arr = ['one', 'two', 'three']
$('div.autocomplete-params').text('delay,0|minLength,0');
window.foo = {
bar: function(request, response) {
Expand All @@ -143,6 +144,7 @@ QUnit.module('AutocompleteWidget', hooks => {
});

QUnit.test('function 2', assert => {
let arr = ['one', 'two', 'three']
$('div.autocomplete-params').text('delay,0|minLength,0');
window.foo = {
bar: {
Expand Down
6 changes: 5 additions & 1 deletion src/yafowil/widget/autocomplete/tests/test_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def test_source_is_string(self):
<input class="autocomplete" id="input-root" name="root" type="text"/>
<div class="autocomplete-source hiddenStructure">http://www.foo.bar/baz</div>
<div class="autocomplete-params hiddenStructure">delay,300|minLength,1|type,remote</div>
<input class="autocomplete-result-key hiddenStructure" name="result_key" type="hidden" value=""/>
</div>
""", fxml(widget()))

Expand All @@ -54,6 +55,7 @@ def test_source_is_list(self):
<input class="autocomplete" id="input-root" name="root" type="text"/>
<div class="autocomplete-source hiddenStructure">foo|bar</div>
<div class="autocomplete-params hiddenStructure">delay,300|minLength,1|type,local</div>
<input class="autocomplete-result-key hiddenStructure" name="result_key" type="hidden" value=""/>
</div>
""", fxml(widget()))

Expand All @@ -73,6 +75,7 @@ def test_source(widget, data):
<input class="autocomplete" id="input-root" name="root" type="text"/>
<div class="autocomplete-source hiddenStructure">http://from.callable/</div>
<div class="autocomplete-params hiddenStructure">delay,300|minLength,1|type,remote</div>
<input class="autocomplete-result-key hiddenStructure" name="result_key" type="hidden" value=""/>
</div>""", fxml(widget()))

def test_extraction(self):
Expand All @@ -88,7 +91,7 @@ def test_source(widget, data):
data = widget.extract({'root': 'abc'})
self.assertEqual(
[data.name, data.value, data.extracted, data.errors],
['root', UNSET, 'abc', []]
['root', UNSET, {'key': None, 'value': 'abc'}, []]
)

widget = factory(
Expand All @@ -113,6 +116,7 @@ def test_source(widget, data):
required="required" type="text" value=""/>
<div class="autocomplete-source hiddenStructure">http://from.callable/</div>
<div class="autocomplete-params hiddenStructure">delay,300|minLength,1|type,remote</div>
<input class="autocomplete-result-key hiddenStructure" name="result_key" type="hidden" value=""/>
</div>
</div>
""", fxml(widget(data)))
Expand Down

0 comments on commit b811dd5

Please sign in to comment.