~free.ekanayaka/lazr-js/update-gallery-form

« back to all changes in this revision

Viewing changes to src-js/lazrjs/picker/tests/picker.js

  • Committer: Sidnei da Silva
  • Date: 2010-12-17 18:03:06 UTC
  • mfrom: (166.11.19 toolchain)
  • Revision ID: sidnei.da.silva@canonical.com-20101217180306-3g9ewp6nkbiwitia
- Merge from trunk, fix conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
848
848
    name: 'picker_text_field_plugin',
849
849
 
850
850
    setUp: function() {
851
 
        var node = Y.one(document.body).appendChild(
852
 
            Y.Node.create('<input id="field.initval" value="foo" />'));
 
851
        this.search_input = Y.Node.create(
 
852
                '<input id="field.initval" value="foo" />');
 
853
        var node = Y.one(document.body).appendChild(this.search_input);
853
854
        this.picker = new Y.lazr.Picker();
854
855
        this.picker.plug(Y.lazr.TextFieldPickerPlugin,
855
856
                         {input_element: '[id="field.initval"]'});
868
869
    test_TextFieldPickerPlugin_selected_item_is_saved: function () {
869
870
        this.picker.set('results', [{'title': 'Object 1', value: 'first'}]);
870
871
        this.picker.render();
 
872
        var got_focus = false;
 
873
        this.search_input.on('focus', function(e) {
 
874
            got_focus = true;
 
875
        });
871
876
        simulate(
872
877
            this.picker.get('boundingBox'), '.yui3-picker-results li', 'click');
873
878
        Assert.areEqual(
874
879
            'first', Y.Node.getDOMNode(Y.one('[id="field.initval"]')).value);
 
880
        Assert.isTrue(got_focus, "focus didn't go to the search input.");
875
881
    },
876
882
 
877
883
}));