You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/07/16 23:46:14 UTC
[2/4] js commit: Fix grunt tests by deleting plugin-related and
legacy BB tests
Fix grunt tests by deleting plugin-related and legacy BB tests
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/f947df19
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/f947df19
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/f947df19
Branch: refs/heads/master
Commit: f947df1994f9076f7d4216fc3f248878652ce7fd
Parents: 50f8dbb
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 16 17:43:58 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 16 17:45:05 2013 -0400
----------------------------------------------------------------------
build/packager.js | 68 ++---
test/blackberry/test.exec.js | 162 ----------
test/blackberry/test.platform.js | 95 ------
test/blackberry/webworks/test.accelerometer.js | 85 ------
test/blackberry/webworks/test.logger.js | 40 ---
test/blackberry/webworks/test.media.js | 319 --------------------
test/blackberry/webworks/test.notification.js | 88 ------
test/test.accelerometer.js | 201 ------------
test/test.battery.js | 134 --------
test/test.builder.js | 8 +-
test/test.camera.js | 34 ---
test/test.compass.js | 123 --------
test/test.console-via-logger.js | 193 ------------
test/test.contact.js | 125 --------
test/test.contacts.js | 131 --------
test/test.filetransfer.js | 75 -----
test/test.geolocation.js | 291 ------------------
test/test.logger.js | 296 ------------------
test/test.network.js | 50 ---
test/test.notification.js | 89 ------
20 files changed, 28 insertions(+), 2579 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/build/packager.js
----------------------------------------------------------------------
diff --git a/build/packager.js b/build/packager.js
index 7e2f19b..71433ce 100644
--- a/build/packager.js
+++ b/build/packager.js
@@ -99,24 +99,11 @@ packager.bundle = function(platform, debug, commitId) {
var scripts = collectFiles('lib/scripts')
modules[''] = 'lib/cordova.js'
-
+ copyProps(modules, collectFiles(path.join('lib', platform)));
+
if (platform === 'test') {
- copyProps(modules, collectFiles(path.join('lib', platform)));
-
- //Test platform needs to bring in platform specific plugin's for testing
- copyProps(modules, collectFiles(path.join('lib', 'blackberry', 'plugin'), 'plugin'));
- copyProps(modules, collectFiles(path.join('lib', 'blackberry10', 'plugin'), 'plugin'));
- copyProps(modules, collectFiles(path.join('lib', 'firefoxos', 'plugin', 'firefoxos'), 'plugin/firefoxos'));
- copyProps(modules, collectFiles(path.join('lib', 'tizen', 'plugin', 'tizen'), 'plugin/tizen'));
- copyProps(modules, collectFiles(path.join('lib', 'windowsphone', 'plugin', 'windowsphone'), 'plugin/windowsphone'));
- copyProps(modules, collectFiles(path.join('lib', 'windows8', 'plugin', 'windows8'), 'plugin/windows8'));
- copyProps(modules, collectFiles(path.join('lib', 'ios', 'plugin', 'ios'), 'plugin/ios/'));
- copyProps(modules, collectFiles(path.join('lib', 'bada', 'plugin', 'bada'), 'plugin/bada/'));
+ // TODO: move plugin files used in tests out of plugins
copyProps(modules, collectFiles(path.join('lib', 'android', 'plugin', 'android'), 'plugin/android/'));
- copyProps(modules, collectFiles(path.join('lib', 'osx', 'plugin', 'osx'), 'plugin/osx/'));
- }
- else {
- copyProps(modules, collectFiles(path.join('lib', platform)))
}
var output = [];
@@ -187,35 +174,28 @@ function collectFiles(dir, id) {
if (!id) id = ''
var result = {}
-
- try {
- var entries = fs.readdirSync(dir)
-
- entries = entries.filter(function(entry) {
- if (entry.match(/\.js$/)) return true
-
- var stat = fs.statSync(path.join(dir, entry))
- if (stat.isDirectory()) return true
- })
-
- entries.forEach(function(entry) {
- var moduleId = path.join(id, entry)
- var fileName = path.join(dir, entry)
-
- var stat = fs.statSync(fileName)
- if (stat.isDirectory()) {
- copyProps(result, collectFiles(fileName, moduleId))
- }
- else {
- moduleId = getModuleId(moduleId)
- result[moduleId] = fileName
- }
- })
- }
- catch(ex) {
+ var entries = fs.readdirSync(dir)
- }
-
+ entries = entries.filter(function(entry) {
+ if (entry.match(/\.js$/)) return true
+
+ var stat = fs.statSync(path.join(dir, entry))
+ if (stat.isDirectory()) return true
+ })
+
+ entries.forEach(function(entry) {
+ var moduleId = path.join(id, entry)
+ var fileName = path.join(dir, entry)
+
+ var stat = fs.statSync(fileName)
+ if (stat.isDirectory()) {
+ copyProps(result, collectFiles(fileName, moduleId))
+ }
+ else {
+ moduleId = getModuleId(moduleId)
+ result[moduleId] = fileName
+ }
+ })
return copyProps({}, result)
}
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/blackberry/test.exec.js
----------------------------------------------------------------------
diff --git a/test/blackberry/test.exec.js b/test/blackberry/test.exec.js
deleted file mode 100644
index 1becbe0..0000000
--- a/test/blackberry/test.exec.js
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("blackberry exec", function () {
- var exec = require('cordova/blackberryexec'),
- cordova = require('cordova');
-
- it("calls the managers exec for the given runtime", function () {
- var platform = require('cordova/platform'),
- manager = require('cordova/plugin/air/manager'),
- win = jasmine.createSpy("win"),
- fail = jasmine.createSpy("fail"),
- args = {};
-
- spyOn(platform, "runtime").andReturn("air");
- spyOn(manager, "exec");
-
- exec(win, fail, "foo", "bar", args);
-
- expect(manager.exec).toHaveBeenCalledWith(win, fail, "foo", "bar", args);
- });
-
- describe("when the callback status is ok", function () {
- var platform = require('cordova/platform'),
- manager = require('cordova/plugin/air/manager');
-
- beforeEach(function () {
- spyOn(platform, "runtime").andReturn("air");
- spyOn(manager, "exec").andReturn({
- status: cordova.callbackStatus.OK,
- message: "sometimes I drink from the milk carton"
- });
- });
-
- it("returns the message", function () {
- expect(exec(null, null)).toBe("sometimes I drink from the milk carton");
- });
-
- it("calls the success callback with the message", function () {
- var success = jasmine.createSpy("success");
- exec(success);
- expect(success).toHaveBeenCalledWith("sometimes I drink from the milk carton");
- });
-
- it("doesn't call the error callback", function () {
- var error = jasmine.createSpy("error");
- exec(null, error);
- expect(error).not.toHaveBeenCalled();
- });
-
- it("logs any errors from the success callback", function () {
- spyOn(console, "log");
-
- var success = jasmine.createSpy("success").andThrow("oh noes!");
- cordova.callbackId = 1;
- exec(success);
-
- expect(console.log).toHaveBeenCalledWith("Error in success callback: 1 = oh noes!");
- });
-
- it("still returns the message even if there was an exception in success", function () {
- spyOn(console, "log");
- var success = jasmine.createSpy("success").andThrow("oh noes!");
- expect(exec(success)).toBe("sometimes I drink from the milk carton");
- });
- });
-
- describe("when the callback status is no_result", function () {
- var platform = require('cordova/platform'),
- manager = require('cordova/plugin/air/manager');
-
- beforeEach(function () {
- spyOn(platform, "runtime").andReturn("air");
- spyOn(manager, "exec").andReturn({
- status: cordova.callbackStatus.NO_RESULT,
- message: "I know what you did last summer"
- });
- });
-
- it("returns undefined", function () {
- expect(exec()).not.toBeDefined();
- });
-
- it("doesn't call the success callback", function () {
- var success = jasmine.createSpy("success");
- exec(success);
- expect(success).not.toHaveBeenCalled();
- });
-
- it("doesn't call the error callback", function () {
- var error = jasmine.createSpy("error");
- exec(null, error);
- expect(error).not.toHaveBeenCalled();
- });
- });
-
- describe("when the callback status is anything else", function () {
- var platform = require('cordova/platform'),
- manager = require('cordova/plugin/air/manager');
-
- beforeEach(function () {
- spyOn(console, "log");
- spyOn(platform, "runtime").andReturn("air");
- spyOn(manager, "exec").andReturn({
- status: "poop",
- message: "the bed"
- });
- });
-
- it("returns null", function () {
- expect(exec()).toBeNull();
- });
-
- it("logs the status and message", function () {
- exec();
- expect(console.log).toHaveBeenCalledWith("Error: Status=poop Message=the bed");
- });
-
- it("calls the fail callback with the message", function () {
- var fail = jasmine.createSpy("fail");
- exec(null, fail);
- expect(fail).toHaveBeenCalledWith("the bed");
- });
-
- it("doesn't call the success callback", function () {
- var success = jasmine.createSpy("success");
- exec(success);
- expect(success).not.toHaveBeenCalled();
- });
-
- it("logs the exception from the error callback", function () {
- var error = jasmine.createSpy("error").andThrow("aww snap");
- cordova.callbackId = 1;
- exec(null, error);
-
- expect(console.log).toHaveBeenCalledWith("Error in error callback: 1 = aww snap");
- });
-
- it("still returns null when there is an error", function () {
- var error = jasmine.createSpy("error").andThrow("aww snap");
- expect(exec(null, error)).toBeNull();
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/blackberry/test.platform.js
----------------------------------------------------------------------
diff --git a/test/blackberry/test.platform.js b/test/blackberry/test.platform.js
deleted file mode 100644
index 067d436..0000000
--- a/test/blackberry/test.platform.js
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("blackberry platform", function () {
- var modulemapper = require('cordova/modulemapper'),
- modulereplacer = require('cordova/modulereplacer'),
- platform = require('cordova/blackberryplatform');
-
- org = {};
- org.apache = {};
- org.apache.cordova = {};
- org.apache.cordova.JavaPluginManager = {};
-
- beforeEach(function () {
- modulereplacer.replace('cordova/platform', platform);
- });
-
- beforeEach(function () {
- GLOBAL.navigator = {};
- });
-
- afterEach(function () {
- delete GLOBAL.navigator;
- });
-
- describe("when getting the runtime", function () {
- it("returns air for the playbook user agent", function () {
- navigator.__defineGetter__("userAgent", function () {
- return "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536.2+";
- });
- expect(platform.runtime()).toBe("air");
- });
-
- it("returns java for a blackberry user agent", function () {
- navigator.__defineGetter__("userAgent", function () {
- return "Mozilla/5.0 (BlackBerry; U; BlackBerry 9100; en) AppleWebKit/534.3+ (KHTML, like Gecko) Version/6.0.0.286 Mobile Safari/534.3+";
- });
- expect(platform.runtime()).toBe("java");
- });
- });
-
- describe("when initializing", function () {
- beforeEach(function () {
- platform.contextObj = {};
- var count = 0;
- // Don't load non-blackberry symbol modules.
- var loadMatchingModulesSpy = spyOn(modulemapper, 'loadMatchingModules');
- loadMatchingModulesSpy.andCallFake(function(pattern) {
- if (!pattern.exec('cordova/foo/symbols')) {
- return loadMatchingModulesSpy.originalValue.apply(this, arguments);
- }
- });
- });
-
- it("calls initialize for the platform from the runtime", function () {
- var air = require('cordova/plugin/air/platform');
-
- spyOn(air, "initialize");
- spyOn(platform, "runtime").andReturn("air");
- platform.initialize();
-
- expect(air.initialize).toHaveBeenCalled();
- });
-
- it("builds java platforms objects into window", function () {
- var java = require('cordova/plugin/java/platform');
-
- spyOn(java, "initialize");
- spyOn(platform, "runtime").andReturn("java");
- platform.initialize();
-
- expect(platform.contextObj.File).not.toBeUndefined();
- expect(platform.contextObj.navigator.app).not.toBeUndefined();
- });
-
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/blackberry/webworks/test.accelerometer.js
----------------------------------------------------------------------
diff --git a/test/blackberry/webworks/test.accelerometer.js b/test/blackberry/webworks/test.accelerometer.js
deleted file mode 100644
index 860ccc4..0000000
--- a/test/blackberry/webworks/test.accelerometer.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("accelerometer", function () {
- var accelerometer = require('cordova/plugin/webworks/accelerometer'),
- cordova = require('cordova');
-
- beforeEach(function(){
- spyOn(window, "removeEventListener");
- spyOn(window, "addEventListener");
- });
-
- describe("start", function() {
- it("returns no result", function () {
- expect(accelerometer.start()).toEqual({
- status: cordova.callbackStatus.NO_RESULT,
- message: "WebWorks Is On It"
- });
- });
-
- it("removes the event listener", function () {
- accelerometer.start();
- expect(window.removeEventListener).toHaveBeenCalledWith("devicemotion", jasmine.any(Function));
- });
-
- it("adds the event listener back", function () {
- accelerometer.start();
- expect(window.addEventListener).toHaveBeenCalledWith("devicemotion", jasmine.any(Function));
- });
-
- it("grabs the motion information from the callback and calls success", function () {
- var success = jasmine.createSpy("success");
- accelerometer.start({}, success);
-
- window.addEventListener.mostRecentCall.args[1]({
- accelerationIncludingGravity: {
- x: 1,
- y: 2,
- z: 3,
- },
- timestamp: "around tea time"
- });
-
- expect(success).toHaveBeenCalledWith({
- x: 1,
- y: 2,
- z: 3,
- timestamp: "around tea time"
- });
-
- });
- });
-
- describe("stop", function() {
- it("returns OK", function () {
- expect(accelerometer.stop()).toEqual({
- status: cordova.callbackStatus.OK,
- message: "removed"
- });
- });
-
- it("removes the event listener", function () {
- accelerometer.stop();
- expect(window.removeEventListener).toHaveBeenCalledWith("devicemotion", jasmine.any(Function));
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/blackberry/webworks/test.logger.js
----------------------------------------------------------------------
diff --git a/test/blackberry/webworks/test.logger.js b/test/blackberry/webworks/test.logger.js
deleted file mode 100644
index 9299211..0000000
--- a/test/blackberry/webworks/test.logger.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("logger", function () {
- var logger = require('cordova/plugin/webworks/logger');
-
- beforeEach(function () {
- spyOn(console, "log");
- });
-
- it("should post a console log", function() {
- logger.log("Yodalay-Yodalay-Yodalay-Hee-Hoo!");
- expect(console.log).toHaveBeenCalledWith("Yodalay-Yodalay-Yodalay-Hee-Hoo!");
- });
-
- it("returns ok", function () {
- expect(logger.log('moo')).toEqual({
- status: cordova.callbackStatus.OK,
- message: 'Message logged to console: moo'
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/blackberry/webworks/test.media.js
----------------------------------------------------------------------
diff --git a/test/blackberry/webworks/test.media.js b/test/blackberry/webworks/test.media.js
deleted file mode 100644
index dd8f1e7..0000000
--- a/test/blackberry/webworks/test.media.js
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("media", function () {
- var media = require('cordova/plugin/webworks/media'),
- audio = {
- play: jasmine.createSpy("play"),
- pause: jasmine.createSpy("pause"),
- src: "file.mp3",
- currentTime: 800,
- duration: 2100
- };
-
- beforeEach(function(){
- audio.play.reset();
- audio.pause.reset();
- global.blackberry = {
- media:{
- microphone:{
- record: jasmine.createSpy("blackberry.media.microphone.record")
- }
- }
- };
-
- global.Audio = jasmine.createSpy("Audio").andCallFake(function () {
- return audio;
- });
- });
-
- afterEach(function(){
- delete global.Audio;
- delete global.blackberry;
- });
-
- function handlesNoArgs(func) {
- it("should return an error message when no args provided", function() {
- expect(func({})).toEqual({
- status: 9,
- message: 'Media Object id was not sent in arguments'
- });
- });
- }
-
- function handlesNotFound(func) {
- it("returns error if it can't find audio object", function () {
- expect(func(["FreeBird"])).toEqual({
- status: 2,
- message: 'Audio Object has not been initialized'
- });
- });
- }
-
- describe("create", function() {
-
- handlesNoArgs(media.create);
-
- it("should create an audio object for the src", function () {
- media.create(["jammin", "tunes/wejammin.mp3"]);
- expect(Audio).toHaveBeenCalledWith("tunes/wejammin.mp3");
- });
-
- it("returns success", function() {
- expect(media.create(["jammin", "tunes/wejammin.mp3"])).toEqual({
- status: 1,
- message: 'Audio object created'
- });
- });
- });
-
- describe("startPlayingAudio", function(){
-
- handlesNoArgs(media.startPlayingAudio);
-
- it("errors out when no src", function () {
- expect(media.startPlayingAudio([1])).toEqual({
- status: 9,
- message: "Media source argument not found"
- });
- });
-
- it("returns success", function() {
- expect(media.startPlayingAudio(["jammin", "tunes/wejammin.mp3"])).toEqual({
- status: 1,
- message: 'Audio play started'
- });
- });
-
- it("creates an audio object for the src", function () {
- media.startPlayingAudio(["push", "pushit.mp3"]);
- expect(Audio).toHaveBeenCalledWith("pushit.mp3");
- });
-
- it("calls play on the audio object", function () {
- media.startPlayingAudio(["baby", "babybabybabyohhh.mp3"]);
- expect(audio.play).toHaveBeenCalled();
- });
-
- it("calls pause if the audio id already existed", function () {
- media.startPlayingAudio(["ice", "iceicebaby.mp3"]);
- media.startPlayingAudio(["ice", "iceicebaby.mp3"]);
- expect(audio.pause).toHaveBeenCalled();
- });
-
- it("doesn't call pause on new id's", function () {
- media.startPlayingAudio(["loser", "loser.mp3"]);
- expect(audio.pause).not.toHaveBeenCalled();
- });
- });
-
- describe("stopPlayingAudio", function(){
- handlesNoArgs(media.stopPlayingAudio);
-
- it("finds that no Audio Object exists", function () {
- expect(media.stopPlayingAudio(["Free Bird"])).toEqual({
- status: 2,
- message: 'Audio Object has not been initialized'
- });
- });
-
- describe("when it can find the audio object", function () {
- beforeEach(function () {
- media.startPlayingAudio(["thriller", "triller.mp3"]);
- audio.pause.reset(); //since start will call play
- });
-
- it("returns success", function () {
- expect(media.stopPlayingAudio(["thriller"])).toEqual({
- status: 1,
- message: "Audio play stopped"
- });
- });
-
- it("calls pause on the found audio object", function () {
- media.stopPlayingAudio(["thriller"]);
- expect(audio.pause).toHaveBeenCalled();
-
- });
- });
- });
-
- describe("seekToAudio", function(){
- handlesNoArgs(media.seekToAudio);
- handlesNotFound(media.seekToAudio);
-
- describe("when it can find an audio object", function () {
- beforeEach(function () {
- media.create(["yellowSubmarine", "yellowSubmarine.ogg"]);
- });
-
- it("returns a message when no seek time provided", function () {
- expect(media.seekToAudio(["yellowSubmarine"])).toEqual({
- status: 9,
- message: 'Media seek time argument not found'
- });
- });
-
- it("sets the currentTime of the audio object", function () {
- media.seekToAudio(["yellowSubmarine", 12]);
- expect(audio.currentTime).toBe(12);
- });
-
- describe("when setting the current time fails", function () {
- beforeEach(function () {
- spyOn(console, "log");
- audio.__defineSetter__("currentTime", jasmine.createSpy("audio.currentTime").andThrow("holy balls!"));
- });
-
- afterEach(function () {
- delete audio.currentTime;
- audio.currentTime = 800;
- });
-
- it("logs the error", function () {
- media.seekToAudio(["yellowSubmarine", 33]);
- expect(console.log).toHaveBeenCalledWith("Error seeking audio: holy balls!");
- });
-
- it("returns the error", function () {
- expect(media.seekToAudio(["yellowSubmarine", 33])).toEqual({
- status: 3,
- message: "Error seeking audio: holy balls!"
- });
- });
- });
- });
- });
-
- describe("pausePlayingAudio", function(){
- handlesNoArgs(media.pausePlayingAudio);
- handlesNotFound(media.pausePlayingAudio);
-
- it("should pause the existing audio", function () {
- media.create(["WhatIsLove", "babyDontHurtMe.mp3"]);
- media.pausePlayingAudio(["WhatIsLove"]);
- expect(audio.pause).toHaveBeenCalled();
- });
-
- it("should return Audio paused", function () {
- media.create(["TheBoysAreBackInTown", "thinLizzyBaby.mp3"]);
- expect(media.pausePlayingAudio(["TheBoysAreBackInTown"])).toEqual({
- status: 1,
- message: 'Audio paused'
- });
- });
- });
-
- describe("getCurrentPositionAudio", function(){
- handlesNoArgs(media.getCurrentPositionAudio);
- handlesNotFound(media.getCurrentPositionAudio);
-
- it("should return current audio position", function () {
- media.create(["InTheEnd", "linkinPark/inTheEnd.mp3"]);
- expect(media.getCurrentPositionAudio(["InTheEnd"])).toEqual({
- status: 1,
- message: 800
- });
- });
- });
-
- describe("getDuration", function(){
- handlesNoArgs(media.getDuration);
- handlesNotFound(media.getDuration);
-
- it("should return the duration", function () {
- media.create(["lollypop", "lollypop.mp3"]);
- expect(media.getDuration(["lollypop"])).toEqual({
- status: 1,
- message: 2100
- });
- });
- });
-
- describe("startRecordingAudio", function(){
- handlesNoArgs(media.startRecordingAudio);
-
- beforeEach(function () {
- global.blackberry = {
- media: {
- microphone: {
- record: jasmine.createSpy("record")
- }
- }
- };
- });
-
- afterEach(function () {
- delete global.blackberry;
- });
-
- it("throws an error when not enough arguments", function () {
- expect(media.startRecordingAudio(["ww"])).toEqual({
- status: 9,
- message: "Media start recording, insufficient arguments"
- });
- });
-
- it("calls record", function () {
- var win = jasmine.createSpy("win"),
- fail = jasmine.createSpy("fail");
-
- media.startRecordingAudio(["record", "manifesto.ogg"], win, fail);
-
- expect(blackberry.media.microphone.record).toHaveBeenCalledWith("manifesto.ogg", win, fail);
- });
-
- it("returns no result", function () {
- expect(media.startRecordingAudio(["foo", "birdcall.mp3"])).toEqual({
- status: 0,
- message: "WebWorks Is On It"
- });
- });
- });
-
- describe("stopRecordingAudio", function () {
- it("can be called with no args and all is well", function () {
- expect(media.stopRecordingAudio).not.toThrow();
- });
- });
-
- describe("release", function () {
- handlesNoArgs(media.release);
-
- afterEach(function () {
- audio.src = "file.mp3";
- });
-
- it("sets the src of the audio object to undefined", function () {
- media.create(["video", "killedtheradiostar.mp3"]);
- media.release(["video"]);
-
- expect(audio.src).not.toBeDefined();
- });
-
- it("returns a message that the resources have been released", function () {
- expect(media.release(["onaboat"])).toEqual({
- status: 1,
- message: "Media resources released"
- });
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/blackberry/webworks/test.notification.js
----------------------------------------------------------------------
diff --git a/test/blackberry/webworks/test.notification.js b/test/blackberry/webworks/test.notification.js
deleted file mode 100644
index 684aca2..0000000
--- a/test/blackberry/webworks/test.notification.js
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("notification", function () {
- var notification = require('cordova/plugin/webworks/notification'),
- cordova = require('cordova');
-
- beforeEach(function(){
- global.blackberry = {
- ui:{
- dialog:{
- customAskAsync: jasmine.createSpy()
- // apply: jasmine.createSpy('apply')
-
- }
- }
- }
- });
-
- afterEach(function(){
- delete global.blackberry;
- });
-
- describe("alert", function() {
-
- it("should return that alert arguments are missing", function() {
- expect(notification.alert("")).toEqual({
- status: 9,
- message: "Notification action - alert arguments not found"
- });
- });
-
- it("should call the blackberry object", function() {
- var win = jasmine.createSpy('win');
- notification.alert(["Danger, danger Will Robinson!", "Panic, is my middle name", "PANIC!"], win);
- expect(blackberry.ui.dialog.customAskAsync).toHaveBeenCalledWith("Danger, danger Will Robinson!", [ "PANIC!" ], win, { "title" : "Panic, is my middle name" });
- });
-
- it("should return that WebWorks Is On It", function() {
- expect(notification.alert(["Danger, danger Will Robinson!", "Panic, is my middle name", "PANIC!"])).toEqual({
- status: cordova.callbackStatus.NO_RESULT,
- message: "WebWorks Is On It"
- });
- });
- });
-
- describe("confirm", function() {
- it("should return that alert arguments are missing", function() {
- expect(notification.confirm("")).toEqual({
- status: 9,
- message: "Notification action - confirm arguments not found"
- });
- });
-
- it("should call the blackberry object", function() {
- var win = jasmine.createSpy('win');
- notification.confirm(["Are you interested in cheaper long distance?", "Serving you better!", "SCREAM,CONFIRM"], win);
-
- expect(blackberry.ui.dialog.customAskAsync).toHaveBeenCalledWith("Are you interested in cheaper long distance?", [ "SCREAM", "CONFIRM" ], win, { "title" : "Serving you better!" });
- });
-
- it("should return that WebWorks Is On It", function() {
- expect(notification.confirm(["Danger, danger Will Robinson!", "Panic, is my middle name", "PANIC!"])).toEqual({
- status: cordova.callbackStatus.NO_RESULT,
- message: "WebWorks Is On It"
- });
- });
- });
-
-});
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/test.accelerometer.js
----------------------------------------------------------------------
diff --git a/test/test.accelerometer.js b/test/test.accelerometer.js
deleted file mode 100644
index 3b7d90e..0000000
--- a/test/test.accelerometer.js
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("accelerometer", function () {
- var accelerometer = require("cordova/plugin/accelerometer"),
- exec = require('cordova/exec');
-
- beforeEach(function() {
- exec.reset();
- });
-
- var fakeAccelObject = {x:1,y:2,z:3};
-
- function callSuccess() {
- exec.mostRecentCall.args[0](fakeAccelObject);
- }
-
- function callError() {
- exec.mostRecentCall.args[1](fakeAccelObject);
- }
-
- describe("getCurrentAcceleration", function () {
- describe("failure", function () {
- it("should throw exception if bad success callback passed in", function () {
- expect(function() {
- accelerometer.getCurrentAcceleration();
- }).toThrow();
- expect(function() {
- accelerometer.getCurrentAcceleration(null);
- }).toThrow();
- expect(function() {
- accelerometer.getCurrentAcceleration({call:function(){}, apply:function(){}});
- }).toThrow();
- });
- });
-
- describe("success", function() {
- afterEach(function() {
- // Calling the success callback for getCurrent methods should clear out the listeners
- // This way we are "starting fresh" before each test.
- callSuccess();
- });
-
- it("should call the exec method each time with no other listeners", function () {
- var success = function () {},
- error = function () {};
-
- accelerometer.getCurrentAcceleration(success, error, {});
- expect(exec).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Function), "Accelerometer", "start", []);
- });
- });
- });
-
- describe("watchAcceleration", function () {
- describe("failure", function () {
- it("throws an exception if bad successCallback", function () {
- expect(function() {
- accelerometer.watchAcceleration();
- }).toThrow();
- expect(function() {
- accelerometer.watchAcceleration(null);
- }).toThrow();
- expect(function() {
- accelerometer.watchAcceleration({call:function(){}, apply:function(){}});
- }).toThrow();
- });
- });
-
- describe('success', function() {
- var id;
-
- afterEach(function() {
- // Clear the watch
- accelerometer.clearWatch(id);
- });
-
- it("should call exec if no other listeners exist", function () {
- var success = jasmine.createSpy(),
- fail = jasmine.createSpy();
-
- id = accelerometer.watchAcceleration(success, fail, {frequency: 11});
-
- expect(exec).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Function), "Accelerometer", "start", []);
- });
-
- it("should set a timer with the provided frequency", function() {
- spyOn(window, "setInterval");
-
- id = accelerometer.watchAcceleration(function(){}, function(){}, {frequency:50});
-
- expect(window.setInterval).toHaveBeenCalledWith(jasmine.any(Function), 50);
- });
-
- it("should fire the timer immediately for a watch call if the accelerometer is running", function() {
- var someId = accelerometer.watchAcceleration(function(){}, function(){}, {frequency:50});
-
- var success = jasmine.createSpy();
-
- runs(function() {
- id = accelerometer.watchAcceleration(success, function(){}, {frequency:75});
- });
- waits(5);
- runs(function() {
- expect(success).toHaveBeenCalled();
- accelerometer.clearWatch(someId);
- });
- });
- it("should NOT fire the timer immediately for a watch call if the accelerometer is NOT running", function() {
- var success = jasmine.createSpy();
-
- runs(function() {
- id = accelerometer.watchAcceleration(success, function(){}, {frequency:75});
- });
- waits(5);
- runs(function() {
- expect(success).not.toHaveBeenCalled();
- });
- waits(71);
- runs(function() {
- expect(success).toHaveBeenCalled();
- });
- });
- it("should fire the success callback on the appropriate interval, not based on how quickly the framework returns accel objects", function() {
- var success = jasmine.createSpy();
- runs(function() {
- id = accelerometer.watchAcceleration(success, function(){}, {frequency:250});
- });
- waits(25);
- runs(function() {
- callSuccess();
- expect(success).not.toHaveBeenCalled();
- });
- waits(25);
- runs(function() {
- callSuccess();
- expect(success).not.toHaveBeenCalled();
- });
- waits(210);
- runs(function() {
- expect(success).toHaveBeenCalled();
- });
- });
- });
- });
-
- describe("clearWatch", function () {
- it("doesn't clear anything if the timer doesn't exist", function () {
- accelerometer.clearWatch("Never Gonna Give you Up");
- expect(exec).not.toHaveBeenCalled();
- });
- it("should clear the watch if a timer exists", function() {
- var success = jasmine.createSpy(),
- id;
- runs(function() {
- id = accelerometer.watchAcceleration(success, function() {}, {frequency: 50});
- });
- waits(25);
- runs(function() {
- accelerometer.clearWatch(id);
- });
- waits(26);
- runs(function() {
- expect(success).not.toHaveBeenCalled();
- });
- });
- it("should call exec with stop after the last timer is cleared", function() {
- var idone,
- idtwo;
-
- idone = accelerometer.watchAcceleration(function(){}, function() {}, {frequency: 50});
- exec.reset();
- idtwo = accelerometer.watchAcceleration(function(){}, function() {}, {frequency: 50});
-
- accelerometer.clearWatch(idone);
-
- expect(exec).not.toHaveBeenCalled();
-
- accelerometer.clearWatch(idtwo);
-
- expect(exec).toHaveBeenCalledWith(null, null, "Accelerometer", "stop", []);
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/test.battery.js
----------------------------------------------------------------------
diff --git a/test/test.battery.js b/test/test.battery.js
deleted file mode 100644
index 6216e7e..0000000
--- a/test/test.battery.js
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("battery", function () {
- var battery = require("cordova/plugin/battery"),
- exec = require("cordova/exec");
-
- describe("when handling events", function () {
- it("calls exec when subscribing", function () {
- var cb = jasmine.createSpy("cb");
- window.addEventListener("batterystatus", cb);
- expect(exec).toHaveBeenCalledWith(battery._status, battery._error, "Battery", "start", []);
- window.removeEventListener("batterystatus", cb);
- });
-
- it("only calls exec with start once", function () {
- var cb1 = jasmine.createSpy("cb1"),
- cb2 = jasmine.createSpy("cb2");
-
- exec.reset();
- window.addEventListener("batterystatus", cb1);
- window.addEventListener("batterystatus", cb2);
-
- expect(exec.callCount).toBe(1);
- window.removeEventListener("batterystatus", cb1);
- window.removeEventListener("batterystatus", cb2);
- });
-
- it("calls stop when all handlers are removed", function () {
- var cb1 = jasmine.createSpy("cb1"),
- cb2 = jasmine.createSpy("cb2");
-
- window.addEventListener("batterystatus", cb1);
-
- exec.reset();
-
- window.removeEventListener("batterystatus", cb1);
-
- expect(exec).toHaveBeenCalledWith(null, null, "Battery", "stop", []);
- });
-
- it("only calls exec with stop once", function () {
- var cb1 = jasmine.createSpy("cb1"),
- cb2 = jasmine.createSpy("cb2");
-
- window.addEventListener("batterystatus", cb1);
- window.addEventListener("batterystatus", cb2);
- exec.reset();
- window.removeEventListener("batterystatus", cb1);
- window.removeEventListener("batterystatus", cb2);
-
- expect(exec.callCount).toBe(1);
- });
- });
-
- describe("when monitoring the status", function () {
- var cordova = require('cordova');
-
- beforeEach(function () {
- spyOn(cordova, "fireWindowEvent");
- });
-
- //HACK: This is suspect that we can do this but
- // it being public for now makes it very easy to
- // test ;)
- it("fires the battery status event", function () {
- var info = {
- level: 100,
- isPlugged: false
- };
-
- battery._status(info);
- expect(cordova.fireWindowEvent).toHaveBeenCalledWith("batterystatus", info);
- });
-
- it("doesn't fire the battery status event if the values haven't changed", function () {
- var info = {
- level: 95,
- isPlugged: false
- };
-
- battery._status(info);
- battery._status(info);
- expect(cordova.fireWindowEvent.callCount).toBe(1);
- });
-
- it("fires the battery low event when the level is 20", function () {
- var info = {
- level: 20,
- isPlugged: false
- };
-
- battery._status(info);
- expect(cordova.fireWindowEvent).toHaveBeenCalledWith("batterylow", info);
- });
-
- it("fires the battery critical event when the level is 5", function () {
- var info = {
- level: 5,
- isPlugged: false
- };
-
- battery._status(info);
- expect(cordova.fireWindowEvent).toHaveBeenCalledWith("batterycritical", info);
- });
- });
-
- it("logs errors to the console", function () {
- //HACK: shouldn't be able to test like this but public is public ;)
- var e = "We are traveling at warp speed. How did you manage to beam aboard this ship?";
- spyOn(console, "log");
- battery._error(e);
-
- expect(console.log).toHaveBeenCalledWith("Error initializing Battery: " + e);
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/test.builder.js
----------------------------------------------------------------------
diff --git a/test/test.builder.js b/test/test.builder.js
index e8921c1..19f4769 100644
--- a/test/test.builder.js
+++ b/test/test.builder.js
@@ -28,14 +28,14 @@ describe("builder", function () {
var target = {},
objects = {
foo: {
- path: "cordova/plugin/compass"
+ path: "cordova/builder"
}
};
builder.buildIntoAndClobber(objects, target);
expect(target.foo).toBeDefined();
- expect(target.foo).toBe(require("cordova/plugin/compass"));
+ expect(target.foo).toBe(require("cordova/builder"));
});
it("returns an empty object literal if no path", function () {
@@ -56,7 +56,7 @@ describe("builder", function () {
bart: {},
lisa: {},
maggie: {
- path: "cordova/plugin/compass"
+ path: "cordova/builder"
}
}
}
@@ -65,7 +65,7 @@ describe("builder", function () {
builder.buildIntoButDoNotClobber(objects, target);
expect(target.homer.bart).toBeDefined();
- expect(target.homer.maggie).toBe(require('cordova/plugin/compass'));
+ expect(target.homer.maggie).toBe(require('cordova/builder'));
expect(target.homer.lisa).toBeDefined();
});
});
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/test.camera.js
----------------------------------------------------------------------
diff --git a/test/test.camera.js b/test/test.camera.js
deleted file mode 100644
index 26dc4e4..0000000
--- a/test/test.camera.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("camera", function () {
- var camera = require('cordova/plugin/Camera'),
- constants = require('cordova/plugin/CameraConstants');
-
- describe("constants", function() {
- it("should be defined on the base camera plugin", function() {
- for (var type in constants) {
- expect(camera[type]).toBe(constants[type]);
- }
- });
- });
-});
-
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/test.compass.js
----------------------------------------------------------------------
diff --git a/test/test.compass.js b/test/test.compass.js
deleted file mode 100644
index 2d9bff3..0000000
--- a/test/test.compass.js
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("compass", function () {
- var compass = require('cordova/plugin/compass'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
- beforeEach(function() {
- exec.reset();
- });
-
- describe("when getting the current heading", function () {
- it("throws an error and doesn't call exec when no success callback given", function () {
- expect(function() { compass.getCurrentHeading() }).toThrow();
- });
-
- it("throws an error and doesn't call exec when success isn't a function", function () {
- expect(function() { compass.getCurrentHeading(12) }).toThrow();
- });
-
- it("throws an error and doesn't call exec when error isn't a function", function () {
- var func = function () {};
- expect(function() { compass.getCurrentHeading(func, 12) }).toThrow();
- });
-
- it("calls exec", function () {
- var s = function () {},
- f = function () {};
-
- compass.getCurrentHeading(s, f);
- expect(exec).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Function), "Compass", "getHeading", [undefined]);
- });
- });
-
- describe("watch heading", function () {
- beforeEach(function () {
- spyOn(window, "setInterval").andReturn("def");
- });
-
- it("throws an error and doesn't call exec when no success callback given", function () {
- expect(function() { compass.watchHeading() }).toThrow();
- });
-
- it("throws an error and doesn't call exec when success isn't a function", function () {
- expect(function() { compass.watchHeading(12) }).toThrow();
- });
-
- it("throws an error and doesn't call exec when error isn't a function", function () {
- var func = function () {};
- expect(function() { compass.watchHeading(func, 12) }).toThrow();
- });
-
- it("generates and returns a uuid for the watch", function () {
- spyOn(utils, "createUUID").andReturn(1234);
-
- var result = compass.watchHeading(function () {});
- expect(result).toBe(1234);
- });
-
- describe("setting the interval", function () {
- it("is 100 when not provided", function () {
- compass.watchHeading(function () {});
- expect(window.setInterval).toHaveBeenCalledWith(jasmine.any(Function), 100);
- });
-
- it("is 100 when options provided with no frequency", function () {
- compass.watchHeading(function () {}, null, {});
- expect(window.setInterval).toHaveBeenCalledWith(jasmine.any(Function), 100);
- });
-
- it("is the provided value", function () {
- compass.watchHeading(function () {}, null, {frequency: 200});
- expect(window.setInterval).toHaveBeenCalledWith(jasmine.any(Function), 200);
- });
- });
-
- it("gets the compass value for the given interval", function () {
- var success = jasmine.createSpy(),
- fail = jasmine.createSpy();
-
- compass.watchHeading(success, fail);
-
- //exec the interval callback!
- window.setInterval.mostRecentCall.args[0]();
- expect(exec).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Function), "Compass", "getHeading", [undefined]);
- });
- });
-
- describe("when clearing the watch", function () {
- beforeEach(function () {
- spyOn(window, "clearInterval");
- });
-
- it("doesn't clear anything if the timer doesn't exist", function () {
- compass.clearWatch("Never Gonna Give you Up");
- expect(window.clearInterval).not.toHaveBeenCalled();
- });
-
- it("can be called with no args", function () {
- compass.clearWatch();
- expect(window.clearInterval).not.toHaveBeenCalled();
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/test.console-via-logger.js
----------------------------------------------------------------------
diff --git a/test/test.console-via-logger.js b/test/test.console-via-logger.js
deleted file mode 100644
index 71d9a87..0000000
--- a/test/test.console-via-logger.js
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("console-via-logger", function () {
-
- var cordova = require('cordova')
- var logger = require('cordova/plugin/logger')
- var console = require('cordova/plugin/console-via-logger')
- var exec = require("cordova/exec")
- var savedLevel
-
- // fake device ready, but can't test the queued messages this way
- logger.__onDeviceReady()
-
- //--------------------------------------------------------------------------
- beforeEach(function() {
- savedLevel = logger.level()
- logger.level(logger.DEBUG)
- logger.useConsole(false)
- console.useLogger(true)
- exec.reset();
- })
-
- //--------------------------------------------------------------------------
- afterEach(function() {
- logger.level(savedLevel)
- logger.useConsole(true)
- console.useLogger(false)
- })
-
- //--------------------------------------------------------------------------
- it("is using the logger", function () {
- expect(console.useLogger()).toBe(true)
- })
-
- //--------------------------------------------------------------------------
- it("is not being used by logger", function () {
- expect(logger.useConsole()).toBe(false)
- })
-
- //--------------------------------------------------------------------------
- it("implements log() correctly", function () {
- console.log("%s", "1")
- expect(exec).toHaveBeenCalledWith(null, null, "Logger", "logLevel", [logger.LOG, "1"]);
- })
-
- //--------------------------------------------------------------------------
- it("implements error() correctly", function () {
- console.error("%s", "2")
- expect(exec).toHaveBeenCalledWith(null, null, "Logger", "logLevel", [logger.ERROR, "2"]);
- })
-
- //--------------------------------------------------------------------------
- it("implements warn() correctly", function () {
- console.warn("%s", "3")
- expect(exec).toHaveBeenCalledWith(null, null, "Logger", "logLevel", [logger.WARN, "3"]);
- })
-
- //--------------------------------------------------------------------------
- it("implements info() correctly", function () {
- console.info("%s", "4")
- expect(exec).toHaveBeenCalledWith(null, null, "Logger", "logLevel", [logger.INFO, "4"]);
- })
-
- //--------------------------------------------------------------------------
- it("implements debug() correctly", function () {
- console.debug("%s", "5")
- expect(exec).toHaveBeenCalledWith(null, null, "Logger", "logLevel", [logger.DEBUG, "5"]);
- })
-
- //--------------------------------------------------------------------------
- it("implements assert(false) correctly", function () {
- console.assert(false, "%s", 6)
- expect(exec).toHaveBeenCalledWith(null, null, "Logger", "logLevel", [logger.LOG, "ASSERT: 6"]);
- })
-
- it("implements assert(true) correctly", function () {
- console.assert(true, "%s", 6)
- expect(exec).not.toHaveBeenCalled();
- })
-
- //--------------------------------------------------------------------------
- it("does nothing for clear()", function () {
- console.clear()
- expect(exec).not.toHaveBeenCalled();
- })
-
- //--------------------------------------------------------------------------
- it("implements dir() correctly", function () {
- console.dir({a:1, b:2})
- expect(exec).toHaveBeenCalledWith(null, null, "Logger", "logLevel", [logger.LOG, '{"a":1,"b":2}']);
- })
-
- //--------------------------------------------------------------------------
- it("implements dirxml() correctly", function () {
- console.dirxml({ innerHTML: "<b>nonce</b>" })
- expect(exec).toHaveBeenCalledWith(null, null, "Logger", "logLevel", [logger.LOG, "<b>nonce</b>"]);
- })
-
- //--------------------------------------------------------------------------
- it("does nothing for trace()", function () {
- console.trace()
- expect(exec).not.toHaveBeenCalled();
- })
-
- //--------------------------------------------------------------------------
- it("implements group() correctly", function () {
- console.group("%s", 7)
- expect(exec).toHaveBeenCalledWith(null, null, "Logger", "logLevel", [logger.LOG, "7"]);
- })
-
- //--------------------------------------------------------------------------
- it("implements groupCollapsed() correctly", function () {
- console.groupCollapsed("%s", 8)
- expect(exec).toHaveBeenCalledWith(null, null, "Logger", "logLevel", [logger.LOG, "8"]);
- })
-
- //--------------------------------------------------------------------------
- it("does nothing for groupEnd()", function () {
- console.groupEnd()
- expect(exec).not.toHaveBeenCalled();
- })
-
- //--------------------------------------------------------------------------
- it("implements time() and timeEnd() correctly", function () {
- runs(function() {
- console.time("foo")
- expect(exec).not.toHaveBeenCalled();
- })
-
- waits(50)
-
- runs(function() {
- console.timeEnd("foo")
- var message = exec.mostRecentCall.args[4][1]
- expect(message).toMatch(/foo: \d+ms/)
- })
- })
-
- //--------------------------------------------------------------------------
- it("does nothing for timeStamp()", function () {
- console.timeStamp()
- expect(exec).not.toHaveBeenCalled();
- })
-
- //--------------------------------------------------------------------------
- it("does nothing for profile()", function () {
- console.profile()
- expect(exec).not.toHaveBeenCalled();
- })
-
- //--------------------------------------------------------------------------
- it("does nothing for profileEnd()", function () {
- console.profileEnd()
- expect(exec).not.toHaveBeenCalled();
- })
-
- //--------------------------------------------------------------------------
- it("does nothing for count()", function () {
- console.count()
- expect(exec).not.toHaveBeenCalled();
- })
-
- //--------------------------------------------------------------------------
- it("implements exception() correctly", function () {
- console.exception(new Error("bar"))
- expect(exec).toHaveBeenCalledWith(null, null, "Logger", "logLevel", [logger.LOG, "Error: bar"]);
- })
-
- //--------------------------------------------------------------------------
- it("implements table() correctly", function () {
- console.table({c:3,d:4})
- expect(exec).toHaveBeenCalledWith(null, null, "Logger", "logLevel", [logger.LOG, '{"c":3,"d":4}']);
- })
-})
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/test.contact.js
----------------------------------------------------------------------
diff --git a/test/test.contact.js b/test/test.contact.js
deleted file mode 100644
index 58662a0..0000000
--- a/test/test.contact.js
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("Contact", function () {
- var Contact = require('cordova/plugin/Contact'),
- exec = require('cordova/exec');
-
-
- describe("ctor", function () {
- it("sets the default values", function () {
- var c = new Contact();
-
- expect(c.id).toBe(null);
- expect(c.rawId).toBe(null);
- expect(c.displayName).toBe(null);
- expect(c.name).toBe(null);
- expect(c.nickname).toBe(null);
- expect(c.phoneNumbers).toEqual(null);
- expect(c.emails).toEqual(null);
- expect(c.addresses).toEqual(null);
- expect(c.ims).toEqual(null);
- expect(c.organizations).toEqual(null);
- expect(c.birthday).toBe(null);
- expect(c.note).toBe(null);
- expect(c.photos).toEqual(null);
- expect(c.categories).toEqual(null);
- expect(c.urls).toEqual(null);
- });
-
- it("overrides default values with the arguments", function () {
- var c = new Contact(
- 1,
- "Bart",
- "Bartholomew JoJo Simpson",
- "Bart",
- ["KL5-3223"],
- ["bart@but.com"],
- ["742 Evergreen Terrace, Springfield USA"],
- ["1234567"],
- ["Springfield Elementary"],
- new Date("April 1, 1979"),
- "Everybody in the house do the Bartman",
- ["http://upload.wikimedia.org/wikipedia/en/thumb/e/ed/Bart_Simpson.svg/200px-Bart_Simpson.svg.png"],
- ["simpson", "child"],
- ["www.thesimpsons.com"]
- );
-
- expect(c.id).toBe(1);
- expect(c.rawId).toBe(null);
- expect(c.displayName).toBe("Bart");
- expect(c.name).toBe("Bartholomew JoJo Simpson");
- expect(c.nickname).toBe("Bart");
- expect(c.phoneNumbers).toEqual(["KL5-3223"]);
- expect(c.emails).toEqual(["bart@but.com"]);
- expect(c.addresses).toEqual(["742 Evergreen Terrace, Springfield USA"]);
- expect(c.ims).toEqual(["1234567"]);
- expect(c.organizations).toEqual(["Springfield Elementary"]);
- expect(c.birthday).toEqual(new Date("April 1, 1979")),
- expect(c.note).toBe("Everybody in the house do the Bartman");
- expect(c.photos).toEqual(["http://upload.wikimedia.org/wikipedia/en/thumb/e/ed/Bart_Simpson.svg/200px-Bart_Simpson.svg.png"]);
- expect(c.categories).toEqual(["simpson", "child"]);
- expect(c.urls).toEqual(["www.thesimpsons.com"]);
- });
- });
-
- describe("clone", function () {
- it("clears the id's on the cloned contact", function () {
-
- var c = new Contact();
- c.id = 1;
- c.rawId = 1;
-
- c.phoneNumbers = [{id: 1}];
- c.emails = [{id: 1}];
- c.addresses = [{id: 1}];
- c.ims = [{id: 1}];
- c.organizations = [{id: 1}];
- c.categories = [{id: 1}];
- c.photos = [{id: 1}];
- c.urls = [{id: 1}];
-
- var clone = c.clone();
-
- expect(clone.id).toBeNull();
- expect(clone.rawId).toBeNull();
- expect(clone.phoneNumbers[0].id).toBeNull();
- expect(clone.emails[0].id).toBeNull();
- expect(clone.addresses[0].id).toBeNull();
- expect(clone.ims[0].id).toBeNull();
- expect(clone.organizations[0].id).toBeNull();
- expect(clone.categories[0].id).toBeNull();
- expect(clone.photos[0].id).toBeNull();
- expect(clone.urls[0].id).toBeNull();
- });
- });
-
- describe("save", function () {
- it("calls exec when saving", function () {
- var c = new Contact(),
- s = jasmine.createSpy(),
- e = jasmine.createSpy();
-
- c.save(s, e);
- expect(exec).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Function), "Contacts", "save", [c]);
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/test.contacts.js
----------------------------------------------------------------------
diff --git a/test/test.contacts.js b/test/test.contacts.js
deleted file mode 100644
index 4fa0d0d..0000000
--- a/test/test.contacts.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("contacts", function () {
- var contacts = require('cordova/plugin/contacts'),
- exec = require('cordova/exec'),
- Contact = require('cordova/plugin/Contact'),
- ContactError = require('cordova/plugin/ContactError');
-
- afterEach(function() {
- exec.reset();
- });
-
- describe("create", function () {
- it("returns a new contact", function () {
- expect(contacts.create() instanceof Contact).toBe(true);
- });
-
- it("will copy over properties that are set in the arguments", function () {
- var c = contacts.create({
- name: "Gord Tanner",
- note: "he moved the cheese"
- });
-
- expect(c.name).toBe("Gord Tanner");
- expect(c.note).toBe("he moved the cheese");
- });
-
- it("will not copy over properties that don't exist in the Contact object", function () {
- var c = contacts.create({
- isAwesome: "probably"
- });
-
- expect(c.isAwesome).not.toBeDefined();
- });
- });
-
- describe("find", function () {
- it("throws an error with no success callback", function () {
- expect(function() {contacts.find()}).toThrow();
- });
-
- it("doesn't call exec with null fields", function () {
- expect(function() {contacts.find(null, jasmine.createSpy())}).toThrow();
- });
-
- it("calls the error callback when no fields provided", function () {
- var success = jasmine.createSpy(),
- error = jasmine.createSpy();
-
- contacts.find([], success, error);
- expect(exec).not.toHaveBeenCalled();
- expect(error).toHaveBeenCalledWith(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
- });
-
- it("calls exec", function () {
- //http://www.imdb.com/title/tt0181536/
- var success = jasmine.createSpy(),
- error = jasmine.createSpy(),
- fields = ['*'],
- options = {};
-
- contacts.find(fields, success, error, options);
- expect(exec).toHaveBeenCalledWith(jasmine.any(Function), error, "Contacts", "search", [fields, options]);
- //HACK: I am not expecting to have our success function passed in as there is some stuff done clientside
- expect(exec).not.toHaveBeenCalledWith(success, error, "Contacts", "search", [fields, options]);
- });
-
- it("creates a contact for each value returned", function () {
- //http://www.imdb.com/title/tt0266543/
- var success = jasmine.createSpy(),
- error = jasmine.createSpy(),
- fields = ['*'],
- options = {};
-
- spyOn(contacts, "create");
- contacts.find(fields, success, error, options);
- //exec the success callback
- exec.mostRecentCall.args[0]([{
- name: "Nemo",
- note: "He has a lucky fin"
- },
- {
- name: "Nemo",
- note: "He is also a clownfish"
- }]);
-
- expect(contacts.create.callCount).toBe(2);
- expect(contacts.create).toHaveBeenCalledWith({
- name: "Nemo",
- note: "He has a lucky fin"
- });
- expect(contacts.create).toHaveBeenCalledWith({
- name: "Nemo",
- note: "He is also a clownfish"
- });
- });
-
- it("calls the success callback on success", function () {
- //http://www.imdb.com/title/tt0889134/
- var success = jasmine.createSpy(),
- error = jasmine.createSpy(),
- fields = ['*'],
- options = {};
-
- spyOn(contacts, "create").andReturn("Rehab");
- contacts.find(fields, success, error, options);
- //exec the success callback
- exec.mostRecentCall.args[0]([0, 0, 0]);
- expect(success).toHaveBeenCalledWith(["Rehab", "Rehab", "Rehab"]);
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f947df19/test/test.filetransfer.js
----------------------------------------------------------------------
diff --git a/test/test.filetransfer.js b/test/test.filetransfer.js
deleted file mode 100644
index 6c604b1..0000000
--- a/test/test.filetransfer.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe("FileTransfer", function() {
- var FileTransfer = new (require('cordova/plugin/FileTransfer'))();
- describe("download", function() {
- it("should throw an exception if source or target is not defined", function() {
- var win = jasmine.createSpy(),
- fail = jasmine.createSpy();
-
- expect(function() {
- FileTransfer.download(null, null, win, fail);
- }).toThrow();
- expect(function() {
- FileTransfer.download(undefined, undefined, win, fail);
- }).toThrow();
- expect(function() {
- FileTransfer.download(null, undefined, win, fail);
- }).toThrow();
- expect(function() {
- FileTransfer.download(undefined, null, win, fail);
- }).toThrow();
- expect(function() {
- FileTransfer.download("test.txt", undefined, win, fail);
- }).toThrow();
- expect(function() {
- FileTransfer.download(undefined, "http://google.com/robots.txt", win, fail);
- }).toThrow();
- });
- });
-
- describe("upload", function() {
- it("should throw an exception if filePath or server is not defined", function() {
- var win = jasmine.createSpy(),
- fail = jasmine.createSpy();
-
- expect(function() {
- FileTransfer.upload(null, null, win, fail);
- }).toThrow();
- expect(function() {
- FileTransfer.upload(undefined, undefined, win, fail);
- }).toThrow();
- expect(function() {
- FileTransfer.upload(null, undefined, win, fail);
- }).toThrow();
- expect(function() {
- FileTransfer.upload(undefined, null, win, fail);
- }).toThrow();
- expect(function() {
- FileTransfer.upload("test.txt", undefined, win, fail);
- }).toThrow();
- expect(function() {
- FileTransfer.upload(undefined, "http://google.com/robots.txt", win, fail);
- }).toThrow();
- });
- });
-});