~launchpad-pqm/launchpad/devel

14617.2.2 by William Grant
Update a few templates.
1
/* Copyright (c) 2012, Canonical Ltd. All rights reserved. */
13885.3.4 by Graham Binns
Added standard_test_template.(js|html) to help people not have to cargo-cult boilerplate.
2
YUI({
3
    base: '../../../../canonical/launchpad/icing/yui/',
4
    filter: 'raw',
5
    combine: false,
6
    fetchCSS: false
7
8
// Don't forget to add the module under test to the use() clause.
9
10
      }).use('event', 'lp.client', 'node', 'test', 'widget-stack',
11
             'console', function(Y) {
12
13
// Local aliases
14
var Assert = Y.Assert,
15
    ArrayAssert = Y.ArrayAssert;
13885.3.6 by Graham Binns
Updated the test templates to make them match the wiki.
16
var mynamespace = Y.lp.mynamespace;
17
var suite = new Y.Test.Suite("mynamespace Tests");
13885.3.4 by Graham Binns
Added standard_test_template.(js|html) to help people not have to cargo-cult boilerplate.
18
19
suite.add(new Y.Test.Case({
13885.3.6 by Graham Binns
Updated the test templates to make them match the wiki.
20
    // Test the setup method.
21
    name: 'setup',
13885.3.4 by Graham Binns
Added standard_test_template.(js|html) to help people not have to cargo-cult boilerplate.
22
13885.3.6 by Graham Binns
Updated the test templates to make them match the wiki.
23
    _should: {
24
        error: {
14027.3.1 by Jeroen Vermeulen
Fix lots of lint in recently-changed files.
25
            test_config_undefined: true
26
            // Careful: no comma after last item or IE chokes.
13885.3.6 by Graham Binns
Updated the test templates to make them match the wiki.
27
            }
28
        },
13885.3.4 by Graham Binns
Added standard_test_template.(js|html) to help people not have to cargo-cult boilerplate.
29
30
    setUp: function() {
13885.3.6 by Graham Binns
Updated the test templates to make them match the wiki.
31
        this.tbody = Y.get('#milestone-rows');
32
        },
13885.3.4 by Graham Binns
Added standard_test_template.(js|html) to help people not have to cargo-cult boilerplate.
33
34
    tearDown: function() {
13885.3.6 by Graham Binns
Updated the test templates to make them match the wiki.
35
        delete this.tbody;
36
        mynamespace._milestone_row_uri_template = null;
37
        mynamespace._tbody = null;
38
        },
39
40
    test_good_config: function() {
41
        // Verify the config data is stored.
42
        var config = {
43
            milestone_row_uri_template: '/uri',
44
            milestone_rows_id:  '#milestone-rows'
45
            };
46
        mynamespace.setup(config);
47
        Y.Assert.areSame(
48
            config.milestone_row_uri_template,
49
            mynamespace._milestone_row_uri_template);
50
        Y.Assert.areSame(this.tbody, mynamespace._tbody);
51
        },
52
53
    test_config_undefined: function() {
54
        // Verify an error is thrown if there is no config.
55
        mynamespace.setup();
14027.3.1 by Jeroen Vermeulen
Fix lots of lint in recently-changed files.
56
        }
57
        // Careful: no comma after last item or IE chokes.
13885.3.4 by Graham Binns
Added standard_test_template.(js|html) to help people not have to cargo-cult boilerplate.
58
}));
59
13885.3.6 by Graham Binns
Updated the test templates to make them match the wiki.
60
13885.3.4 by Graham Binns
Added standard_test_template.(js|html) to help people not have to cargo-cult boilerplate.
61
var handle_complete = function(data) {
62
    window.status = '::::' + JSON.stringify(data);
63
    };
64
Y.Test.Runner.on('complete', handle_complete);
65
Y.Test.Runner.add(suite);
66
67
var yconsole = new Y.Console({
68
    newestOnTop: false
69
});
70
yconsole.render('#log');
71
72
Y.on('domready', function() {
73
    Y.Test.Runner.run();
74
});
75
76
});