~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/javascript/tests/test_requestbuild_overlay.js

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-24 14:50:26 UTC
  • mfrom: (13776.1.1 devel-rollback-13766)
  • Revision ID: launchpad@pqm.canonical.com-20110824145026-uy68vw9fjv2kqgog
[r=henninge][rollback=13766] Rollback r13766 because it breaks js
 code by referencing an unavailable module.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Copyright (c) 2011, Canonical Ltd. All rights reserved. */
2
2
 
3
3
YUI().use('test', 'console', 'node-event-simulate',
4
 
          'lp.testing.mockio', 'lp.testing.runner',
 
4
          'lp.testing.iorecorder', 'lp.testing.runner',
5
5
          'lp.code.requestbuild_overlay', function(Y) {
6
6
 
7
7
var suite = new Y.Test.Suite("lp.code.requestbuild_overlay Tests");
17
17
    name: "lp.code.requestbuild_overlay",
18
18
 
19
19
    setUp: function() {
20
 
        LP.cache.context = {
 
20
        LP.cache['context'] = {
21
21
            web_link: "http://code.launchpad.dev/~foobar/myrecipe"};
22
22
        // Prepare testbed.
23
23
        var testbed = Y.one("#testbed").set('innerHTML', '');
34
34
    },
35
35
 
36
36
    _makeRequest: function() {
37
 
        var mockio = new Y.lp.testing.mockio.MockIo();
 
37
        var recorder = new Y.lp.testing.iorecorder.IORecorder();
38
38
        var build_now_link = Y.one('#request-daily-build');
39
39
        build_now_link.removeClass('unseen');
40
 
        module.connect_requestdailybuild({io_provider: mockio});
 
40
        module.connect_requestdailybuild(
 
41
            {io: Y.bind(recorder.do_io, recorder)});
41
42
        build_now_link.simulate('click');
42
 
 
43
 
        Y.Assert.areSame(1, mockio.requests.length);
44
 
        return mockio;
 
43
        
 
44
        Y.Assert.areSame(1, recorder.requests.length);
 
45
        return recorder.requests[0];
45
46
    },
46
 
 
 
47
    
47
48
    test_requestbuild_success: function() {
48
 
        var mockio = this._makeRequest();
49
 
        mockio.success({
50
 
            responseText: builds_target_markup,
51
 
            responseHeaders: {'Content-Type': 'application/xhtml'}
52
 
        });
 
49
        var request = this._makeRequest();
 
50
        request.success(
 
51
            builds_target_markup,  {'Content-Type': 'application/xhtml'});
53
52
 
54
53
        // The markup has been inserted.
55
54
        Y.Assert.areSame(
69
68
 
70
69
 
71
70
    _testRequestbuildFailure: function(status, expected_message) {
72
 
        var mockio = this._makeRequest();
73
 
        mockio.respond({status: status});
 
71
        var request = this._makeRequest();
 
72
        request.respond(status, '',  {});
74
73
 
75
74
        // No build targets.
76
75
        Y.Assert.areSame(