~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* Copyright (c) 2011, Canonical Ltd. All rights reserved. */
YUI({
    base: '../../../../canonical/launchpad/icing/yui/',
    filter: 'raw',
    combine: false,
    fetchCSS: false

// Don't forget to add the module under test to the use() clause.

      }).use('event', 'lp.client', 'node', 'test', 'widget-stack',
             'console', function(Y) {

// Local aliases
var Assert = Y.Assert,
    ArrayAssert = Y.ArrayAssert;
var mynamespace = Y.lp.mynamespace;
var suite = new Y.Test.Suite("mynamespace Tests");

suite.add(new Y.Test.Case({
    // Test the setup method.
    name: 'setup',

    _should: {
        error: {
            test_config_undefined: true
            // Careful: no comma after last item or IE chokes.
            }
        },

    setUp: function() {
        this.tbody = Y.get('#milestone-rows');
        },

    tearDown: function() {
        delete this.tbody;
        mynamespace._milestone_row_uri_template = null;
        mynamespace._tbody = null;
        },

    test_good_config: function() {
        // Verify the config data is stored.
        var config = {
            milestone_row_uri_template: '/uri',
            milestone_rows_id:  '#milestone-rows'
            };
        mynamespace.setup(config);
        Y.Assert.areSame(
            config.milestone_row_uri_template,
            mynamespace._milestone_row_uri_template);
        Y.Assert.areSame(this.tbody, mynamespace._tbody);
        },

    test_config_undefined: function() {
        // Verify an error is thrown if there is no config.
        mynamespace.setup();
        }
        // Careful: no comma after last item or IE chokes.
}));


var handle_complete = function(data) {
    window.status = '::::' + JSON.stringify(data);
    };
Y.Test.Runner.on('complete', handle_complete);
Y.Test.Runner.add(suite);

var yconsole = new Y.Console({
    newestOnTop: false
});
yconsole.render('#log');

Y.on('domready', function() {
    Y.Test.Runner.run();
});

});