diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-08-18 14:58:22 -0300 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-08-18 15:15:32 -0300 |
commit | 7b7e5f1a6fd5926670917af735b2eda75fa332ee (patch) | |
tree | e7fafb4a782514a4b35179a077357f5efa2f604c /web-ui/test/spec/tags/ui/tag_shortcut.spec.js | |
parent | 0ef62a242c8b8bb5a39dc5d4b1fc75123e9f70d8 (diff) |
Duda/Patrick #8: reseting tag shortcuts before loading them again
Diffstat (limited to 'web-ui/test/spec/tags/ui/tag_shortcut.spec.js')
-rw-r--r-- | web-ui/test/spec/tags/ui/tag_shortcut.spec.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/web-ui/test/spec/tags/ui/tag_shortcut.spec.js b/web-ui/test/spec/tags/ui/tag_shortcut.spec.js index 5e464350..ba44304e 100644 --- a/web-ui/test/spec/tags/ui/tag_shortcut.spec.js +++ b/web-ui/test/spec/tags/ui/tag_shortcut.spec.js @@ -7,9 +7,14 @@ describeComponent("tags/ui/tag_shortcut", function () { component = jasmine.createSpyObj('tagComponent', ['triggerSelect']); parent = $("<ul>"); + $('body').append(parent); shortcut = TagShortcut.appendedTo(parent, { linkTo: { name: 'inbox', counts: { total: 15 }}, trigger: component }); }); + afterEach(function () { + $('body')[0].removeChild(parent[0]) + }); + 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>'); @@ -32,4 +37,18 @@ describeComponent("tags/ui/tag_shortcut", function () { expect(component.triggerSelect).toHaveBeenCalled(); }); + it('teardown shortcuts on event but only if they are not in the DOM', function () { + parent.empty(); + var shortcutAddedAfterEmptyingParent = TagShortcut.appendedTo(parent, { linkTo: { name: 'inbox', counts: { total: 15 }}, trigger: component }); + // by now shorcut is not in the DOM anymore but shortcutAddedAfterEmptyingParent is + + spyOn(shortcut, 'teardown'); + spyOn(shortcutAddedAfterEmptyingParent, 'teardown'); + + $(document).trigger(Pixelated.events.tags.shortcuts.teardown); + + expect(shortcut.teardown).toHaveBeenCalled(); + expect(shortcutAddedAfterEmptyingParent.teardown).not.toHaveBeenCalled(); + }); }); + |