From 95d1aea4f1a8f4b31a3e1a2602cc36ea5dfc3fdd Mon Sep 17 00:00:00 2001 From: Andrew Joslin Date: Thu, 8 May 2014 09:10:27 -0600 Subject: [PATCH] chore(travis): re-enable jshint --- .jshintrc | 12 +- gulpfile.js | 16 ++- js/angular/directive/menuToggle.js | 2 +- js/angular/directive/slideBox.js | 8 +- js/animation/gl-matrix.js | 108 +++++++++--------- js/animation/timing-functions.js | 10 +- js/utils/utils.js | 2 +- js/utils/viewport.js | 2 +- js/views/listView.js | 7 +- js/views/scrollView.js | 18 +-- js/views/sliderView.js | 28 ++--- package.json | 5 +- .../controller/scrollController.unit.js | 2 +- test/unit/angular/directive/navBar.unit.js | 2 +- test/unit/angular/directive/refresher.unit.js | 2 +- test/unit/angular/directive/sideMenu.unit.js | 12 +- test/unit/angular/directive/slideBox.unit.js | 60 +++++----- test/unit/angular/directive/tabs.unit.js | 2 +- test/unit/angular/directive/toggle.unit.js | 10 +- .../angular/service/delegateService.unit.js | 4 +- test/unit/angular/service/platform.unit.js | 26 ++--- test/unit/angular/service/popup.unit.js | 2 +- test/unit/angular/service/viewService.unit.js | 18 +-- test/unit/utils/keyboard.unit.js | 10 +- test/unit/utils/tap.unit.js | 17 ++- test/unit/utils/viewport.unit.js | 4 +- test/unit/views/scrollView.unit.js | 2 +- 27 files changed, 197 insertions(+), 194 deletions(-) diff --git a/.jshintrc b/.jshintrc index f4f57b8f56..fe01d3d406 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,13 +1,3 @@ { - "expr": true, - "browser": true, - "multistr": true, - "globals": { - "jQuery": true, - "ionic": true, - "angular": true, - "console": true, - "module": true, - "document": true - } + "expr": true } diff --git a/gulpfile.js b/gulpfile.js index b253e1067a..420ec4fe6e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -48,6 +48,7 @@ if (IS_RELEASE_BUILD) { gulp.task('default', ['build']); gulp.task('build', ['bundle', 'sass']); +gulp.task('validate', ['jshint', 'ddescribe-iit', 'karma']); gulp.task('docs', function(done) { var docVersion = argv['doc-version']; @@ -113,18 +114,21 @@ gulp.task('bundle', [ }); gulp.task('jshint', function() { - return gulp.src(['js/**/*.js', 'test/**/*.js']) + return gulp.src(['js/**/*.js']) .pipe(jshint('.jshintrc')) - .pipe(jshint.reporter('jshint-stylish')); + .pipe(jshint.reporter(require('jshint-summary')({ + fileColCol: ',bold', + positionCol: ',bold', + codeCol: 'green,bold', + reasonCol: 'cyan' + }))) + .pipe(jshint.reporter('fail')); }); gulp.task('ddescribe-iit', function() { return gulp.src(['test/**/*.js', 'js/**/*.js']) .pipe(notContains([ - 'ddescribe', - 'iit', - 'xit', - 'xdescribe' + 'ddescribe', 'iit', 'xit', 'xdescribe' ])); }); diff --git a/js/angular/directive/menuToggle.js b/js/angular/directive/menuToggle.js index 6ed0a0e38d..3328e50be8 100644 --- a/js/angular/directive/menuToggle.js +++ b/js/angular/directive/menuToggle.js @@ -36,5 +36,5 @@ IonicModule }); } }; -}]) +}]); diff --git a/js/angular/directive/slideBox.js b/js/angular/directive/slideBox.js index 9e421b43e3..d289d60d4d 100644 --- a/js/angular/directive/slideBox.js +++ b/js/angular/directive/slideBox.js @@ -119,10 +119,10 @@ function($timeout, $compile, $ionicSlideBoxDelegate) { slider.load(); }); }], - template: '
\ -
\ -
\ -
', + template: '
' + + '
' + + '
' + + '
', link: function($scope, $element, $attr, slideBoxCtrl) { // If the pager should show, append it to the slide box diff --git a/js/animation/gl-matrix.js b/js/animation/gl-matrix.js index 75e7d0df82..3b22c7979a 100644 --- a/js/animation/gl-matrix.js +++ b/js/animation/gl-matrix.js @@ -627,7 +627,7 @@ vec2.str = function (a) { if(typeof(exports) !== 'undefined') { exports.vec2 = vec2; } -; + /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -1120,23 +1120,23 @@ vec3.transformQuat = function(out, a, q) { * @returns {vec3} out */ vec3.rotateX = function(out, a, b, c){ - var p = [], r=[]; - //Translate point to the origin - p[0] = a[0] - b[0]; - p[1] = a[1] - b[1]; - p[2] = a[2] - b[2]; + var p = [], r=[]; + //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; - //perform rotation - r[0] = p[0]; - r[1] = p[1]*Math.cos(c) - p[2]*Math.sin(c); - r[2] = p[1]*Math.sin(c) + p[2]*Math.cos(c); + //perform rotation + r[0] = p[0]; + r[1] = p[1]*Math.cos(c) - p[2]*Math.sin(c); + r[2] = p[1]*Math.sin(c) + p[2]*Math.cos(c); - //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; + //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; - return out; + return out; }; /* @@ -1148,23 +1148,23 @@ vec3.rotateX = function(out, a, b, c){ * @returns {vec3} out */ vec3.rotateY = function(out, a, b, c){ - var p = [], r=[]; - //Translate point to the origin - p[0] = a[0] - b[0]; - p[1] = a[1] - b[1]; - p[2] = a[2] - b[2]; + var p = [], r=[]; + //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; - //perform rotation - r[0] = p[2]*Math.sin(c) + p[0]*Math.cos(c); - r[1] = p[1]; - r[2] = p[2]*Math.cos(c) - p[0]*Math.sin(c); + //perform rotation + r[0] = p[2]*Math.sin(c) + p[0]*Math.cos(c); + r[1] = p[1]; + r[2] = p[2]*Math.cos(c) - p[0]*Math.sin(c); - //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; + //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; - return out; + return out; }; /* @@ -1176,23 +1176,23 @@ vec3.rotateY = function(out, a, b, c){ * @returns {vec3} out */ vec3.rotateZ = function(out, a, b, c){ - var p = [], r=[]; - //Translate point to the origin - p[0] = a[0] - b[0]; - p[1] = a[1] - b[1]; - p[2] = a[2] - b[2]; + var p = [], r=[]; + //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; - //perform rotation - r[0] = p[0]*Math.cos(c) - p[1]*Math.sin(c); - r[1] = p[0]*Math.sin(c) + p[1]*Math.cos(c); - r[2] = p[2]; + //perform rotation + r[0] = p[0]*Math.cos(c) - p[1]*Math.sin(c); + r[1] = p[0]*Math.sin(c) + p[1]*Math.cos(c); + r[2] = p[2]; - //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; + //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; - return out; + return out; }; /** @@ -1249,7 +1249,7 @@ vec3.str = function (a) { if(typeof(exports) !== 'undefined') { exports.vec3 = vec3; } -; + /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -1774,7 +1774,7 @@ vec4.str = function (a) { if(typeof(exports) !== 'undefined') { exports.vec4 = vec4; } -; + /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -2017,7 +2017,7 @@ mat2.str = function (a) { * @returns {Number} Frobenius norm */ mat2.frob = function (a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2))) + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2))); }; /** @@ -2039,7 +2039,7 @@ mat2.LDU = function (L, D, U, a) { if(typeof(exports) !== 'undefined') { exports.mat2 = mat2; } -; + /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -2291,13 +2291,13 @@ mat2d.str = function (a) { * @returns {Number} Frobenius norm */ mat2d.frob = function (a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + 1)) + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + 1)); }; if(typeof(exports) !== 'undefined') { exports.mat2d = mat2d; } -; + /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -2781,14 +2781,14 @@ mat3.str = function (a) { * @returns {Number} Frobenius norm */ mat3.frob = function (a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2))) + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2))); }; if(typeof(exports) !== 'undefined') { exports.mat3 = mat3; } -; + /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -3693,14 +3693,14 @@ mat4.str = function (a) { * @returns {Number} Frobenius norm */ mat4.frob = function (a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2) + Math.pow(a[9], 2) + Math.pow(a[10], 2) + Math.pow(a[11], 2) + Math.pow(a[12], 2) + Math.pow(a[13], 2) + Math.pow(a[14], 2) + Math.pow(a[15], 2) )) + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2) + Math.pow(a[9], 2) + Math.pow(a[10], 2) + Math.pow(a[11], 2) + Math.pow(a[12], 2) + Math.pow(a[13], 2) + Math.pow(a[14], 2) + Math.pow(a[15], 2) )); }; if(typeof(exports) !== 'undefined') { exports.mat4 = mat4; } -; + /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -4230,7 +4230,7 @@ quat.str = function (a) { if(typeof(exports) !== 'undefined') { exports.quat = quat; } -; + diff --git a/js/animation/timing-functions.js b/js/animation/timing-functions.js index 5fba8c0347..a34fb114e2 100644 --- a/js/animation/timing-functions.js +++ b/js/animation/timing-functions.js @@ -8,27 +8,27 @@ 'linear': function(duration) { return function(t) { return ionic.Animation.Bezier.linear(t, duration); - } + }; }, 'ease': function(duration) { return function(t) { return ionic.Animation.Bezier.ease(t, duration); - } + }; }, 'ease-in': function(duration) { return function(t) { return ionic.Animation.Bezier.easeIn(t, duration); - } + }; }, 'ease-out': function(duration) { return function(t) { return ionic.Animation.Bezier.easeOut(t, duration); - } + }; }, 'ease-in-out': function(duration) { return function(t) { return ionic.Animation.Bezier.easeInOut(t, duration); - } + }; } }; })(window); diff --git a/js/utils/utils.js b/js/utils/utils.js index 5e2009e841..96e2a82113 100644 --- a/js/utils/utils.js +++ b/js/utils/utils.js @@ -117,7 +117,7 @@ // `parent`'s constructor function. var Surrogate = function(){ this.constructor = child; }; Surrogate.prototype = parent.prototype; - child.prototype = new Surrogate; + child.prototype = new Surrogate(); // Add prototype properties (instance properties) to the subclass, // if supplied. diff --git a/js/utils/viewport.js b/js/utils/viewport.js index 372185c4f0..23e14a25cd 100644 --- a/js/utils/viewport.js +++ b/js/utils/viewport.js @@ -25,7 +25,7 @@ function viewportLoadTag() { var props = viewportTag.content.toLowerCase().replace(/\s+/g, '').split(','); var keyValue; for(x=0; x 1 ? keyValue[1] : '_'); } diff --git a/js/views/listView.js b/js/views/listView.js index 1e281bc64e..ce6a94bcc9 100644 --- a/js/views/listView.js +++ b/js/views/listView.js @@ -192,7 +192,7 @@ ReorderDrag.prototype._moveElement = function(e) { var y = e.gesture.center.pageY - - this._currentDrag.elementHeight + + this._currentDrag.elementHeight + this.scrollView.getValues().top - this.listEl.offsetTop; this.el.style[ionic.CSS.TRANSFORM] = 'translate3d(0, '+y+'px, 0)'; @@ -457,10 +457,11 @@ this._isDragging = false; var lastDragOp = this._lastDragOp; + var item; // Check if this is a reorder drag if(ionic.DomUtil.getParentOrSelfWithClass(e.target, ITEM_REORDER_BTN_CLASS) && (e.gesture.direction == 'up' || e.gesture.direction == 'down')) { - var item = this._getItem(e.target); + item = this._getItem(e.target); if(item) { this._dragOp = new ReorderDrag({ @@ -481,7 +482,7 @@ else if(!this._didDragUpOrDown && (e.gesture.direction == 'left' || e.gesture.direction == 'right') && Math.abs(e.gesture.deltaX) > 5) { // Make sure this is an item with buttons - var item = this._getItem(e.target); + item = this._getItem(e.target); if(item && item.querySelector('.item-options')) { this._dragOp = new SlideDrag({ el: this.el, canSwipe: this.canSwipe }); this._dragOp.start(e); diff --git a/js/views/scrollView.js b/js/views/scrollView.js index 70e5d9ceef..6c61d3a1ec 100644 --- a/js/views/scrollView.js +++ b/js/views/scrollView.js @@ -12,6 +12,8 @@ * License: MIT + Apache (V2) */ +/* jshint eqnull: true */ + /** * Generic animation class with support for dropped frames both optional easing and duration. * @@ -805,12 +807,12 @@ ionic.views.Scroll = ionic.views.View.inherit({ //For Firefox document.addEventListener('mousewheel', onMouseWheel); - function onMouseWheel(e) { - self.hintResize(); - wheelShowBarFn(); - self.scrollBy(e.wheelDeltaX/self.options.wheelDampen, -e.wheelDeltaY/self.options.wheelDampen); - wheelHideBarFn(); - } + } + function onMouseWheel(e) { + self.hintResize(); + wheelShowBarFn(); + self.scrollBy(e.wheelDeltaX/self.options.wheelDampen, -e.wheelDeltaY/self.options.wheelDampen); + wheelHideBarFn(); } }, @@ -1965,7 +1967,7 @@ ionic.views.Scroll = ionic.views.View.inherit({ self.__maxScrollLeft = Math.max((self.__contentWidth * zoomLevel) - self.__clientWidth, 0); self.__maxScrollTop = Math.max((self.__contentHeight * zoomLevel) - self.__clientHeight, 0); - if(!self.__didWaitForSize && self.__maxScrollLeft == 0 && self.__maxScrollTop == 0) { + if(!self.__didWaitForSize && !self.__maxScrollLeft && !self.__maxScrollTop) { self.__didWaitForSize = true; self.__waitForSize(); } @@ -1984,7 +1986,7 @@ ionic.views.Scroll = ionic.views.View.inherit({ var sizer = function() { self.resize(); - if((self.options.scrollingX && self.__maxScrollLeft == 0) || (self.options.scrollingY && self.__maxScrollTop == 0)) { + if((self.options.scrollingX && !self.__maxScrollLeft) || (self.options.scrollingY && !self.__maxScrollTop)) { //self.__sizerTimeout = setTimeout(sizer, 1000); } }; diff --git a/js/views/sliderView.js b/js/views/sliderView.js index 708b20158a..fc87e72ac7 100644 --- a/js/views/sliderView.js +++ b/js/views/sliderView.js @@ -194,11 +194,11 @@ ionic.views.Slider = ionic.views.View.inherit({ } - var start = +new Date; + var start = +new Date(); var timer = setInterval(function() { - var timeElap = +new Date - start; + var timeElap = +new Date() - start; if (timeElap > speed) { @@ -283,7 +283,7 @@ ionic.views.Slider = ionic.views.View.inherit({ y: touches.pageY, // store time to determine touch duration - time: +new Date + time: +new Date() }; @@ -348,9 +348,9 @@ ionic.views.Slider = ionic.views.View.inherit({ delta.x = delta.x / - ( (!index && delta.x > 0 // if first slide and sliding left - || index == slides.length - 1 // or if last slide and sliding right - && delta.x < 0 // and if sliding at all + ( (!index && delta.x > 0 || // if first slide and sliding left + index == slides.length - 1 && // or if last slide and sliding right + delta.x < 0 // and if sliding at all ) ? ( Math.abs(delta.x) / width + 1 ) // determine resistance level : 1 ); // no resistance if false @@ -367,18 +367,18 @@ ionic.views.Slider = ionic.views.View.inherit({ end: function(event) { // measure duration - var duration = +new Date - start.time; + var duration = +new Date() - start.time; // determine if slide attempt triggers next/prev slide var isValidSlide = - Number(duration) < 250 // if slide duration is less than 250ms - && Math.abs(delta.x) > 20 // and if slide amt is greater than 20px - || Math.abs(delta.x) > width/2; // or if slide amt is greater than half the width + Number(duration) < 250 && // if slide duration is less than 250ms + Math.abs(delta.x) > 20 || // and if slide amt is greater than 20px + Math.abs(delta.x) > width/2; // or if slide amt is greater than half the width // determine if slide attempt is past start and end var isPastBounds = - !index && delta.x > 0 // if first slide and slide amt is greater than 0 - || index == slides.length - 1 && delta.x < 0; // or if last slide and slide amt is less than 0 + !index && delta.x > 0 | // if first slide and slide amt is greater than 0 + index == slides.length - 1 && delta.x < 0; // or if last slide and slide amt is less than 0 if (options.continuous) isPastBounds = false; @@ -465,7 +465,7 @@ ionic.views.Slider = ionic.views.View.inherit({ } - } + }; // Public API this.update = function() { @@ -591,7 +591,7 @@ ionic.views.Slider = ionic.views.View.inherit({ window.onresize = function () { setup(); }; // to play nice with old IE } - } + }; } }); diff --git a/package.json b/package.json index 066f409aba..451dc42aa3 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "sauce-connect-launcher": "^0.2.2", "dgeni": "^0.2.0", "dgeni-packages": "^0.7.1", - "jshint-stylish": "^0.1.5", "gulp-template": "^0.1.1", "gulp-concat": "^2.1.7", "gulp-jshint": "^1.5.0", @@ -47,7 +46,9 @@ "gulp-footer": "^1.0.4", "marked": "^0.3.2", "ircb": "^0.3.1", - "node-twitter-api": "^1.2.2" + "node-twitter-api": "^1.2.2", + "chalk": "^0.4.0", + "jshint-summary": "^0.3.0" }, "licenses": [ { diff --git a/test/unit/angular/controller/scrollController.unit.js b/test/unit/angular/controller/scrollController.unit.js index 17a6f537f6..91d92f931e 100644 --- a/test/unit/angular/controller/scrollController.unit.js +++ b/test/unit/angular/controller/scrollController.unit.js @@ -127,7 +127,7 @@ describe('$ionicScroll Controller', function() { it('should forget on $viewHistory.viewBack after $viewContentLoaded', inject(function($rootScope, $timeout) { var historyData = { viewId: 'foo' }; setup(); - spyOn($rootScope, '$on').andCallThrough();; + spyOn($rootScope, '$on').andCallThrough(); scope.$broadcast('$viewContentLoaded', historyData); $timeout.flush(); expect(scope.$on).toHaveBeenCalledWith('$viewHistory.viewBack', jasmine.any(Function)); diff --git a/test/unit/angular/directive/navBar.unit.js b/test/unit/angular/directive/navBar.unit.js index 9b9a17dd12..0da3fd3d94 100644 --- a/test/unit/angular/directive/navBar.unit.js +++ b/test/unit/angular/directive/navBar.unit.js @@ -105,7 +105,7 @@ describe('ionNavBar', function() { ctrl.setTitle('baz'); expect($scope.title).toBe('baz'); expect($scope.oldTitle).toBe('bar'); - }) + }); it('should getTitle', function() { var ctrl = setup(); diff --git a/test/unit/angular/directive/refresher.unit.js b/test/unit/angular/directive/refresher.unit.js index 54f1ba5c09..2425da6270 100644 --- a/test/unit/angular/directive/refresher.unit.js +++ b/test/unit/angular/directive/refresher.unit.js @@ -53,7 +53,7 @@ describe('ionRefresher directive', function() { expect(el.controller('$ionicScroll')._setRefresher.callCount).toBe(1); expect(el.controller('$ionicScroll')._setRefresher).toHaveBeenCalledWith( el.scope(), el[0] - ) + ); }); it('should listen for scroll.refreshComplete', function() { diff --git a/test/unit/angular/directive/sideMenu.unit.js b/test/unit/angular/directive/sideMenu.unit.js index 8d8fe69d07..2916cfefe9 100644 --- a/test/unit/angular/directive/sideMenu.unit.js +++ b/test/unit/angular/directive/sideMenu.unit.js @@ -92,19 +92,19 @@ describe('Ionic Angular Side Menu', function() { expect(ctrl.isDraggableTarget(e)).toBe(false); e.target.isContentEditable = false; - e.target.dataset.preventScroll = true + e.target.dataset.preventScroll = true; expect(ctrl.isDraggableTarget(e)).toBe(false); e.target.isContentEditable = false; e.target.dataset = undefined; e.target.getAttribute = function(val){ return (val == 'data-prevent-default' ? 'true' : undefined); - } + }; expect(ctrl.isDraggableTarget(e)).toBe(false); e.target.getAttribute = function(){ return null; - } + }; expect(ctrl.isDraggableTarget(e)).toBe(true); })); @@ -195,8 +195,8 @@ describe('menuToggle directive', function() { var toggleLeftSpy, toggleRightSpy; function setup(side) { var el = angular.element('
'); - toggleLeftSpy = jasmine.createSpy('toggleLeft') - toggleRightSpy = jasmine.createSpy('toggleRight') + toggleLeftSpy = jasmine.createSpy('toggleLeft'); + toggleRightSpy = jasmine.createSpy('toggleRight'); el.data('$ionSideMenusController', { toggleLeft: toggleLeftSpy, toggleRight: toggleRightSpy @@ -242,7 +242,7 @@ describe('menuClose directive', function() { })); it('should close on click', inject(function($compile, $rootScope) { var el = angular.element('
'); - var closeSpy = jasmine.createSpy('sideMenuClose') + var closeSpy = jasmine.createSpy('sideMenuClose'); el.data('$ionSideMenusController', { close: closeSpy }); diff --git a/test/unit/angular/directive/slideBox.unit.js b/test/unit/angular/directive/slideBox.unit.js index 4d36dfdbe7..bff2f990a7 100644 --- a/test/unit/angular/directive/slideBox.unit.js +++ b/test/unit/angular/directive/slideBox.unit.js @@ -12,21 +12,21 @@ describe('Ionic Angular Slide Box', function() { rootScope = $rootScope; compile = $compile; - el = $compile('\ - \ -
\ -

BLUE {{slideBox.slideIndex}}

\ -
\ -
\ - \ -
\ -

YELLOW {{slideBox.slideIndex}}

\ -
\ -
\ - \ -

PINK {{slideBox.slideIndex}}

\ -
\ -
')($rootScope); + el = $compile('' + + '' + + '
' + + '

BLUE {{slideBox.slideIndex}}

' + + '
' + + '
' + + '' + + '
' + + '

YELLOW {{slideBox.slideIndex}}

' + + '
' + + '
' + + '' + + '

PINK {{slideBox.slideIndex}}

' + + '
' + + '
')($rootScope); })); it('should register with $ionicSlideBoxDelegate', inject(function($compile, $rootScope, $ionicSlideBoxDelegate) { @@ -50,21 +50,21 @@ describe('ionSlideBox with active slide', function() { beforeEach(module('ionic')); it('Should set initial active slide', inject(function($ionicSlideBoxDelegate, $rootScope, $compile) { - el = $compile('\ - \ -
\ -

BLUE {{slideBox.slideIndex}}

\ -
\ -
\ - \ -
\ -

YELLOW {{slideBox.slideIndex}}

\ -
\ -
\ - \ -

PINK {{slideBox.slideIndex}}

\ -
\ -
')($rootScope.$new()); + el = $compile('' + + '' + + '
' + + '

BLUE {{slideBox.slideIndex}}

' + + '
' + + '
' + + '' + + '
' + + '

YELLOW {{slideBox.slideIndex}}

' + + '
' + + '
' + + '' + + '

PINK {{slideBox.slideIndex}}

' + + '
' + + '
')($rootScope.$new()); var scope = el.scope(); scope.$apply(); diff --git a/test/unit/angular/directive/tabs.unit.js b/test/unit/angular/directive/tabs.unit.js index 6d43baecd0..6c8773055f 100644 --- a/test/unit/angular/directive/tabs.unit.js +++ b/test/unit/angular/directive/tabs.unit.js @@ -69,7 +69,7 @@ describe('tabs', function() { ctrl.remove(tab1); expect(ctrl.selectedTab()).toBe(tab2); expect(ctrl.tabs.indexOf(tab1)).toBe(-1); - ctrl.remove(tab2) + ctrl.remove(tab2); expect(ctrl.selectedTab()).toBe(null); expect(ctrl.tabs.indexOf(tab2)).toBe(-1); expect(ctrl.tabs.length).toBe(0); diff --git a/test/unit/angular/directive/toggle.unit.js b/test/unit/angular/directive/toggle.unit.js index 54261f7c0a..4f1d361fc4 100644 --- a/test/unit/angular/directive/toggle.unit.js +++ b/test/unit/angular/directive/toggle.unit.js @@ -36,7 +36,7 @@ describe('Ionic Toggle', function() { // Not disabled, we can toggle expect(toggle.val()).toBe(false); - ionic.trigger('click', {target: label}) + ionic.trigger('click', {target: label}); expect(toggle.val()).toBe(true); // Disable it @@ -45,7 +45,7 @@ describe('Ionic Toggle', function() { expect(input.getAttribute('disabled')).toBe('disabled'); // We shouldn't be able to toggle it now - ionic.trigger('click', {target: label}) + ionic.trigger('click', {target: label}); expect(toggle.val()).toBe(true); // Re-enable it @@ -53,7 +53,7 @@ describe('Ionic Toggle', function() { rootScope.$apply(); // Should be able to toggle it now - ionic.trigger('click', {target: label}) + ionic.trigger('click', {target: label}); expect(toggle.val()).toBe(false); expect(input.getAttribute('disabled')).not.toBe('disabled'); }); @@ -62,9 +62,9 @@ describe('Ionic Toggle', function() { var toggle = el.isolateScope().toggle; var label = el[0].querySelector('label'); expect(toggle.val()).toBe(false); - ionic.trigger('click', {target: label}) + ionic.trigger('click', {target: label}); expect(toggle.val()).toBe(true); - ionic.trigger('click', {target: label}) + ionic.trigger('click', {target: label}); expect(toggle.val()).toBe(false); }); diff --git a/test/unit/angular/service/delegateService.unit.js b/test/unit/angular/service/delegateService.unit.js index c35d1e90ea..6db8133188 100644 --- a/test/unit/angular/service/delegateService.unit.js +++ b/test/unit/angular/service/delegateService.unit.js @@ -127,7 +127,7 @@ describe('DelegateFactory', function() { expect(result).toBe('a1'); instance1.a.reset(); - var result = delegate.$getByHandle('2').a(2,3,4); + result = delegate.$getByHandle('2').a(2,3,4); expect(instance2.a).toHaveBeenCalledWith(2,3,4); expect(instance1.a).not.toHaveBeenCalled(); expect(result).toBe('a2'); @@ -151,7 +151,7 @@ describe('DelegateFactory', function() { instance1.a.reset(); deregister(); - var result = delegateInstance.a(2); + result = delegateInstance.a(2); expect(instance1.a).not.toHaveBeenCalled(); expect(instance2.a).toHaveBeenCalledWith(2); expect(instance3.a).not.toHaveBeenCalled(); diff --git a/test/unit/angular/service/platform.unit.js b/test/unit/angular/service/platform.unit.js index 918381ed2b..98af3b0c19 100644 --- a/test/unit/angular/service/platform.unit.js +++ b/test/unit/angular/service/platform.unit.js @@ -165,7 +165,7 @@ describe('Ionic Platform Service', function() { ionic.Platform.setPlatform('iOS'); ionic.Platform.setVersion('7.0.3'); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.platforms[0]).toEqual('webview'); expect(ionic.Platform.platforms[1]).toEqual('cordova'); @@ -179,7 +179,7 @@ describe('Ionic Platform Service', function() { ionic.Platform.setPlatform('android'); ionic.Platform.setVersion('4.2.3'); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.platforms[0]).toEqual('webview'); expect(ionic.Platform.platforms[1]).toEqual('cordova'); @@ -193,7 +193,7 @@ describe('Ionic Platform Service', function() { ionic.Platform.setPlatform(''); ionic.Platform.setVersion(''); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.platforms.length).toEqual(2); expect(ionic.Platform.platforms[0]).toEqual('webview'); @@ -207,7 +207,7 @@ describe('Ionic Platform Service', function() { ionic.Platform.setPlatform(''); ionic.Platform.setVersion(''); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.platforms[0]).toEqual('browser'); }); @@ -216,7 +216,7 @@ describe('Ionic Platform Service', function() { window.cordova = {}; ionic.Platform.setPlatform('iOS'); ionic.Platform.setVersion('7.1.1'); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.grade).toEqual('a'); }); @@ -224,7 +224,7 @@ describe('Ionic Platform Service', function() { window.cordova = {}; ionic.Platform.setPlatform('iOS'); ionic.Platform.setVersion('6.1.1'); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.grade).toEqual('a'); }); @@ -232,7 +232,7 @@ describe('Ionic Platform Service', function() { window.cordova = {}; ionic.Platform.setPlatform('android'); ionic.Platform.setVersion('4.4.1'); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.grade).toEqual('a'); }); @@ -240,7 +240,7 @@ describe('Ionic Platform Service', function() { window.cordova = {}; ionic.Platform.setPlatform('android'); ionic.Platform.setVersion('4.3.1'); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.grade).toEqual('b'); }); @@ -248,7 +248,7 @@ describe('Ionic Platform Service', function() { window.cordova = {}; ionic.Platform.setPlatform('android'); ionic.Platform.setVersion('4.0.0'); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.grade).toEqual('b'); }); @@ -256,7 +256,7 @@ describe('Ionic Platform Service', function() { window.cordova = {}; ionic.Platform.setPlatform('android'); ionic.Platform.setVersion('3.0.0'); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.grade).toEqual('c'); }); @@ -264,7 +264,7 @@ describe('Ionic Platform Service', function() { window.cordova = {}; ionic.Platform.setPlatform('android'); ionic.Platform.setVersion('2.3.4'); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.grade).toEqual('c'); }); @@ -272,7 +272,7 @@ describe('Ionic Platform Service', function() { window.cordova = {}; ionic.Platform.setPlatform('android'); ionic.Platform.setVersion('0'); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.grade).toEqual('a'); }); @@ -280,7 +280,7 @@ describe('Ionic Platform Service', function() { window.cordova = {}; ionic.Platform.setPlatform('whatever'); ionic.Platform.setVersion('20.3.4'); - ionic.Platform._checkPlatforms() + ionic.Platform._checkPlatforms(); expect(ionic.Platform.grade).toEqual('a'); }); diff --git a/test/unit/angular/service/popup.unit.js b/test/unit/angular/service/popup.unit.js index 2caecb22f9..0936558367 100644 --- a/test/unit/angular/service/popup.unit.js +++ b/test/unit/angular/service/popup.unit.js @@ -67,7 +67,7 @@ describe('$ionicPopup service', function() { }); it('should resolve with return value from button.onTap', function() { popup.scope.$buttonTapped({ - onTap: function() { return '123' } + onTap: function() { return '123'; } }, {}); expect(popup.responseDeferred.resolve).toHaveBeenCalledWith('123'); }); diff --git a/test/unit/angular/service/viewService.unit.js b/test/unit/angular/service/viewService.unit.js index 4d001b0655..22c50c09fe 100644 --- a/test/unit/angular/service/viewService.unit.js +++ b/test/unit/angular/service/viewService.unit.js @@ -30,7 +30,7 @@ describe('Ionic View Service', function() { .state('tabs.tab3view1', {}) .state('tabs.tab3view2', {}) - .state('tabs.tab3view3', {}) + .state('tabs.tab3view3', {}); })); @@ -38,7 +38,7 @@ describe('Ionic View Service', function() { viewService = $ionicViewService; rootScope = $rootScope; window = $window; - window.history.go = function(val) { return val }; + window.history.go = function(val) { return val; }; })); it('should do nothing if the same state happens', inject(function($state) { @@ -375,7 +375,7 @@ describe('Ionic View Service', function() { homeViewScope = {}; $state.go('home'); rootScope.$apply(); - var homeReg = viewService.register(homeViewScope); + homeReg = viewService.register(homeViewScope); expect(rootScope.$viewHistory.histories.root.cursor).toEqual(0); expect(rootScope.$viewHistory.histories.root.stack.length).toEqual(1); expect(homeReg.historyId).toEqual('root'); @@ -472,7 +472,7 @@ describe('Ionic View Service', function() { expect(viewService.getCurrentStateName()).toEqual('tabs.tab1view2'); expect(viewService.getBackView().stateName).toEqual('tabs.tab1view1'); expect(viewService.getForwardView()).toEqual(null); - var lastView = viewService.getCurrentView(); + lastView = viewService.getCurrentView(); expect(lastView.index).toEqual(1); expect(tab1view2ScopeReg.viewId).toEqual(lastView.viewId); expect(tab1view2ScopeReg.navAction).toEqual('newView'); @@ -487,7 +487,7 @@ describe('Ionic View Service', function() { expect(viewService.getCurrentStateName()).toEqual('tabs.tab1view1'); expect(viewService.getBackView().stateName).toEqual('home'); expect(viewService.getForwardView().stateName).toEqual('tabs.tab1view2'); - var lastView = viewService.getCurrentView(); + lastView = viewService.getCurrentView(); expect(lastView.index).toEqual(0); expect(tab1view1Scope2Reg.navAction).toEqual('moveBack'); expect(tab1view1Scope2Reg.navDirection).toEqual('back'); @@ -716,7 +716,7 @@ describe('Ionic View Service', function() { var result = newView.go(); expect(result).toEqual(null); - $location.url('/nochange') + $location.url('/nochange'); newView = viewService.createView({ url: '/nochange' }); result = newView.go(); expect(result).toEqual(null); @@ -746,13 +746,13 @@ describe('Ionic View Service', function() { rootScope.$broadcast("viewState.changeHistory", { url: '/url' }); expect($location.url()).toEqual('/url'); - rootScope.$viewHistory.histories['h123'] = { stack: [], cursor: -1 } + rootScope.$viewHistory.histories.h123 = { stack: [], cursor: -1 }; rootScope.$broadcast("viewState.changeHistory", { historyId: 'h123' }); expect($location.url()).toEqual('/url'); var newView = viewService.createView({ stateName: 'about' }); - rootScope.$viewHistory.histories['h123'].stack.push(newView); - rootScope.$viewHistory.histories['h123'].cursor++; + rootScope.$viewHistory.histories.h123.stack.push(newView); + rootScope.$viewHistory.histories.h123.cursor++; rootScope.$broadcast("viewState.changeHistory", { historyId: 'h123' }); rootScope.$apply(); expect($state.current.name).toEqual('about'); diff --git a/test/unit/utils/keyboard.unit.js b/test/unit/utils/keyboard.unit.js index 9e56bd46ed..fefd316240 100644 --- a/test/unit/utils/keyboard.unit.js +++ b/test/unit/utils/keyboard.unit.js @@ -141,7 +141,7 @@ describe('Ionic Keyboard', function() { expect( ionic.Platform.isFullScreen ).toEqual(false); keyboardViewportHeight = 480; - window.innerHeight = 280 + window.innerHeight = 280; expect( keyboardGetHeight() ).toEqual(200); }); @@ -161,14 +161,14 @@ describe('Ionic Keyboard', function() { ionic.keyboard.landscape = true; expect( keyboardGetHeight() ).toEqual(206); - }) + }); it('keyboardGetHeight() should = 216 if iOS Safari', function(){ ionic.Platform.setPlatform('iOS'); expect( ionic.Platform.isWebView() ).toEqual(false); expect( keyboardGetHeight() ).toEqual(216); - }) + }); it('keyboardGetHeight() should = 260 if iOS Cordova', function(){ ionic.Platform.setPlatform('iOS'); @@ -176,13 +176,13 @@ describe('Ionic Keyboard', function() { expect( ionic.Platform.isWebView() ).toEqual(true); expect( keyboardGetHeight() ).toEqual(260); - }) + }); it('keyboardGetHeight() should = 275 if not Android or iOS', function(){ ionic.Platform.setPlatform('WP8'); expect( keyboardGetHeight() ).toEqual(275); - }) + }); it('keyboardUpdateViewportHeight() should update when window.innerHeight > keyboardViewportHeight', function(){ window.innerHeight = 460; diff --git a/test/unit/utils/tap.unit.js b/test/unit/utils/tap.unit.js index 889f862e14..b5fd1cb5e3 100644 --- a/test/unit/utils/tap.unit.js +++ b/test/unit/utils/tap.unit.js @@ -301,7 +301,7 @@ describe('Ionic Tap', function() { var e = { stopPropagation: function() { this.stoppedPropagation = true; }, preventDefault: function() { this.preventedDefault = true; } - } + }; tapMouseUp(e); expect( e.stoppedPropagation ).toEqual(true); expect( e.preventedDefault ).toEqual(true); @@ -313,7 +313,7 @@ describe('Ionic Tap', function() { target: document.createElement('select'), stopPropagation: function() { this.stoppedPropagation = true; }, preventDefault: function() { this.preventedDefault = true; } - } + }; expect( tapMouseUp(e) ).toEqual(false); expect( e.stoppedPropagation ).toBeUndefined(); expect( e.preventedDefault ).toBeUndefined(); @@ -325,7 +325,7 @@ describe('Ionic Tap', function() { target: document.createElement('button'), stopPropagation: function() { this.stoppedPropagation = true; }, preventDefault: function() { this.preventedDefault = true; } - } + }; tapMouseUp(e); expect( e.stoppedPropagation ).toBeUndefined(); expect( e.preventedDefault ).toBeUndefined(); @@ -783,10 +783,13 @@ describe('Ionic Tap', function() { it('Should not focus on common elements', function() { var tags = ['div', 'span', 'i', 'body', 'section', 'article', 'aside', 'li', 'p', 'header', 'button', 'ion-content']; + function setFocus() { + this.hasFocus = true; + } for(var x=0; x