From 57f606dacf4ed2a37b317d2a36129045199080f8 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Fri, 11 Jul 2014 23:34:19 +0200 Subject: [PATCH 1/4] Adding tests --- plugin.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin.xml b/plugin.xml index 94211f2..065a983 100755 --- a/plugin.xml +++ b/plugin.xml @@ -21,6 +21,9 @@ + + + From b7bc165d73156ccc57264cd2094b77f650135622 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Fri, 11 Jul 2014 23:36:12 +0200 Subject: [PATCH 2/4] Adding tests --- test/tests.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/tests.js diff --git a/test/tests.js b/test/tests.js new file mode 100644 index 0000000..3e8cf73 --- /dev/null +++ b/test/tests.js @@ -0,0 +1,19 @@ +exports.defineAutoTests = function() { + + define('awesome tests', function() { + it('do something sync', function() { + expect(1).toBe(1); + }); + + it('do something async', function(done) { + setTimeout(function() { + expect(1).toBe(1); + done(); + }, 100); + }); + }); + + //define('more awesome tests', function() { + //}); + +}; From 489d71aadc0b56cfef4d5f8bb220542bfda6c05a Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Fri, 11 Jul 2014 23:51:42 +0200 Subject: [PATCH 3/4] Update tests.js --- test/tests.js | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/test/tests.js b/test/tests.js index 3e8cf73..bef677d 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,19 +1,38 @@ exports.defineAutoTests = function() { - - define('awesome tests', function() { - it('do something sync', function() { - expect(1).toBe(1); + describe('Plugin availability (window.plugins.toast)', function () { + it("should exist", function() { + expect(window.plugins.toast).toBeDefined(); }); - it('do something async', function(done) { - setTimeout(function() { - expect(1).toBe(1); - done(); - }, 100); + it("should contain a platform specification that is a string", function() { + expect(window.plugins.toastnot).toBeDefined(); +// expect((new String(window.device.platform)).length > 0).toBe(true); }); + + /* + it("should contain a version specification that is a string", function() { + expect(window.device.version).toBeDefined(); + expect((new String(window.device.version)).length > 0).toBe(true); + }); + + it("should contain a UUID specification that is a string or a number", function() { + expect(window.device.uuid).toBeDefined(); + if (typeof window.device.uuid == 'string' || typeof window.device.uuid == 'object') { + expect((new String(window.device.uuid)).length > 0).toBe(true); + } else { + expect(window.device.uuid > 0).toBe(true); + } + }); + + it("should contain a cordova specification that is a string", function() { + expect(window.device.cordova).toBeDefined(); + expect((new String(window.device.cordova)).length > 0).toBe(true); + }); + + it("should contain a model specification that is a string", function() { + expect(window.device.model).toBeDefined(); + expect((new String(window.device.model)).length > 0).toBe(true); + }); + */ }); - - //define('more awesome tests', function() { - //}); - }; From 91d06c6dd814b66416cba0310c508b6e6ea3dd05 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Sat, 12 Jul 2014 20:49:48 +0200 Subject: [PATCH 4/4] Update tests.js --- test/tests.js | 69 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/test/tests.js b/test/tests.js index bef677d..1d079d4 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,38 +1,59 @@ -exports.defineAutoTests = function() { - describe('Plugin availability (window.plugins.toast)', function () { - it("should exist", function() { +cordova.define("nl.x-services.plugins.toast.tests", function(require, exports, module) { exports.defineAutoTests = function() { + + var fail = function (done) { + expect(true).toBe(false); + done(); + }, + succeed = function (done) { + expect(true).toBe(true); + done(); + }; + + describe('Plugin availability', function () { + it("window.plugins.toast should exist", function() { expect(window.plugins.toast).toBeDefined(); }); + }); - it("should contain a platform specification that is a string", function() { - expect(window.plugins.toastnot).toBeDefined(); -// expect((new String(window.device.platform)).length > 0).toBe(true); + describe('API functions', function () { + it("should define show", function() { + expect(window.plugins.toast.show).toBeDefined(); }); - /* - it("should contain a version specification that is a string", function() { - expect(window.device.version).toBeDefined(); - expect((new String(window.device.version)).length > 0).toBe(true); + it("should define showShortTop", function() { + expect(window.plugins.toast.showShortTop).toBeDefined(); }); - it("should contain a UUID specification that is a string or a number", function() { - expect(window.device.uuid).toBeDefined(); - if (typeof window.device.uuid == 'string' || typeof window.device.uuid == 'object') { - expect((new String(window.device.uuid)).length > 0).toBe(true); - } else { - expect(window.device.uuid > 0).toBe(true); - } + it("should define showShortCenter", function() { + expect(window.plugins.toast.showShortCenter).toBeDefined(); }); - it("should contain a cordova specification that is a string", function() { - expect(window.device.cordova).toBeDefined(); - expect((new String(window.device.cordova)).length > 0).toBe(true); + it("should define showShortBottom", function() { + expect(window.plugins.toast.showShortBottom).toBeDefined(); }); - it("should contain a model specification that is a string", function() { - expect(window.device.model).toBeDefined(); - expect((new String(window.device.model)).length > 0).toBe(true); + it("should define showLongTop", function() { + expect(window.plugins.toast.showLongTop).toBeDefined(); + }); + + it("should define showLongCenter", function() { + expect(window.plugins.toast.showLongCenter).toBeDefined(); + }); + + it("should define showLongBottom", function() { + expect(window.plugins.toast.showLongBottom).toBeDefined(); + }); + }); + + describe('Invalid usage', function () { + it("should fail due to an invalid position", function(done) { + window.plugins.toast.show('hi', 'short', 'nowhere', fail.bind(null, done), succeed.bind(null, done)); + }); + + it("should fail due to an invalid duration", function(done) { + window.plugins.toast.show('hi', 'medium', 'top', fail.bind(null, done), succeed.bind(null, done)); }); - */ }); }; + +});