~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

[r=jcsackett][bug=801388] Ensure the person picker only shows "assign
        me" and "remove assignee" links when required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
            {
80
80
                "step_title": "Choose someone",
81
81
                "header": "Pick Someone",
82
 
                "remove_button_text": "Remove someone",
83
82
                "null_display_value": "Noone",
84
83
                "show_remove_button": true,
85
84
                "show_assign_me_button": true,
282
281
        delete window.LP;
283
282
    },
284
283
 
285
 
    create_picker: function(show_assign_me, show_remove, field_value) {
 
284
    create_picker: function(
 
285
        show_assign_me_button, show_remove_button, field_value) {
286
286
        if (field_value !== undefined) {
287
287
            var data_box = Y.one('#picker_id .yui3-activator-data-box');
288
288
            data_box.appendChild(Y.Node.create('<a>Content</a>'));
294
294
            "header": "Pick Someone",
295
295
            "validate_callback": null,
296
296
            "show_search_box": true,
297
 
            "show_assign_me_button": show_assign_me,
298
 
            "show_remove_button": show_remove
 
297
            "show_assign_me_button": show_assign_me_button,
 
298
            "show_remove_button": show_remove_button,
 
299
            "assign_button_text": "Assign Moi",
 
300
            "remove_button_text": "Remove someone"
299
301
            };
300
302
        this.picker = Y.lp.app.picker.addPickerPatcher(
301
303
                this.vocabulary,
327
329
        this._check_button_state('.yui-picker-remove-button', is_visible);
328
330
    },
329
331
 
 
332
    test_picker_assign_me_button_text: function() {
 
333
        // The assign me button text is correct.
 
334
        this.create_picker(true, true);
 
335
        this.picker.render();
 
336
        var assign_me_button = Y.one('.yui-picker-assign-me-button');
 
337
        Assert.areEqual('Assign Moi', assign_me_button.get('innerHTML'));
 
338
    },
 
339
 
 
340
    test_picker_remove_button_text: function() {
 
341
        // The remove button text is correct.
 
342
        this.create_picker(true, true);
 
343
        this.picker.render();
 
344
        var remove_button = Y.one('.yui-picker-remove-button');
 
345
        Assert.areEqual('Remove someone', remove_button.get('innerHTML'));
 
346
    },
 
347
 
330
348
    test_picker_has_assign_me_button: function() {
331
349
        // The assign me button is shown.
332
350
        this.create_picker(true, true);