summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/tags/data
diff options
context:
space:
mode:
authorOla Bini <ola.bini@gmail.com>2014-07-31 19:29:33 -0300
committerOla Bini <ola.bini@gmail.com>2014-07-31 19:29:33 -0300
commit04cf441c5ae18400c6b4865b0b37a71718dc9d46 (patch)
treedd0b0d049ec00389e2d4561b226c46eb1682b997 /web-ui/test/spec/tags/data
parent639a663a4c37020003586438fdcd7ac529a00f10 (diff)
Add web-ui based on previous code
Diffstat (limited to 'web-ui/test/spec/tags/data')
-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});
+ });
+});