~bjornt/lazr-js/prefetch-yui-3.5

« back to all changes in this revision

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

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-01-14 23:32:29 UTC
  • mfrom: (197.1.7 yui-3.3.0)
  • Revision ID: launchpad@pqm.canonical.com-20110114233229-r6i4cazdiiw18o7p
Upgrade to YUI 3.3.0 [r=mars]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
2
2
 
3
 
YUI({
4
 
    base: '../../yui/',
5
 
    filter: 'raw',
6
 
    combine: false
7
 
    }).use('lazr.activator', 'lazr.testing.runner', 'node',
 
3
YUI().use('lazr.activator', 'lazr.testing.runner', 'node',
8
4
           'event', 'event-simulate', 'console', function(Y) {
9
5
 
10
6
var Assert = Y.Assert;  // For easy access to isTrue(), etc.
14
10
 * CSS selectors and Node instances instead of raw nodes.
15
11
 */
16
12
function simulate(selector, evtype) {
17
 
    var rawnode = Y.Node.getDOMNode(Y.get(selector));
 
13
    var rawnode = Y.Node.getDOMNode(Y.one(selector));
18
14
    Y.Event.simulate(rawnode, evtype);
19
15
}
20
16
 
37
33
    name: 'activator_basics',
38
34
 
39
35
    setUp: function() {
40
 
        this.workspace = Y.get('#workspace');
 
36
        this.workspace = Y.one('#workspace');
41
37
        if (!this.workspace){
42
 
            Y.get(document.body).appendChild(Y.Node.create(
 
38
            Y.one(document.body).appendChild(Y.Node.create(
43
39
                '<div id="workspace" ' +
44
40
                'style="border: 1px solid blue; ' +
45
41
                'width: 20em; ' +
46
42
                'margin: 1em; ' +
47
43
                'padding: 1em">'+
48
44
                '</div>'));
49
 
            this.workspace = Y.get('#workspace');
 
45
            this.workspace = Y.one('#workspace');
50
46
        }
51
47
        this.workspace.appendChild(Y.Node.create(
52
48
            '<div id="example-1">' +
61
57
            '</div>' +
62
58
            '</div>'));
63
59
        this.activator = new Y.lazr.activator.Activator(
64
 
            {contentBox: Y.get('#example-1')});
 
60
            {contentBox: Y.one('#example-1')});
65
61
        this.action_button = this.activator.get('contentBox').one(
66
62
            '.yui3-activator-act');
67
63
    },
82
78
    },
83
79
 
84
80
    test_simulate_click_on_action_button: function() {
 
81
        var fired = false;
85
82
        this.activator.render();
86
83
        this.activator.subscribe('act', function(e) {
87
 
            this.resume();
 
84
            fired = true;
88
85
        }, this);
89
86
        simulate(this.action_button, 'click');
90
 
        this.wait(function () {
91
 
            Assert.fail("'act' event wasn't fired.");
92
 
        }, 3000);
 
87
        Assert.isTrue(fired, "'act' event wasn't fired.");
93
88
    },
94
89
 
95
90
    test_renderSuccess: function() {