Welcome to mirror list, hosted at ThFree Co, Russian Federation.

hovercard_view_spec.js « views « app « javascripts « spec - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c307ebceee3fcdd5058f624917805f9454536fbb (plain)
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
77
78
79
80
describe("app.views.Hovercard", function() {

  afterEach(function() {
    $("body #hovercard_container").remove();
  });

  context("user not signed in", function() {
    beforeEach(function() {
      logout();
      this.view = new app.views.Hovercard();
    });

    describe("_populateHovercard", function() {
      it("doesn't create the aspect dropdown", function() {
        this.view.parent = spec.content();
        this.view._populateHovercard();
        jasmine.Ajax.requests.mostRecent().respondWith({
          status: 200,
          responseText: JSON.stringify({id: 1337})
        });
        expect(this.view.aspectMembershipDropdown).toEqual(undefined);
      });
    });
  });

  context("user signed in", function() {
    beforeEach(function() {
      loginAs(factory.userAttrs());
      this.view = new app.views.Hovercard();
    });

    describe("initialize", function() {
      it("activates hovercards", function() {
        expect(this.view.active).toBeTruthy();
      });
    });

    describe("mouseIsOverElement", function() {
      it("returns false if the element is undefined", function() {
        expect(this.view.mouseIsOverElement(undefined, $.Event())).toBeFalsy();
      });
    });

    describe("_populateHovercard", function() {
      beforeEach(function() {
        this.view.parent = spec.content();
      });

      it("prevents global error handling for the ajax call", function() {
        spyOn(jQuery, "ajax").and.callThrough();
        this.view._populateHovercard();
        expect(jQuery.ajax).toHaveBeenCalledWith("undefined/hovercard.json", {preventGlobalErrorHandling: true});
      });

      it("creates the aspect dropdown", function() {
        this.view._populateHovercard();
        jasmine.Ajax.requests.mostRecent().respondWith({
          status: 200,
          responseText: JSON.stringify({id: 1337})
        });
        expect(this.view.aspectMembershipDropdown).not.toEqual(undefined);
      });

      it("renders tags properly", function() {
        this.view._populateHovercard();
        jasmine.Ajax.requests.mostRecent().respondWith({
          status: 200,
          responseText: JSON.stringify({id: 1337, profile: {tags: ["first", "second"]}})
        });

        var first = this.view.hashtags.find("a:contains('#first')");
        var second = this.view.hashtags.find("a:contains('#second')");
        expect(first.length).toEqual(1);
        expect(second.length).toEqual(1);
        expect(first.first()[0].href).toContain(Routes.tag("first"));
        expect(second.first()[0].href).toContain(Routes.tag("second"));
      });
    });
  });
});