summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/tags/data/tags.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/test/spec/tags/data/tags.spec.js')
-rw-r--r--web-ui/test/spec/tags/data/tags.spec.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/web-ui/test/spec/tags/data/tags.spec.js b/web-ui/test/spec/tags/data/tags.spec.js
new file mode 100644
index 00000000..8e7d33c3
--- /dev/null
+++ b/web-ui/test/spec/tags/data/tags.spec.js
@@ -0,0 +1,39 @@
+describeComponent('tags/data/tags', function () {
+ 'use strict';
+
+ beforeEach(function () {
+ setupComponent();
+ });
+
+ it('asks the server for tags when receiving the tags:want event', function() {
+ spyOn($, 'ajax').andReturn({done: function() {}});
+
+ this.component.trigger(Smail.events.tags.want);
+
+ expect($.ajax.mostRecentCall.args[0]).toEqual('/tags');
+ });
+
+ it('triggers an event on the initial sender after receiving tags', function() {
+ var f;
+ spyOn($, 'ajax').andReturn({done: function(d) { f = d; }});
+ var me = {};
+ var eventSpy = spyOnEvent(me, Smail.events.tags.received);
+
+ this.component.trigger(Smail.events.tags.want, { caller: me});
+
+ f(['foo', 'bar', 'quux/bar']);
+ expect(eventSpy).toHaveBeenTriggeredOn(me);
+ });
+
+ it('triggers an event containing the returned tags', function() {
+ var f;
+ spyOn($, 'ajax').andReturn({done: function(d) { f = d; }});
+ var me = {};
+ var eventSpy = spyOnEvent(me, Smail.events.tags.received);
+ this.component.trigger(Smail.events.tags.want, { caller: me });
+ var tags = ['foo', 'bar', 'quux/bar'];
+ f(tags);
+ tags.push(this.component.all);
+ expect(eventSpy.mostRecentCall.data).toEqual({tags: tags});
+ });
+});