aboutsummaryrefslogtreecommitdiffstats
path: root/test/caldav/http/basic_auth_test.js
blob: 566de083b66db30d1e8803385f0e03b078fa520f (plain) (blame)
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
testSupport.lib('xhr');
testSupport.lib('connection');
testSupport.lib('http/basic_auth');
testSupport.helper('fake_xhr');

suite('http/basic_auth', function() {

  var XHR;
  var FakeXhr;
  var Connection;
  var BasicAuth;

  suiteSetup(function() {
    FakeXhr = Caldav.require('support/fake_xhr');
    XHR = Caldav.require('xhr');
    Connection = Caldav.require('connection');
    BasicAuth = Caldav.require('http/basic_auth');
  });

  var subject;
  var connection;
  var url = 'http://foo.com/bar';

  setup(function() {
    connection = new Connection({
      user: 'jlal',
      password: 'foo',
      domain: 'google.com'
    });

    subject = new BasicAuth(connection, {
      url: url,
      xhrClass: FakeXhr
    });
  });

  test('initialization', function() {
    assert.instanceOf(subject, XHR);
    assert.equal(subject.url, url);
  });

  test('#send', function() {
    var xhr = subject.send();

    assert.deepEqual(
      xhr.openArgs,
      [
        'GET',
        url,
        subject.async,
        connection.user,
        connection.password
      ]
    );
  });

});