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

help_view_spec.js « views « app « javascripts « spec - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e7383026729559420c341d33f158fb7fa1698ba6 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
describe("app.views.Help", function(){
  beforeEach(function(){
    gon.appConfig = {chat: {enabled: false}};
    this.locale = JSON.parse(spec.readFixture("locale_en_help_json"));
    Diaspora.I18n.reset();
    Diaspora.I18n.load(this.locale, "en");
    this.view = new app.views.Help();
    Diaspora.Page = "HelpFaq";
  });

  afterEach(function() {
    Diaspora.I18n.reset();
    Diaspora.I18n.load(spec.defaultLocale);
  });

  describe("render", function(){
    beforeEach(function(){
      this.view.render();
    });

    it('should initially show getting help section', function(){
      expect(this.view.$el.find('#faq').children().first().data('template')).toBe('faq_getting_help');
    });

    it('should show account and data management section', function(){
      this.view.$el.find('a[data-section=account_and_data_management]').trigger('click');
      expect(this.view.$el.find('#faq').children().first().hasClass('faq_question_account_and_data_management')).toBeTruthy();
    });

    it('should show aspects section', function(){
      this.view.$el.find('a[data-section=aspects]').trigger('click');
      expect(this.view.$el.find('#faq').children().first().hasClass('faq_question_aspects')).toBeTruthy();
    });

    it('should show mentions section', function(){
      this.view.$el.find('a[data-section=mentions]').trigger('click');
      expect(this.view.$el.find('#faq').children().first().hasClass('faq_question_mentions')).toBeTruthy();
    });

    it('should show pods section', function(){
      this.view.$el.find('a[data-section=pods]').trigger('click');
      expect(this.view.$el.find('#faq').children().first().hasClass('faq_question_pods')).toBeTruthy();
    });

    it('should show posts and posting section', function(){
      this.view.$el.find('a[data-section=posts_and_posting]').trigger('click');
      expect(this.view.$el.find('#faq').children().first().data('template')).toBe('faq_posts_and_posting');
    });

    it('should show private posts section', function(){
      this.view.$el.find('a[data-section=private_posts]').trigger('click');
      expect(this.view.$el.find('#faq').children().first().hasClass('faq_question_private_posts')).toBeTruthy();
    });

    it('should show public posts section', function(){
      this.view.$el.find('a[data-section=public_posts]').trigger('click');
      expect(this.view.$el.find('#faq').children().first().hasClass('faq_question_public_posts')).toBeTruthy();
    });

    it('should show resharing posts section', function(){
      this.view.$el.find('a[data-section=resharing_posts]').trigger('click');
      expect(this.view.$el.find('#faq').children().first().hasClass('faq_question_resharing_posts')).toBeTruthy();
    });

    it("should show profile section", function() {
      this.view.$el.find("a[data-section=profile]").trigger("click");
      expect(this.view.$el.find("#faq").children().first().hasClass("faq_question_profile")).toBeTruthy();
    });

    it('should show sharing section', function(){
      this.view.$el.find('a[data-section=sharing]').trigger('click');
      expect(this.view.$el.find('#faq').children().first().data('template')).toBe('faq_sharing');
    });

    it('should show tags section', function(){
      this.view.$el.find('a[data-section=tags]').trigger('click');
      expect(this.view.$el.find('#faq').children().first().data('template')).toBe('faq_tags');
    });

    it('should show keyboard shortcuts section', function(){
      this.view.$el.find('a[data-section=keyboard_shortcuts]').trigger('click');
      expect(this.view.$el.find('#faq').children().first().data('template')).toBe('faq_keyboard_shortcuts');
    });

    it('should show miscellaneous section', function(){
      this.view.$el.find('a[data-section=miscellaneous]').trigger('click');
      expect(this.view.$el.find('#faq').children().first().hasClass('faq_question_miscellaneous')).toBeTruthy();
    });
  });

  describe("findSection", function() {
    beforeEach(function() {
      this.view.render();
    });

    it('should return null for an unknown section', function() {
      expect(this.view.findSection('you_shall_not_pass')).toBeNull();
    });

    it('should return the correct section link for existing sections', function() {
      var sections = [
        'account_and_data_management',
        'aspects',
        'pods',
        'keyboard_shortcuts',
        'tags',
        'miscellaneous'
      ];

      var self = this;
      _.each(sections, function(section) {
        var el = self.view.$el.find('a[data-section=' + section + ']');
        expect(self.view.findSection(section).html()).toBe(el.html());
      });
    });
  });

  describe("menuClicked", function() {
    beforeEach(function() {
      this.view.render();
    });

    it('should rewrite the location', function(){
      var sections = [
        'account_and_data_management',
        'miscellaneous'
      ];
      spyOn(app.router, 'navigate');

      var self = this;
      _.each(sections, function(section) {
        self.view.$el.find('a[data-section=' + section + ']').trigger('click');
        expect(app.router.navigate).toHaveBeenCalledWith('help/' + section);
      });
    });
  });

  describe("chat section", function(){
    describe("chat enabled", function(){
      beforeEach(function(){
        gon.appConfig = {chat: {enabled: true}};
        this.view = new app.views.Help();
        this.view.render();
      });

      it('should display the chat', function(){
        expect(this.view.$el.find('a[data-section=chat]').length).toBe(1);
      });
    });

    describe("chat disabled", function(){
      beforeEach(function(){
        gon.appConfig = {chat: {enabled: false}};
        this.view = new app.views.Help();
        this.view.render();
      });

      it('should not display the chat', function () {
        expect(this.view.$el.find('a[data-section=chat]').length).toBe(0);
      });
    });
  });
});