diff --git a/.travis.yml b/.travis.yml index 5840c2a..1a9431e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,26 @@ language: node_js -node_js: - - 0.10 -before_script: - - 'npm install -g grunt-cli bower && bower install' \ No newline at end of file +sudo: false +cache: + directories: + - node_modules +env: + global: + - SAUCE_USERNAME=ng-flow + - SAUCE_ACCESS_KEY=008c40ec-dbaf-4edc-abad-6c6afcc5d13a +matrix: + fast_finish: true + include: + - env: TEST='unit-tests' + node_js: "4.2" + - env: TEST='browser-tests' + node_js: "4.2" + addons: + sauce_connect: true + allow_failures: + - env: TEST='browser-tests' +before_install: npm install -g grunt-cli bower +install: + - npm install + - bower update +script: + - $TRAVIS_BUILD_DIR/travis.sh diff --git a/Gruntfile.js b/Gruntfile.js index e2b06a3..9351fa0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -34,49 +34,47 @@ module.exports = function(grunt) { } } }, + coveralls: { + options: { + coverageDir: 'coverage/' + } + }, karma: { options: { configFile: 'karma.conf.js' - }, - watch: { - }, continuous: { singleRun: true }, - travis: { + coverage: { singleRun: true, - browsers: ['PhantomJS'], + browsers: ['Firefox'], reporters: ['progress', 'coverage'], preprocessors: { - // source files, that you wanna generate coverage for - // do not include tests or libraries - // (these files will be instrumented by Istanbul) - 'src/**/*.js': ['coverage'] + 'src/**/*.js': 'coverage' }, coverageReporter: { - reporters: [ - { - type: 'lcov', - dir: 'test-results/', - subdir: '.' - } - ] + type: "lcov", + dir: "coverage" } - } - }, - coveralls: { - options: { - force: true }, - main: { - src: 'test-results/lcov.info' - } - }, - david: { - main: { - options: { - update: false + saucelabs: { + singleRun: true, + reporters: ['progress', 'saucelabs'], + preprocessors: { + 'src/**/*.js': 'coverage' + }, + coverageReporter: { + type: "lcov", + dir: "coverage/" + }, + // global config for SauceLabs + sauceLabs: { + testName: 'ng-flow', + username: grunt.option('sauce-username') || process.env.SAUCE_USERNAME, + accessKey: grunt.option('sauce-access-key') || process.env.SAUCE_ACCESS_KEY, + tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER, + startConnect: false } } }, @@ -105,15 +103,18 @@ module.exports = function(grunt) { if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key); } - grunt.registerTask('build', ['concat', 'uglify']); - grunt.registerTask('test', ['karma:continuous']); - grunt.registerTask('travis', ['karma:travis','coveralls:main','david:main']); - grunt.registerTask('watch', ['karma:watch']); + // Default task. + grunt.registerTask('default', ['test']); + // Release tasks + grunt.registerTask('build', ['concat', 'uglify']); grunt.registerTask('release', function(type) { type = type ? type : 'patch'; grunt.task.run('bump-only:' + type); grunt.task.run('clean', 'build'); grunt.task.run('bump-commit'); }); -}; \ No newline at end of file + + // Development + grunt.registerTask('test', ["karma:coverage"]); +}; diff --git a/README.md b/README.md index 9d42be4..b819def 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,8 @@ -[![Build Status](https://travis-ci.org/flowjs/ng-flow.svg)](https://travis-ci.org/flowjs/ng-flow) -[![devDependency Status](https://david-dm.org/flowjs/ng-flow/dev-status.svg)](https://david-dm.org/flowjs/ng-flow#info=devDependencies) -[![Coverage Status](https://coveralls.io/repos/flowjs/ng-flow/badge.svg?branch=master)](https://coveralls.io/r/flowjs/ng-flow?branch=master) +# ng-flow [![Build Status](https://travis-ci.org/flowjs/ng-flow.svg)](https://travis-ci.org/flowjs/ng-flow) [![Coverage Status](https://coveralls.io/repos/flowjs/ng-flow/badge.svg?branch=master)](https://coveralls.io/r/flowjs/ng-flow?branch=master) -What is ng-flow? -============ - -Flow.js extensions for angular.js framework, no 3rd party JS dependencies required! +[![Saucelabs Test Status](https://saucelabs.com/browser-matrix/ng-flow.svg)](https://saucelabs.com/u/ng-flow) -ng-flow extension is based on [Flow.js](https://github.com/flowjs/flow.js) library. +ng-flow is a [Flow.js](https://github.com/flowjs/flow.js) extensions for angular.js framework, no 3rd party JS dependencies required! Demo: http://flowjs.github.io/ng-flow/ diff --git a/karma.conf.js b/karma.conf.js index 1d46ed6..07c80b2 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,70 +1,136 @@ module.exports = function(config) { - config.set({ + // define SL browsers + var customLaunchers = { + sl_ie10: { + base: 'SauceLabs', + browserName: 'internet explorer', + platform: 'Windows 8', + version: '10.0' + }, + sl_ie11: { + base: 'SauceLabs', + browserName: 'internet explorer', + platform: 'Windows 10', + version: '11.0' + }, + sl_edge: { + base: 'SauceLabs', + browserName: 'microsoftedge', + platform: 'Windows 10', + version: '20.10240' + }, + sl_chrome_1: { + base: 'SauceLabs', + browserName: 'chrome', + platform: 'Linux', + version: '26' + }, + sl_chrome_2: { + base: 'SauceLabs', + browserName: 'chrome', + platform: 'Linux', + version: '46' + }, + sl_firefox_1: { + base: 'SauceLabs', + browserName: 'firefox', + platform: 'Linux', + version: '13' + }, + sl_firefox_2: { + base: 'SauceLabs', + browserName: 'firefox', + platform: 'Linux', + version: '42' + }, + sl_android_1: { + base: 'SauceLabs', + browserName: 'android', + platform: 'Linux', + version: '4.4' + }, + sl_android_2: { + base: 'SauceLabs', + browserName: 'android', + platform: 'Linux', + version: '5.1' + }, + sl_iphone_1: { + base: 'SauceLabs', + browserName: 'iPhone', + platform: 'OS X 10.10', + deviceName: 'iPad Simulator', + version: '7.1' + }, + sl_iphone_2: { + base: 'SauceLabs', + browserName: 'iPhone', + platform: 'OS X 10.10', + deviceName: 'iPad Simulator', + deviceOrientation: 'portrait', + version: '9.2' + }, + sl_safari_1: { + base: 'SauceLabs', + browserName: 'safari', + platform: 'OS X 10.8', + version: '6.0' + }, + sl_safari_2: { + base: 'SauceLabs', + browserName: 'safari', + platform: 'OS X 10.11', + version: '9.0' + } + } + config.set({ // base path, that will be used to resolve files and exclude - basePath: '', - + basePath: './', // frameworks to use frameworks: ['jasmine'], - // list of files / patterns to load in the browser files: [ 'bower_components/angular/angular.js', 'bower_components/angular-mocks/angular-mocks.js', 'bower_components/flow.js/dist/flow.js', - 'src/**/*.js', 'test/*.spec.js' ], - // list of files to exclude exclude: [ ], - // test results reporter to use // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' - reporters: ['progress'], - + reporters: ['progress', 'coverage', 'saucelabs'], // web server port port: 9876, - // enable / disable colors in the output (reporters and logs) colors: true, - // level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG logLevel: config.LOG_INFO, - // enable / disable watching file and executing tests whenever any file changes autoWatch: true, - - // Start these browsers, currently available: - // - Chrome - // - ChromeCanary - // - Firefox - // - Opera (has to be installed with `npm install karma-opera-launcher`) - // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`) - // - PhantomJS - // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`) - browsers: ['Chrome'], - - // If browser does not capture in given timeout [ms], kill it captureTimeout: 60000, - // Continuous Integration mode // if true, it capture browsers, run tests and exit - singleRun: false + singleRun: true, + + customLaunchers: customLaunchers, + + browsers: Object.keys(customLaunchers), }); }; diff --git a/package.js b/package.js index dad63fc..8673c9b 100644 --- a/package.js +++ b/package.js @@ -22,5 +22,4 @@ Package.onUse(function(api) { api.use('digimet:flowjs@2.9.0', where); api.addFiles('./dist/ng-flow.js', where); // Files in use - -}); \ No newline at end of file +}); diff --git a/package.json b/package.json index fc3d149..d632ae0 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "2.6.1", "description": "Flow.js html5 file upload extension on angular.js framework", "scripts": { - "test": "grunt travis" + "test": "grunt test" }, "main": "dist/ng-flow.js", "repository": { @@ -26,14 +26,16 @@ "readmeFilename": "README.md", "devDependencies": { "grunt": "~0.4", - "grunt-contrib-uglify": "~0.4", - "grunt-contrib-concat": "~0.3.0", - "grunt-karma": "~0.6.2", - "grunt-coveralls": "~1.0.0", - "grunt-david": "~0.3.0", - "grunt-bump": "0.0.13", - "grunt-contrib-clean": "~0.5.0", - "karma-coverage": "~0.3.1", - "karma-phantomjs-launcher": "~0.1.4" + "grunt-bump": "0.7.0", + "grunt-contrib-clean": "~0.7.0", + "grunt-contrib-concat": "~0.5.1", + "grunt-contrib-uglify": "~0.11", + "grunt-karma": "~0.12.1", + "grunt-karma-coveralls": "^2.5.4", + "karma": "0.13", + "karma-coverage": "0.5.3", + "karma-firefox-launcher": "0.1.7", + "karma-jasmine": "^0.3.6", + "karma-sauce-launcher": "0.3.0" } } diff --git a/test/events.spec.js b/test/events.spec.js index ce43d03..2596332 100644 --- a/test/events.spec.js +++ b/test/events.spec.js @@ -29,8 +29,8 @@ describe('events', function () { })); it('should catch event on element scope', function () { expect(ngFileProgress).toHaveBeenCalled(); - expect(ngFileProgress.callCount).toBe(1); - var args = ngFileProgress.mostRecentCall.args; + expect(ngFileProgress.calls.count()).toBe(1); + var args = ngFileProgress.calls.mostRecent().args; expect(args[1]).toBe(elementScope.$flow); expect(args[2]).toBe('file'); }); @@ -52,18 +52,18 @@ describe('events', function () { uploadStart = jasmine.createSpy('uploadStart'); elementScope.$on('flow::uploadStart', uploadStart); elementScope.$flow.fire('uploadStart'); - expect(uploadStart.callCount).toBe(1); + expect(uploadStart.calls.count()).toBe(1); }); it('should execute scope function', function () { elementScope.$flow.fire('uploadStart'); - expect($rootScope.uploadStart.callCount).toBe(1); + expect($rootScope.uploadStart.calls.count()).toBe(1); }); }); it('should call event', function () { elementScope.$flow.fire('fileProgress', 'file'); expect($rootScope.fileProgress).toHaveBeenCalledWith('file'); - expect($rootScope.fileProgress.callCount).toBe(2); + expect($rootScope.fileProgress.calls.count()).toBe(2); }); describe('nested flow directives', function () { @@ -90,4 +90,4 @@ describe('events', function () { expect($rootScope.fileProgress1).not.toHaveBeenCalled(); }); }); -}); \ No newline at end of file +}); diff --git a/test/init.spec.js b/test/init.spec.js index a065a34..cb551c4 100644 --- a/test/init.spec.js +++ b/test/init.spec.js @@ -52,14 +52,14 @@ describe('init', function() { describe('flow-object', function () { it('should create a new flow object', function () { - spyOn(flowFactory, 'create').andCallThrough(); + spyOn(flowFactory, 'create').and.callThrough(); $compile('
')($rootScope); $rootScope.$digest(); expect(flowFactory.create).toHaveBeenCalled(); }); it('should init with the existing flow object', function () { $rootScope.existingFlow = flowFactory.create(); - spyOn(flowFactory, 'create').andCallThrough(); + spyOn(flowFactory, 'create').and.callThrough(); element = $compile('
')($rootScope); elementScope = element.scope(); $rootScope.$digest(); @@ -75,17 +75,17 @@ describe('init', function() { $rootScope.$digest(); var scopePrototype = Object.getPrototypeOf(elementScope); - spyOn(scopePrototype, '$broadcast').andCallThrough(); + spyOn(scopePrototype, '$broadcast').and.callThrough(); $rootScope.existingFlow.fire('fileProgress', 'file'); - expect(elementScope.$broadcast.callCount).toEqual(2); + expect(elementScope.$broadcast.calls.count()).toEqual(2); elementScope.$destroy(); - scopePrototype.$broadcast.reset(); - $rootScope.existingFlow.fire('fileProgress', 'file'); - expect(elementScope.$broadcast.callCount).toEqual(1); + elementScope.$broadcast.calls.reset(); + $rootScope.existingFlow.fire('fileProgress', 'file'); + expect(elementScope.$broadcast.calls.count()).toEqual(1); }); }); -}); \ No newline at end of file +}); diff --git a/travis.sh b/travis.sh new file mode 100755 index 0000000..d1c3b62 --- /dev/null +++ b/travis.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +if [ $TEST = "unit-tests" ]; then + + echo "Running unit-tests" + export DISPLAY=:99.0 + sh -e /etc/init.d/xvfb start + sleep 1 + grunt karma:coverage + grunt coveralls + +elif [[ $TEST = "browser-tests" ]]; then + + echo "Running browser-tests" + grunt karma:saucelabs + +fi