diff --git a/ng2-components/ng2-alfresco-core/.gitignore b/ng2-components/ng2-alfresco-core/.gitignore index 8ef2c4d294..999b1bedab 100644 --- a/ng2-components/ng2-alfresco-core/.gitignore +++ b/ng2-components/ng2-alfresco-core/.gitignore @@ -3,4 +3,6 @@ node_modules jspm_packages .idea typings -coverage \ No newline at end of file +coverage +src/*.js +src/*.js.map diff --git a/ng2-components/ng2-alfresco-documentlist/.gitignore b/ng2-components/ng2-alfresco-documentlist/.gitignore index 4f651a9b3c..999b1bedab 100644 --- a/ng2-components/ng2-alfresco-documentlist/.gitignore +++ b/ng2-components/ng2-alfresco-documentlist/.gitignore @@ -4,5 +4,5 @@ jspm_packages .idea typings coverage -*.js -*.js.map +src/*.js +src/*.js.map diff --git a/ng2-components/ng2-alfresco-documentlist/karma.conf.js b/ng2-components/ng2-alfresco-documentlist/karma.conf.js new file mode 100644 index 0000000000..601e0240de --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/karma.conf.js @@ -0,0 +1,127 @@ +// Karma configuration +// Generated on Wed Jul 15 2015 09:44:02 GMT+0200 (Romance Daylight Time) +'use strict'; + +var argv = require('yargs').argv; + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: './', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + 'node_modules/zone.js/dist/zone.js', + 'node_modules/zone.js/dist/long-stack-trace-zone.js', + 'node_modules/zone.js/dist/jasmine-patch.js', + 'node_modules/zone.js/dist/async-test.js', + 'node_modules/zone.js/dist/fake-async-test.js', + 'node_modules/es6-module-loader/dist/es6-module-loader.js', + 'node_modules/traceur/bin/traceur-runtime.js', // Required by PhantomJS2, otherwise it shouts ReferenceError: Can't find variable: require + 'node_modules/traceur/bin/traceur.js', + 'node_modules/systemjs/dist/system.src.js', + 'node_modules/reflect-metadata/Reflect.js', + 'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js', + { pattern: 'node_modules/angular2/**/*.js', included: false, watched: false }, + { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false }, + { pattern: 'dist/**/*.js', included: false, watched: true }, + { pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: false, watched: false }, // PhantomJS2 (and possibly others) might require it + + // suppress annoying 404 warnings for resources, images, etc. + //{ pattern: 'dist/src/assets/**/*', watched: false, included: false, served: true }, + + 'test-main.js' + ], + + // must go along with above, suppress annoying 404 warnings. + proxies: { + '/assets/': '/base/dist/dev/assets/' + }, + + // list of files to exclude + exclude: [ + 'node_modules/angular2/**/*spec.js' + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + 'dist/**/!(*spec).js': ['coverage'] + }, + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['mocha', 'coverage'], + + + // 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 + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: [ + 'PhantomJS', + 'Chrome' + ], + + + customLaunchers: { + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, + + coverageReporter: { + dir: 'coverage/', + reporters: [ + { type: 'text-summary' }, + { type: 'json', subdir: '.', file: 'coverage-final.json' }, + { type: 'html' } + ] + }, + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Passing command line arguments to tests + client: { + files: argv.files + } + }); + + if (process.env.APPVEYOR) { + config.browsers = ['IE']; + config.singleRun = true; + config.browserNoActivityTimeout = 90000; // Note: default value (10000) is not enough + } + + if (process.env.TRAVIS || process.env.CIRCLECI) { + config.browsers = ['Chrome_travis_ci']; + config.singleRun = true; + } +}; diff --git a/ng2-components/ng2-alfresco-documentlist/package.json b/ng2-components/ng2-alfresco-documentlist/package.json index 670b3b68eb..775181a4db 100644 --- a/ng2-components/ng2-alfresco-documentlist/package.json +++ b/ng2-components/ng2-alfresco-documentlist/package.json @@ -68,7 +68,8 @@ "karma-phantomjs-launcher": "^1.0.0", "traceur": "^0.0.91", "remap-istanbul": "^0.6.3", - "phantomjs-prebuilt": "^2.1.7" + "phantomjs-prebuilt": "^2.1.7", + "coveralls": "^2.11.9" }, "license-check-config": { "src": [ diff --git a/ng2-components/ng2-alfresco-documentlist/test-main.js b/ng2-components/ng2-alfresco-documentlist/test-main.js new file mode 100644 index 0000000000..ae2130c1b2 --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/test-main.js @@ -0,0 +1,77 @@ +if (!Object.hasOwnProperty('name')) { + Object.defineProperty(Function.prototype, 'name', { + get: function() { + var matches = this.toString().match(/^\s*function\s*(\S*)\s*\(/); + var name = matches && matches.length > 1 ? matches[1] : ""; + Object.defineProperty(this, 'name', {value: name}); + return name; + } + }); +} + +// Turn on full stack traces in errors to help debugging +Error.stackTraceLimit = Infinity; + +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; + +// Cancel Karma's synchronous start, +// we will call `__karma__.start()` later, once all the specs are loaded. +__karma__.loaded = function() {}; + +System.config({ + baseURL: '/base/', + defaultJSExtensions: true, + paths: { + 'angular2/*': 'node_modules/angular2/*.js', + 'rxjs/*': 'node_modules/rxjs/*.js' + } +}); + +Promise.all([ + System.import('angular2/src/platform/browser/browser_adapter'), + System.import('angular2/platform/testing/browser'), + System.import('angular2/testing') +]).then(function (modules) { + var browser_adapter = modules[0]; + var providers = modules[1]; + var testing = modules[2]; + testing.setBaseTestProviders(providers.TEST_BROWSER_PLATFORM_PROVIDERS, + providers.TEST_BROWSER_APPLICATION_PROVIDERS); + + browser_adapter.BrowserDomAdapter.makeCurrent(); +}).then(function() { + return Promise.all( + Object.keys(window.__karma__.files) // All files served by Karma. + .filter(onlySpecFiles) + .map(file2moduleName) + .map(function(path) { + return System.import(path).then(function(module) { + if (module.hasOwnProperty('main')) { + module.main(); + } else { + throw new Error('Module ' + path + ' does not implement main() method.'); + } + }); + })); + }) + .then(function() { + __karma__.start(); + }, function(error) { + // console.error(error.stack || error); + __karma__.start(); + }); + +function onlySpecFiles(path) { + // check for individual files, if not given, always matches to all + var patternMatched = __karma__.config.files ? + path.match(new RegExp(__karma__.config.files)) : true; + + return patternMatched && /[\.|_]spec\.js$/.test(path); +} + +// Normalize paths to module names. +function file2moduleName(filePath) { + return filePath.replace(/\\/g, '/') + .replace(/^\/base\//, '') + .replace(/\.js$/, ''); +} diff --git a/ng2-components/ng2-alfresco-login/.gitignore b/ng2-components/ng2-alfresco-login/.gitignore index f5aad0cafa..999b1bedab 100644 --- a/ng2-components/ng2-alfresco-login/.gitignore +++ b/ng2-components/ng2-alfresco-login/.gitignore @@ -4,8 +4,5 @@ jspm_packages .idea typings coverage -*.js -*.js.map - -!karma.conf.js -!test-main.js +src/*.js +src/*.js.map diff --git a/ng2-components/ng2-alfresco-login/package.json b/ng2-components/ng2-alfresco-login/package.json index bf61e63599..556d715770 100644 --- a/ng2-components/ng2-alfresco-login/package.json +++ b/ng2-components/ng2-alfresco-login/package.json @@ -74,7 +74,8 @@ "karma-phantomjs-launcher": "^1.0.0", "traceur": "^0.0.91", "remap-istanbul": "^0.6.3", - "phantomjs-prebuilt": "^2.1.7" + "phantomjs-prebuilt": "^2.1.7", + "coveralls": "^2.11.9" }, "license-check-config": { "src": [ diff --git a/ng2-components/ng2-alfresco-upload/.gitignore b/ng2-components/ng2-alfresco-upload/.gitignore index 4f651a9b3c..999b1bedab 100644 --- a/ng2-components/ng2-alfresco-upload/.gitignore +++ b/ng2-components/ng2-alfresco-upload/.gitignore @@ -4,5 +4,5 @@ jspm_packages .idea typings coverage -*.js -*.js.map +src/*.js +src/*.js.map diff --git a/ng2-components/ng2-alfresco-upload/karma.conf.js b/ng2-components/ng2-alfresco-upload/karma.conf.js new file mode 100644 index 0000000000..4fc94d241f --- /dev/null +++ b/ng2-components/ng2-alfresco-upload/karma.conf.js @@ -0,0 +1,128 @@ +// Karma configuration +// Generated on Wed Jul 15 2015 09:44:02 GMT+0200 (Romance Daylight Time) +'use strict'; + +var argv = require('yargs').argv; + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: './', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + 'node_modules/zone.js/dist/zone.js', + 'node_modules/zone.js/dist/long-stack-trace-zone.js', + 'node_modules/zone.js/dist/jasmine-patch.js', + 'node_modules/zone.js/dist/async-test.js', + 'node_modules/zone.js/dist/fake-async-test.js', + 'node_modules/es6-module-loader/dist/es6-module-loader.js', + 'node_modules/traceur/bin/traceur-runtime.js', // Required by PhantomJS2, otherwise it shouts ReferenceError: Can't find variable: require + 'node_modules/traceur/bin/traceur.js', + 'node_modules/systemjs/dist/system.src.js', + 'node_modules/reflect-metadata/Reflect.js', + 'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js', + { pattern: 'node_modules/ng2-translate/**/*.js', included: false, watched: false }, // source files + { pattern: 'node_modules/angular2/**/*.js', included: false, watched: false }, + { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false }, + { pattern: 'dist/**/*.js', included: false, watched: true }, + { pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: false, watched: false }, // PhantomJS2 (and possibly others) might require it + + // suppress annoying 404 warnings for resources, images, etc. + //{ pattern: 'dist/src/assets/**/*', watched: false, included: false, served: true }, + + 'test-main.js' + ], + + // must go along with above, suppress annoying 404 warnings. + proxies: { + '/assets/': '/base/dist/dev/assets/' + }, + + // list of files to exclude + exclude: [ + 'node_modules/angular2/**/*spec.js' + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + 'dist/**/!(*spec).js': ['coverage'] + }, + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['mocha', 'coverage'], + + + // 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 + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: [ + 'PhantomJS', + 'Chrome' + ], + + + customLaunchers: { + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, + + coverageReporter: { + dir: 'coverage/', + reporters: [ + { type: 'text-summary' }, + { type: 'json', subdir: '.', file: 'coverage-final.json' }, + { type: 'html' } + ] + }, + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Passing command line arguments to tests + client: { + files: argv.files + } + }); + + if (process.env.APPVEYOR) { + config.browsers = ['IE']; + config.singleRun = true; + config.browserNoActivityTimeout = 90000; // Note: default value (10000) is not enough + } + + if (process.env.TRAVIS || process.env.CIRCLECI) { + config.browsers = ['Chrome_travis_ci']; + config.singleRun = true; + } +}; diff --git a/ng2-components/ng2-alfresco-upload/package.json b/ng2-components/ng2-alfresco-upload/package.json index 611bb40604..dcd40976d3 100644 --- a/ng2-components/ng2-alfresco-upload/package.json +++ b/ng2-components/ng2-alfresco-upload/package.json @@ -12,8 +12,7 @@ "tsc": "tsc", "tsc:w": "tsc -w", "typings": "typings", - "test": "live-server --open=index.html --entry-file=test/ ", - "test:w": "concurrently \"npm run tsc:w\" \"npm run test\" " + "test": "karma start karma.conf.js" }, "repository": { "type": "git", @@ -41,8 +40,9 @@ "es6-shim": "^0.35.0", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.2", - "zone.js": "0.6.10", - "ng2-translate": "^1.11.2" + "ng2-translate": "^1.11.2", + "zone.js": "^0.6.12", + "es6-module-loader": "^0.17.8" }, "peerDependencies": { "angular2": "2.0.0-beta.15" @@ -56,7 +56,18 @@ "tslint": "^3.8.1", "typescript": "^1.8.10", "typings": "^0.7.12", - "concurrently": "^2.0.0" + "concurrently": "^2.0.0", + "jasmine-spec-reporter": "^2.4.0", + "karma": "~0.13.22", + "karma-chrome-launcher": "~1.0.1", + "karma-coverage": "^1.0.0", + "karma-ie-launcher": "^1.0.0", + "karma-jasmine": "~1.0.2", + "karma-mocha-reporter": "^2.0.3", + "karma-phantomjs-launcher": "^1.0.0", + "traceur": "^0.0.91", + "remap-istanbul": "^0.6.3", + "phantomjs-prebuilt": "^2.1.7" }, "license-check-config": { "src": [ @@ -65,7 +76,8 @@ "!/**/coverage/**/*", "!/**/demo/**/*", "!/**/node_modules/**/*", - "!/**/typings/**/*" + "!/**/typings/**/*", + "!*.js" ], "path": "assets/license_header.txt", "blocking": false, diff --git a/ng2-components/ng2-alfresco-upload/test/assets/translation.service.mock.ts b/ng2-components/ng2-alfresco-upload/src/assets/translation.service.mock.ts similarity index 100% rename from ng2-components/ng2-alfresco-upload/test/assets/translation.service.mock.ts rename to ng2-components/ng2-alfresco-upload/src/assets/translation.service.mock.ts diff --git a/ng2-components/ng2-alfresco-upload/test/components/file-uploading-dialog.component.spec.ts b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.spec.ts similarity index 99% rename from ng2-components/ng2-alfresco-upload/test/components/file-uploading-dialog.component.spec.ts rename to ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.spec.ts index ffe4315c42..f7664a6c56 100644 --- a/ng2-components/ng2-alfresco-upload/test/components/file-uploading-dialog.component.spec.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.spec.ts @@ -36,4 +36,3 @@ describe('FileUploadDialog', () => { }); })); }); - diff --git a/ng2-components/ng2-alfresco-upload/test/components/upload-button.component.spec.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts similarity index 99% rename from ng2-components/ng2-alfresco-upload/test/components/upload-button.component.spec.ts rename to ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts index 8029ba0baf..28ec9d463c 100644 --- a/ng2-components/ng2-alfresco-upload/test/components/upload-button.component.spec.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts @@ -103,4 +103,3 @@ describe('AlfrescoUploadButton', () => { }); })); }); - diff --git a/ng2-components/ng2-alfresco-upload/test/services/upload.service.spec.ts b/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts similarity index 100% rename from ng2-components/ng2-alfresco-upload/test/services/upload.service.spec.ts rename to ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts diff --git a/ng2-components/ng2-alfresco-upload/test-main.js b/ng2-components/ng2-alfresco-upload/test-main.js new file mode 100644 index 0000000000..65ecaefbc0 --- /dev/null +++ b/ng2-components/ng2-alfresco-upload/test-main.js @@ -0,0 +1,78 @@ +if (!Object.hasOwnProperty('name')) { + Object.defineProperty(Function.prototype, 'name', { + get: function() { + var matches = this.toString().match(/^\s*function\s*(\S*)\s*\(/); + var name = matches && matches.length > 1 ? matches[1] : ""; + Object.defineProperty(this, 'name', {value: name}); + return name; + } + }); +} + +// Turn on full stack traces in errors to help debugging +Error.stackTraceLimit = Infinity; + +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; + +// Cancel Karma's synchronous start, +// we will call `__karma__.start()` later, once all the specs are loaded. +__karma__.loaded = function() {}; + +System.config({ + baseURL: '/base/', + defaultJSExtensions: true, + paths: { + 'angular2/*': 'node_modules/angular2/*.js', + 'rxjs/*': 'node_modules/rxjs/*.js', + 'ng2-translate/*':'node_modules/ng2-translate/*.js' + } +}); + +Promise.all([ + System.import('angular2/src/platform/browser/browser_adapter'), + System.import('angular2/platform/testing/browser'), + System.import('angular2/testing') +]).then(function (modules) { + var browser_adapter = modules[0]; + var providers = modules[1]; + var testing = modules[2]; + testing.setBaseTestProviders(providers.TEST_BROWSER_PLATFORM_PROVIDERS, + providers.TEST_BROWSER_APPLICATION_PROVIDERS); + + browser_adapter.BrowserDomAdapter.makeCurrent(); +}).then(function() { + return Promise.all( + Object.keys(window.__karma__.files) // All files served by Karma. + .filter(onlySpecFiles) + .map(file2moduleName) + .map(function(path) { + return System.import(path).then(function(module) { + if (module.hasOwnProperty('main')) { + module.main(); + } else { + throw new Error('Module ' + path + ' does not implement main() method.'); + } + }); + })); + }) + .then(function() { + __karma__.start(); + }, function(error) { + // console.error(error.stack || error); + __karma__.start(); + }); + +function onlySpecFiles(path) { + // check for individual files, if not given, always matches to all + var patternMatched = __karma__.config.files ? + path.match(new RegExp(__karma__.config.files)) : true; + + return patternMatched && /[\.|_]spec\.js$/.test(path); +} + +// Normalize paths to module names. +function file2moduleName(filePath) { + return filePath.replace(/\\/g, '/') + .replace(/^\/base\//, '') + .replace(/\.js$/, ''); +} diff --git a/ng2-components/ng2-alfresco-upload/test/.gitignore b/ng2-components/ng2-alfresco-upload/test/.gitignore deleted file mode 100644 index 75871e6dc2..0000000000 --- a/ng2-components/ng2-alfresco-upload/test/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.js -*.js.map -*.d.ts diff --git a/ng2-components/ng2-alfresco-upload/test/index.html b/ng2-components/ng2-alfresco-upload/test/index.html deleted file mode 100644 index 75c6315b4b..0000000000 --- a/ng2-components/ng2-alfresco-upload/test/index.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - Alfresco Upload component Tests - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/test/tsconfig.json b/ng2-components/ng2-alfresco-upload/test/tsconfig.json deleted file mode 100644 index d24362499a..0000000000 --- a/ng2-components/ng2-alfresco-upload/test/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "system", - "moduleResolution": "node", - "sourceMap": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "removeComments": false, - "noImplicitAny": false, - "declaration": false, - "outDir": "../dist" - }, - "exclude": [ - ] -} diff --git a/ng2-components/ng2-alfresco-upload/tsconfig.json b/ng2-components/ng2-alfresco-upload/tsconfig.json index d1413d432d..862a88325c 100644 --- a/ng2-components/ng2-alfresco-upload/tsconfig.json +++ b/ng2-components/ng2-alfresco-upload/tsconfig.json @@ -21,8 +21,7 @@ "dist", "typings/browser.d.ts", "typings/browser", - "demo", - "src" + "demo" ], "compileOnSave": false }