~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/app/javascript/tests/test_picker.js

  • Committer: Ian Booth
  • Date: 2011-04-19 15:10:57 UTC
  • mfrom: (12868 devel)
  • mto: This revision was merged to the branch mainline in revision 12983.
  • Revision ID: ian.booth@canonical.com-20110419151057-he56y6k29c4zeiyk
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
        Assert.isTrue(save_flag.event_has_fired, "save event wasn't fired.");
119
119
    },
120
120
 
 
121
    test_TextFieldPickerPlugin_selected_item_is_saved: function () {
 
122
        // Test that the picker saves the selected value to its associated
 
123
        // textfield if one is defined.
 
124
        var search_input = Y.Node.create(
 
125
                '<input id="field.initval" value="foo" />');
 
126
        node = Y.one(document.body).appendChild(search_input);
 
127
        this.create_picker();
 
128
        this.picker.plug(Y.lazr.TextFieldPickerPlugin,
 
129
                         {input_element: '[id="field.initval"]'});
 
130
        this.picker.set('results', this.vocabulary);
 
131
        this.picker.render();
 
132
        var got_focus = false;
 
133
        search_input.on('focus', function(e) {
 
134
            got_focus = true;
 
135
        });
 
136
        simulate(
 
137
            this.picker.get('boundingBox').one('.yui3-picker-results'),
 
138
                'li:nth-child(1)', 'click');
 
139
        Assert.areEqual(
 
140
            'fred', Y.one('[id="field.initval"]').get("value"));
 
141
        Assert.isTrue(got_focus, "focus didn't go to the search input.");
 
142
    },
 
143
 
121
144
    test_confirmation_yes: function() {
122
145
        // Test that the picker saves the selected value if the user answers
123
146
        // "Yes" to a confirmation request.