CB-10636 Add JSHint for plugins

Fixed autotests
This commit is contained in:
daserge 2016-02-19 12:04:40 +03:00
parent e401a4de0f
commit 5ea854d8c3
9 changed files with 46 additions and 12 deletions

16
.jshintrc Normal file
View File

@ -0,0 +1,16 @@
{
"browser": true
, "devel": true
, "bitwise": true
, "undef": true
, "trailing": true
, "quotmark": false
, "indent": 4
, "unused": "vars"
, "latedef": "nofunc"
, "globals": {
"module": false,
"exports": false,
"require": false
}
}

4
.travis.yml Normal file
View File

@ -0,0 +1,4 @@
language: node_js
sudo: false
node_js:
- "4.2"

View File

@ -17,6 +17,8 @@
# under the License.
-->
[![Build Status](https://travis-ci.org/apache/cordova-plugin-splashscreen.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-splashscreen)
# cordova-plugin-splashscreen
This plugin displays and hides a splash screen during application launch.

View File

@ -34,6 +34,10 @@
"cordova-windows",
"cordova-tizen"
],
"scripts": {
"test": "npm run jshint",
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
},
"engines": [
{
"name": "cordova-android",
@ -41,5 +45,8 @@
}
],
"author": "Apache Software Foundation",
"license": "Apache-2.0"
"license": "Apache-2.0",
"devDependencies": {
"jshint": "^2.6.0"
}
}

View File

@ -14,6 +14,8 @@
* limitations under the License.
*/
/* global PluginResult */
module.exports = {
show: function (success, fail, args, env) {
var result = new PluginResult(args, env);

View File

@ -18,17 +18,18 @@
* under the License.
*
*/
// Default parameter values including image size can be changed in `config.xml`
var splashImageWidth = 170;
var splashImageHeight = 200;
var position = { x: 0, y: 0, width: splashImageWidth, height: splashImageHeight };
var splash = null; //
var localSplash; // the image to display
var localSplashImage;
var bgColor = "#464646";
var imageSrc = 'img/logo.png';
var splashScreenDelay = 3000; // in milliseconds
var showSplashScreen = true; // show splashcreen by default
var cordova = require('cordova');
var configHelper = cordova.require('cordova/confighelper');
function updateImageLocation() {
@ -103,7 +104,6 @@ function readPreferencesFromCfg(cfg) {
} catch(e) {
var msg = '[Browser][SplashScreen] Error occured on loading preferences from config.xml: ' + JSON.stringify(e);
console.error(msg);
error(msg);
}
}

View File

@ -19,6 +19,8 @@
*
*/
/* global win:true */
( function() {
win = null;

View File

@ -19,18 +19,20 @@
*
*/
exports.defineAutoTest = function () {
/* jshint jasmine: true */
exports.defineAutoTests = function () {
describe('Splashscreen (cordova)', function () {
it("splashscreen.spec.1 should exist", function () {
expect(navigator.splashscreen).toBeDefined();
});
it("splashscreen.spec.2 exec method should exist", function () {
it("splashscreen.spec.2 show method should exist", function () {
expect(navigator.splashscreen.show).toBeDefined();
expect(typeof navigator.splashscreen.show).toBe('function');
});
it("splashscreen.spec.3 exec method should exist", function () {
it("splashscreen.spec.3 hide method should exist", function () {
expect(navigator.splashscreen.hide).toBeDefined();
expect(typeof navigator.splashscreen.hide).toBe('function');
});

View File

@ -20,17 +20,16 @@
*/
/*jslint sloppy:true */
/*global Windows:true, require, module, window, document, WinJS */
/*global WinJS */
var cordova = require('cordova'),
channel = require('cordova/channel');
var cordova = require('cordova');
var isPhone = (cordova.platformId == "windows") && WinJS.Utilities.isPhone;
var isHosted = window.location.protocol.indexOf('http') === 0;
var localSplash = null;
var localSplash = null, localSplashImage = null;
var bgColor = "#464646"; // default backgrond color; TDOO - read it from .appxmanifest
var splashImageSrc = (isHosted ? "ms-appx-web" : "ms-appx") + ":///images/"
+ (isPhone ? "splashscreenphone.png" : "splashscreen.png");
var splashImageSrc = (isHosted ? "ms-appx-web" : "ms-appx") + ":///images/" +
(isPhone ? "splashscreenphone.png" : "splashscreen.png");
var SplashScreen = {
setBGColor: function (cssBGColor) {