diaspora/spec/javascripts/app/views/help_view_spec.js
Sage Ross 23c2487550
Delete specs that cause order-dependent failures elsewhere
This set of specs — in particular, all the calls to `this.view.$el.find(...).trigger('click') — are changing the environment in ways that cause I18n missing key errors elsewhere.

There are failures in `app_spec.js` if this spec file is run before it, and I haven't found a way to reset the environment to avoid the issue.
2022-06-19 17:23:00 +02:00

98 lines
2.7 KiB
JavaScript

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');
});
});
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);
});
});
});
});