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

contacts_collection_spec.js « collections « app « javascripts « spec - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a2342851d7261661e0ea0179ecfa28a38fb5ae29 (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
describe("app.collections.Contacts", function(){
  beforeEach(function(){
    this.collection = new app.collections.Contacts();
  });

  describe("comparator", function() {
    beforeEach(function(){
      this.aspect = new app.models.Aspect({id: 42, name: "cats"});
      this.con1 = new app.models.Contact({
                    person: { name: "aaa" },
                    aspect_memberships: []
                  });
      this.con2 = new app.models.Contact({
                    person: { name: "aaa" },
                    aspect_memberships: [{id: 23, aspect: this.aspect}]
                  });
      this.con3 = new app.models.Contact({
                    person: { name: "zzz" },
                    aspect_memberships: [{id: 23, aspect: this.aspect}]
                  });
    });

    it("should compare the username if app.aspect is not present", function() {
      delete app.aspect;
      expect(this.collection.comparator(this.con1, this.con3)).toBeLessThan(0);
    });

    it("should compare the aspect memberships if app.aspect is present", function() {
      app.aspect = this.aspect;
      expect(this.collection.comparator(this.con1, this.con3)).toBeGreaterThan(0);
    });

    it("should compare the username if the contacts have equal aspect memberships", function() {
      app.aspect = this.aspect;
      expect(this.collection.comparator(this.con2, this.con3)).toBeLessThan(0);
    });
  });
});