From 6c198b7e6cb7bceabf906e91d7480d0f5f1be6fd Mon Sep 17 00:00:00 2001 From: Gilles Callebaut Date: Thu, 23 Jun 2016 21:27:56 +0200 Subject: [PATCH] JS fix --- tests/main.js | 115 +++++++++++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/tests/main.js b/tests/main.js index fc12dab..b2ff7be 100644 --- a/tests/main.js +++ b/tests/main.js @@ -326,70 +326,71 @@ exports.defineAutoTests = function() { /* NEW API test with Password encryption*/ describe('Password encryption Error Tests new API', function() { - it("Plugin available", function() { - expect(NativeStorage).toEqual(jasmine.anything()); - }); - it('should invoke the error callback function for a secret item', function(done) { - //reference, obj, encryptConfig, success, error - NativeStorage.setSecretItem("ref_to_secret_value", "SomeVerySecretText", { - mode: "password", - value: "mySecretPassword" - }, - function(result) { - // Oke good we've set the secret - expect(result).toEqual("SomeVerySecretText"); - // let's grab it back - NativeStorage.getSecretItem("ref_to_secret_value", { - mode: "password", - value: "SomeOhterPassword" - }, function(result) { - // if we are in the browser - if (window.cordova && window.cordova.platformId === 'browser') || !(window.phonegap || window.cordova)) { - done(); - } - fail("We've giving the pasword so it shouldn't work"); NativeStorage.remove("ref_to_secret_value", function() { - fail("We shouldn't got here... maybe we are in a browser!"); - }, function(e) { - fail("Delete item Failed"); - }); - }, - function(e) { - done(); - }); + it("Plugin available", function() { + expect(NativeStorage).toEqual(jasmine.anything()); + }); + it('should invoke the error callback function for a secret item', function(done) { + //reference, obj, encryptConfig, success, error + NativeStorage.setSecretItem("ref_to_secret_value", "SomeVerySecretText", { + mode: "password", + value: "mySecretPassword" + }, + function(result) { + // Oke good we've set the secret + expect(result).toEqual("SomeVerySecretText"); + // let's grab it back + NativeStorage.getSecretItem("ref_to_secret_value", { + mode: "password", + value: "SomeOhterPassword" + }, function(result) { + // if we are in the browser + if ((window.cordova && window.cordova.platformId === 'browser') || !(window.phonegap || window.cordova)) { + done(); + } + fail("We've giving the pasword so it shouldn't work"); + NativeStorage.remove("ref_to_secret_value", function() { + fail("We shouldn't got here... maybe we are in a browser!"); + }, function(e) { + fail("Delete item Failed"); + }); }, function(e) { - fail("Set item Failed"); + done(); }); - }); + }, + function(e) { + fail("Set item Failed"); + }); + }); }); -/* NEW API test with clear() function*/ -describe('clear function', function() { - it("Plugin available", function() { - expect(NativeStorage).toEqual(jasmine.anything()); - }); - it('should invoke the error callback function with error code 2', function(done) { - var a = {}; - NativeStorage.setItem("dummy_ref_clear", a, function(result) { - expect(result).toEqual(a); - NativeStorage.clear(function(result) { - NativeStorage.getItem("dummy_ref_clear", function(result) { - fail("Should not give a result"); - }, function(e) { - expect(e.code).toEqual(2); - done(); + /* NEW API test with clear() function*/ + describe('clear function', function() { + it("Plugin available", function() { + expect(NativeStorage).toEqual(jasmine.anything()); + }); + it('should invoke the error callback function with error code 2', function(done) { + var a = {}; + NativeStorage.setItem("dummy_ref_clear", a, function(result) { + expect(result).toEqual(a); + NativeStorage.clear(function(result) { + NativeStorage.getItem("dummy_ref_clear", function(result) { + fail("Should not give a result"); + }, function(e) { + expect(e.code).toEqual(2); + done(); + }); + }, + function(e) { + fail("Error when clearing native storage"); }); - }, - function(e) { - fail("Error when clearing native storage"); - }); - }, - function(e) { - fail("Error when item is set"); - }); - }); + }, + function(e) { + fail("Error when item is set"); + }); + }); -}); + }); };