summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/tags/ui/tag_shortcut.spec.js
blob: 7df356314b9539e9acdc08f4035cf1b73de32938 (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
describeComponent("tags/ui/tag_shortcut", function () {

  var parent, shortcut, component, TagShortcut;

  beforeEach(function () {
    TagShortcut = require('tags/ui/tag_shortcut');

    component = jasmine.createSpyObj('tagComponent', ['triggerSelect']);
    parent = $("<ul>");
    shortcut = TagShortcut.appendedTo(parent, { linkTo: { name: 'inbox', counts: { total: 15 }}, trigger: component });
  });

  it('renders the shortcut inside the parent', function () {
    expect(parent.html()).toMatch('<a title="inbox">');
    expect(parent.html()).toMatch('<i class="fa fa-inbox"></i>');
    expect(parent.html()).toMatch('<div class="shortcut-label">inbox</div>');
  });

  it('selects and unselect on tag.select', function () {
    $(document).trigger(Smail.events.ui.tag.select, { tag: 'inbox'});

    expect(shortcut.$node).toHaveClass("selected");

    $(document).trigger(Smail.events.ui.tag.select, { tag: 'sent'});

    expect(shortcut.$node).not.toHaveClass("selected");
  });

  it('delegates the click to linked tag', function (){
    shortcut.$node.click();

    expect(component.triggerSelect).toHaveBeenCalled();
  });

});