Skip to content
Extraits de code Groupes Projets
Valider 257d6f41 rédigé par Dan Hansen & Sarah Mei's avatar Dan Hansen & Sarah Mei
Parcourir les fichiers

Top-level Diaspora object for js widget management

parent 78fb5fec
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
var Diaspora = Diaspora || {};
Diaspora.widgets = Diaspora.widgets || {
pageWidgets: {},
add: function(widgetId, widget) {
this.pageWidgets[widgetId] = widget;
},
remove: function(widgetId) {
delete this.pageWidgets[widgetId];
},
init: function() {
for (var widgetId in this.pageWidgets) {
this.pageWidgets[widgetId].start();
}
}
};
\ No newline at end of file
describe("Diaspora", function() {
describe("widgets", function() {
beforeEach(function() {
Diaspora.widgets.pageWidgets = {};
});
describe("add", function() {
it("adds a widget to the list of pageWidgets", function() {
expect(Diaspora.widgets.pageWidgets["nameOfWidget"]).not.toBeDefined();
Diaspora.widgets.add("nameOfWidget", {});
expect(Diaspora.widgets.pageWidgets["nameOfWidget"]).toBeDefined();
});
});
describe("remove", function() {
it("removes a widget from the list of pageWidgets", function() {
Diaspora.widgets.add("nameOfWidget", {});
expect(Diaspora.widgets.pageWidgets["nameOfWidget"]).toBeDefined();
Diaspora.widgets.remove("nameOfWidget");
expect(Diaspora.widgets.pageWidgets["nameOfWidget"]).not.toBeDefined();
});
});
describe("init", function() {
Diaspora.widgets.add("nameOfWidget", {start:$.noop});
spyOn(Diaspora.widgets.pageWidgets["nameOfWidget"], "start");
Diaspora.widgets.init();
expect(Diaspora.widgets.pageWidgets["nameOfWidget"].start).toHaveBeenCalled();
});
});
});
...@@ -14,6 +14,7 @@ src_files: ...@@ -14,6 +14,7 @@ src_files:
- public/javascripts/vendor/jquery144.js - public/javascripts/vendor/jquery144.js
- public/javascripts/vendor/jquery-ui-1.8.6.custom.min.js - public/javascripts/vendor/jquery-ui-1.8.6.custom.min.js
- public/javascripts/vendor/jquery.tipsy.js - public/javascripts/vendor/jquery.tipsy.js
- public/javascripts/diaspora.js
- public/javascripts/mobile.js - public/javascripts/mobile.js
- public/javascripts/aspect-edit.js - public/javascripts/aspect-edit.js
- public/javascripts/web-socket-receiver.js - public/javascripts/web-socket-receiver.js
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter