Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
[spec] update specs to cordova.require/define
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Willoughby committed Jun 10, 2013
1 parent 7ec3d47 commit 2331218
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
32 changes: 18 additions & 14 deletions spec/barcodescanner.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,39 @@
*
*/

describe('Plugin object (window.plugins)', function () {
var scanner;

describe('cordova.require object should exist', function () {
it("should exist", function() {
expect(window.plugins).toBeDefined();
expect(window.cordova).toBeDefined();
expect(typeof cordova.require == 'function').toBe(true);
});

it("should contain a barcodeScanner object", function() {
expect(window.plugins.barcodeScanner).toBeDefined();
expect(typeof window.plugins.barcodeScanner == 'object').toBe(true);
it("BarcodeScanner plugin should exist", function() {
scanner = cordova.require("cordova/plugin/BarcodeScanner")
expect(scanner).toBeDefined();
expect(typeof scanner == 'object').toBe(true);
});

it("should contain a scan function", function() {
expect(window.plugins.barcodeScanner.scan).toBeDefined();
expect(typeof window.plugins.barcodeScanner.scan == 'function').toBe(true);
expect(scanner.scan).toBeDefined();
expect(typeof scanner.scan == 'function').toBe(true);
});

it("should contain an encode function", function() {
expect(window.plugins.barcodeScanner.encode).toBeDefined();
expect(typeof window.plugins.barcodeScanner.encode == 'function').toBe(true);
expect(scanner.encode).toBeDefined();
expect(typeof scanner.encode == 'function').toBe(true);
});

it("should contain three DestinationType constants", function() {
expect(BarcodeScanner.Encode.TEXT_TYPE).toBe("TEXT_TYPE");
expect(BarcodeScanner.Encode.EMAIL_TYPE).toBe("EMAIL_TYPE");
expect(BarcodeScanner.Encode.PHONE_TYPE).toBe("PHONE_TYPE");
expect(BarcodeScanner.Encode.SMS_TYPE).toBe("SMS_TYPE");
expect(scanner.Encode.TEXT_TYPE).toBe("TEXT_TYPE");
expect(scanner.Encode.EMAIL_TYPE).toBe("EMAIL_TYPE");
expect(scanner.Encode.PHONE_TYPE).toBe("PHONE_TYPE");
expect(scanner.Encode.SMS_TYPE).toBe("SMS_TYPE");
});
/*
it("should call scan successfully", function() {
window.plugins.barcodeScanner.scan(function() {}, function() {});
scanner.scan(function() {}, function() {});
});
*/
});
4 changes: 2 additions & 2 deletions www/barcodescanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ cordova.define("cordova/plugin/BarcodeScanner",
}

if (typeof errorCallback != "function") {
console.log("BarcodeScanner.scan failure: failure parameter not a function");
console.log("BarcodeScanner.encode failure: failure parameter not a function");
return
}

if (typeof successCallback != "function") {
console.log("BarcodeScanner.scan failure: success callback parameter must be a function");
console.log("BarcodeScanner.encode failure: success callback parameter must be a function");
return
}

Expand Down

0 comments on commit 2331218

Please sign in to comment.