From f399c739bc6ed2a6dcc96eff8bd93a058e5122a8 Mon Sep 17 00:00:00 2001 From: Audrey So Date: Thu, 20 Jul 2017 13:23:11 -0700 Subject: [PATCH] CB-12361 : added tests for plugin/search.js and rebased --- spec/cordova/plugin/search.spec.js | 33 +++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/spec/cordova/plugin/search.spec.js b/spec/cordova/plugin/search.spec.js index 33e4d480a..02eaaa142 100644 --- a/spec/cordova/plugin/search.spec.js +++ b/spec/cordova/plugin/search.spec.js @@ -44,7 +44,34 @@ describe('cordova/plugin/search', function () { console.error(e); }).done(done); }); - it('should open a link to cordova.apache.org/plugins if no plugins are provided as parameter'); - it('should open a link to cordova.apache.org/plugins, providing the plugins passed in as a query-string parameter'); - it('should fire the after_plugin_search hook'); + + it('should open a link to cordova.apache.org/plugins if no plugins are provided as parameter', function (done) { + var opts = {important: 'options', plugins: []}; + search(hook_mock, opts).then(function () { + expect(opener_mock).toHaveBeenCalled(); + }).fail(function (e) { + fail('fail handler unexpectedly invoked'); + console.error(e); + }).done(done); + }); + + it('should open a link to cordova.apache.org/plugins, providing the plugins passed in as a query-string parameter', function (done) { + var opts = {important: 'options', plugins: ['cordova-plugin-camera', 'cordova-plugin-splashscreen']}; + search(hook_mock, opts).then(function () { + expect(opener_mock).toHaveBeenCalled(); + }).fail(function (e) { + fail('fail handler unexpectedly invoked'); + console.error(e); + }).done(done); + }); + + it('should fire the after_plugin_search hook', function (done) { + var opts = {important: 'options', plugins: []}; + search(hook_mock, opts).then(function () { + expect(hook_mock.fire).toHaveBeenCalledWith('after_plugin_search', opts); + }).fail(function (e) { + fail('fail handler unexpectedly invoked'); + console.error(e); + }).done(done); + }); });