From 4545671dcfc8580470afb6924f99f05a15632881 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 15 Apr 2015 14:20:16 -0700 Subject: [PATCH] Move file drag and drop specs to pane-view-spec --- spec/pane-view-spec.coffee | 27 +++++++++++++++++++++++++++ spec/window-spec.coffee | 27 --------------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/spec/pane-view-spec.coffee b/spec/pane-view-spec.coffee index ecb8b259d..19fa247e0 100644 --- a/spec/pane-view-spec.coffee +++ b/spec/pane-view-spec.coffee @@ -360,3 +360,30 @@ describe "PaneView", -> pane3 = container3.getRoot() container3.attachToDom() expect(pane3).not.toMatchSelector(':has(:focus)') + + describe "drag and drop", -> + buildDragEvent = (type, files) -> + dataTransfer = + files: files + data: {} + setData: (key, value) -> @data[key] = value + getData: (key) -> @data[key] + + event = new CustomEvent("drop") + event.dataTransfer = dataTransfer + event + + describe "when a file is dragged to window", -> + it "opens it", -> + spyOn(atom, "open") + event = buildDragEvent("drop", [ {path: "/fake1"}, {path: "/fake2"} ]) + pane[0].dispatchEvent(event) + expect(atom.open.callCount).toBe 1 + expect(atom.open.argsForCall[0][0]).toEqual pathsToOpen: ['/fake1', '/fake2'] + + describe "when a non-file is dragged to window", -> + it "does nothing", -> + spyOn(atom, "open") + event = buildDragEvent("drop", []) + pane[0].dispatchEvent(event) + expect(atom.open).not.toHaveBeenCalled() diff --git a/spec/window-spec.coffee b/spec/window-spec.coffee index 3c1a5b4ae..376a71ab3 100644 --- a/spec/window-spec.coffee +++ b/spec/window-spec.coffee @@ -141,33 +141,6 @@ describe "Window", -> expect(buffer.getSubscriptionCount()).toBe 0 - describe "drag and drop", -> - buildDragEvent = (type, files) -> - dataTransfer = - files: files - data: {} - setData: (key, value) -> @data[key] = value - getData: (key) -> @data[key] - - event = new CustomEvent("drop") - event.dataTransfer = dataTransfer - event - - describe "when a file is dragged to window", -> - it "opens it", -> - spyOn(atom, "open") - event = buildDragEvent("drop", [ {path: "/fake1"}, {path: "/fake2"} ]) - document.dispatchEvent(event) - expect(atom.open.callCount).toBe 1 - expect(atom.open.argsForCall[0][0]).toEqual pathsToOpen: ['/fake1', '/fake2'] - - describe "when a non-file is dragged to window", -> - it "does nothing", -> - spyOn(atom, "open") - event = buildDragEvent("drop", []) - document.dispatchEvent(event) - expect(atom.open).not.toHaveBeenCalled() - describe "when a link is clicked", -> it "opens the http/https links in an external application", -> shell = require 'shell'