Blame view

framework/thirdparty/jasmine-ajax/spec/javascripts/fake-xml-http-request-spec.js 1.06 KB
0084d336   Administrator   Importers CRUD
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
  describe("FakeXMLHttpRequest", function() {
    var xhr;
    beforeEach(function() {
      xhr = new FakeXMLHttpRequest();
    });
    it("should have an initial readyState of 0 (uninitialized)", function() {
      expect(xhr.readyState).toEqual(0);
    });
    describe("when opened", function() {
      beforeEach(function() {
        xhr.open("GET", "http://example.com")
      });
      it("should have a readyState of 1 (open)", function() {
        expect(xhr.readyState).toEqual(1);
      });
  
      describe("when sent", function() {
        it("should have a readyState of 2 (sent)", function() {
          xhr.send(null);
          expect(xhr.readyState).toEqual(2);
        });
      });
  
      describe("when a response comes in", function() {
        it("should have a readyState of 4 (loaded)", function() {
          xhr.response({status: 200});
          expect(xhr.readyState).toEqual(4);
        });
      });
  
      describe("when aborted", function() {
        it("should have a readyState of 0 (uninitialized)", function() {
          xhr.abort();
          expect(xhr.readyState).toEqual(0);
        });
      });
    });
  });