From 8ce1930f0daf2a815bdea486880154437061f49e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 26 Jan 2017 10:34:27 -0800 Subject: [PATCH] Add specs for missing startDrag options --- atom/browser/api/atom_api_web_contents.cc | 4 ++-- spec/api-web-contents-spec.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index afb6f4c..0d52112 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -1327,7 +1327,7 @@ void WebContents::StartDrag(const mate::Dictionary& item, // Error checking. if (icon.IsEmpty()) { - args->ThrowError("icon must be set"); + args->ThrowError("Must specify non-empty 'icon' option"); return; } @@ -1337,7 +1337,7 @@ void WebContents::StartDrag(const mate::Dictionary& item, base::MessageLoop::current()); DragFileItems(files, icon->image(), web_contents()->GetNativeView()); } else { - args->ThrowError("There is nothing to drag"); + args->ThrowError("Must specify either 'file' or 'files' option"); } } diff --git a/spec/api-web-contents-spec.js b/spec/api-web-contents-spec.js index fb9c171..417b8d5 100644 --- a/spec/api-web-contents-spec.js +++ b/spec/api-web-contents-spec.js @@ -285,4 +285,20 @@ describe('webContents module', function () { }) w.webContents.inspectElement(10, 10) }) + + describe('startDrag({file, icon})', () => { + it('throws errors for a missing file or a missing/empty icon', () => { + assert.throws(() => { + w.webContents.startDrag({icon: path.join(__dirname, 'fixtures', 'assets', 'logo.png')}) + }, /Must specify either 'file' or 'files' option/) + + assert.throws(() => { + w.webContents.startDrag({file: __filename, icon: __filename}) + }, /Must specify non-empty 'icon' option/) + + assert.throws(() => { + w.webContents.startDrag({file: __filename}) + }, /Must specify non-empty 'icon' option/) + }) + }) }) -- 2.7.4