Commit 4dc814d90a38bdc7440f30c5f2b1d499b1ef44e2

Authored by Ábner Oliveira
1 parent 79e99040

ajustes nos testes

@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 var path = require('path'); 4 var path = require('path');
5 var conf = require('./gulp/conf'); 5 var conf = require('./gulp/conf');
6 6
  7 +
7 var _ = require('lodash'); 8 var _ = require('lodash');
8 var wiredep = require('wiredep'); 9 var wiredep = require('wiredep');
9 10
@@ -17,10 +18,11 @@ function listFiles() { @@ -17,10 +18,11 @@ function listFiles() {
17 devDependencies: true 18 devDependencies: true
18 }); 19 });
19 20
20 - var patterns = wiredep(wiredepOptions).js 21 + var patterns = [].concat(wiredep(wiredepOptions).js)
21 .concat([ 22 .concat([
22 - path.join(conf.paths.src, 'noosfero.js')  
23 - ,path.join(conf.paths.src, 'noosfero-testing.js'), 23 + //path.join(conf.paths.src, 'common.js'),
  24 + //, path.join(conf.paths.src, 'index.ts')
  25 + path.join(conf.paths.src, 'test.js')
24 // path.join(conf.paths.src, '/app/**/*.module.js'), 26 // path.join(conf.paths.src, '/app/**/*.module.js'),
25 // path.join(conf.paths.src, '/app/**/*.js'), 27 // path.join(conf.paths.src, '/app/**/*.js'),
26 // path.join(conf.paths.src, '/**/*.spec.js'), 28 // path.join(conf.paths.src, '/**/*.spec.js'),
@@ -41,7 +43,7 @@ function listFiles() { @@ -41,7 +43,7 @@ function listFiles() {
41 watched: false 43 watched: false
42 }); 44 });
43 files.push({ 45 files.push({
44 - pattern: path.join(conf.paths.src, '/*.map'), 46 + pattern: path.join(conf.paths.src, '/test.js.map'),
45 included: false, 47 included: false,
46 served: true 48 served: true
47 }); 49 });
@@ -68,61 +70,34 @@ module.exports = function (config) { @@ -68,61 +70,34 @@ module.exports = function (config) {
68 }, 70 },
69 71
70 72
71 - frameworks: ['jasmine'],//, 'angular-filesort'], 73 + frameworks: ['jasmine', 'phantomjs-shim'],//, 'angular-filesort'],
72 74
73 angularFilesort: { 75 angularFilesort: {
74 whitelist: [path.join(conf.paths.src, '/**/!(*.html|*.spec|*.mock).js')] 76 whitelist: [path.join(conf.paths.src, '/**/!(*.html|*.spec|*.mock).js')]
75 }, 77 },
76 78
77 - browsers: ['Chrome'],  
78 -  
79 - webpack: _.merge({}, webpackConfig, {  
80 - externals: {  
81 - encapsulatedWindow: 'Object.create(window)'  
82 -  
83 - },  
84 - resolve: {  
85 - alias : {  
86 - angular: "angular/angular.js"  
87 - }  
88 - },  
89 - module: {  
90 - loaders: [  
91 - {  
92 - test: /angular\.js$/,  
93 - loaders:[  
94 - 'imports?window=encapsulatedWindow',  
95 - 'exports?window.angular'  
96 - ],  
97 - include: [new RegExp(__dirname + '/bower_components/angular/')]  
98 - }  
99 - ],  
100 - postLoaders: [  
101 - {  
102 - test: /src\/noosfero.js/,  
103 - exclude: [  
104 - /node_modules\//,  
105 - /bower_components\//,  
106 - /src\/noosfero-testing.js/  
107 - ],  
108 - loader: 'istanbul-instrumenter'  
109 - }  
110 -  
111 -  
112 - ]  
113 - } 79 + browsers: ['PhantomJS'],
  80 +
  81 + webpack2: _.merge({
  82 +
  83 + }, webpackConfig, {
  84 + /*devtool: 'cheap-module-source-map'*/
114 }), 85 }),
115 webpackServer: { 86 webpackServer: {
116 quite: true 87 quite: true
117 }, 88 },
118 plugins: [ 89 plugins: [
  90 + require('karma-webpack'),
119 'karma-chrome-launcher', 91 'karma-chrome-launcher',
120 'karma-phantomjs-launcher', 92 'karma-phantomjs-launcher',
121 'karma-angular-filesort', 93 'karma-angular-filesort',
122 'karma-webpack', 94 'karma-webpack',
  95 + 'karma-phantomjs-shim',
123 'karma-coverage', 96 'karma-coverage',
124 'karma-jasmine', 97 'karma-jasmine',
125 - 'karma-ng-html2js-preprocessor' 98 + 'karma-spec-reporter',
  99 + 'karma-ng-html2js-preprocessor',
  100 + 'karma-sourcemap-loader'
126 ], 101 ],
127 102
128 coverageReporter: { 103 coverageReporter: {
@@ -130,7 +105,7 @@ module.exports = function (config) { @@ -130,7 +105,7 @@ module.exports = function (config) {
130 dir: 'coverage/' 105 dir: 'coverage/'
131 }, 106 },
132 107
133 - reporters: ['dots', "coverage"], 108 + reporters: ['spec', "coverage"],
134 109
135 proxies: { 110 proxies: {
136 '/assets/': path.join('/base/', conf.paths.src, '/assets/') 111 '/assets/': path.join('/base/', conf.paths.src, '/assets/')
@@ -141,9 +116,11 @@ module.exports = function (config) { @@ -141,9 +116,11 @@ module.exports = function (config) {
141 // The coverage preprocessor is added in gulp/unit-test.js only for single tests 116 // The coverage preprocessor is added in gulp/unit-test.js only for single tests
142 // It was not possible to do it there because karma doesn't let us now if we are 117 // It was not possible to do it there because karma doesn't let us now if we are
143 // running a single test or not 118 // running a single test or not
144 - configuration.preprocessors = {  
145 - 'src/**/*.[sS]pec.ts': ['webpack']  
146 - }; 119 + configuration.preprocessors = {}
  120 + // 'src/**/*.ts': ['sourcemap'],
  121 + // 'src/**/*.js': ['sourcemap'],
  122 + // 'src/**/*.[sS]pec.ts': ['sourcemap']
  123 + // };
147 124
148 pathSrcHtml.forEach(function (path) { 125 pathSrcHtml.forEach(function (path) {
149 configuration.preprocessors[path] = ['ng-html2js']; 126 configuration.preprocessors[path] = ['ng-html2js'];
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 "browser-sync-spa": "~1.0.3", 16 "browser-sync-spa": "~1.0.3",
17 "chalk": "~1.1.1", 17 "chalk": "~1.1.1",
18 "concurrently": "^2.0.0", 18 "concurrently": "^2.0.0",
  19 + "core-js": "^2.1.3",
19 "del": "~2.0.2", 20 "del": "~2.0.2",
20 "eslint-plugin-angular": "~0.12.0", 21 "eslint-plugin-angular": "~0.12.0",
21 "estraverse": "~4.1.0", 22 "estraverse": "~4.1.0",
@@ -52,11 +53,15 @@ @@ -52,11 +53,15 @@
52 "karma-jasmine": "~0.3.6", 53 "karma-jasmine": "~0.3.6",
53 "karma-ng-html2js-preprocessor": "~0.2.0", 54 "karma-ng-html2js-preprocessor": "~0.2.0",
54 "karma-phantomjs-launcher": "~0.2.1", 55 "karma-phantomjs-launcher": "~0.2.1",
  56 + "karma-phantomjs-shim": "^1.2.0",
  57 + "karma-sourcemap-loader": "^0.3.7",
  58 + "karma-spec-reporter": "0.0.24",
55 "karma-webpack": "^1.7.0", 59 "karma-webpack": "^1.7.0",
56 "lodash": "~3.10.1", 60 "lodash": "~3.10.1",
57 "main-bower-files": "~2.9.0", 61 "main-bower-files": "~2.9.0",
58 "ng-forward": "0.0.1-alpha.12", 62 "ng-forward": "0.0.1-alpha.12",
59 "phantomjs": "~1.9.18", 63 "phantomjs": "~1.9.18",
  64 + "phantomjs-polyfill": "0.0.2",
60 "reflect-metadata": "^0.1.3", 65 "reflect-metadata": "^0.1.3",
61 "ts-loader": "^0.8.1", 66 "ts-loader": "^0.8.1",
62 "typescript": "^1.8.2", 67 "typescript": "^1.8.2",
src/app/components/noosfero-articles/article/article.directive.spec.ts
1 -let oldDefine = Object.defineProperties;  
2 -  
3 -Object.defineProperties = function(object, properties){  
4 - let filteredProps = {};  
5 - let currentProperties = Object.getOwnPropertyNames(object);  
6 - for (let i = 0; i < currentProperties.length; i++) {  
7 - let prop = currentProperties[i];  
8 - if(currentProperties.indexOf(prop) < 0){  
9 - filteredProps[prop] = properties[prop];  
10 - }  
11 - }  
12 - oldDefine(object, <any>filteredProps);  
13 -}; 1 +// let oldDefine = Object.defineProperties;
  2 +//
  3 +// Object.defineProperties = function(object, properties){
  4 +// let filteredProps = {};
  5 +// let currentProperties = Object.getOwnPropertyNames(object);
  6 +// for (let i = 0; i < currentProperties.length; i++) {
  7 +// let prop = currentProperties[i];
  8 +// if(currentProperties.indexOf(prop) < 0){
  9 +// filteredProps[prop] = properties[prop];
  10 +// }
  11 +// }
  12 +// oldDefine(object, <any>filteredProps);
  13 +// };
14 14
15 import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; 15 import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder';
16 import {Input, provide, Component} from 'ng-forward'; 16 import {Input, provide, Component} from 'ng-forward';
webpack.config.js
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 var argv = require("yargs").argv; 3 var argv = require("yargs").argv;
4 var path = require("path"); 4 var path = require("path");
5 var glob = require("glob"); 5 var glob = require("glob");
6 - 6 +var webpack = require("webpack");
7 7
8 var extension = ".js"; 8 var extension = ".js";
9 if (argv.production) { 9 if (argv.production) {
@@ -22,7 +22,7 @@ var testingFiles = glob.sync(&quot;./src/app/**/*.[sS]pec.ts&quot;); @@ -22,7 +22,7 @@ var testingFiles = glob.sync(&quot;./src/app/**/*.[sS]pec.ts&quot;);
22 var webpackConfig = { 22 var webpackConfig = {
23 entry: { 23 entry: {
24 noosfero: './src/app/index.ts', 24 noosfero: './src/app/index.ts',
25 - 'noosfero-testing': testingFiles 25 + 'test': './src/test.ts'
26 }, 26 },
27 27
28 28
@@ -30,6 +30,9 @@ var webpackConfig = { @@ -30,6 +30,9 @@ var webpackConfig = {
30 path: path.join(__dirname, "src"), 30 path: path.join(__dirname, "src"),
31 filename: "[name]" + extension, 31 filename: "[name]" + extension,
32 }, 32 },
  33 +
  34 + /*plugins: [ new webpack.optimize.CommonsChunkPlugin("common.js") ],*/
  35 +
33 resolve: { 36 resolve: {
34 // Add `.ts` and `.tsx` as a resolvable extension. 37 // Add `.ts` and `.tsx` as a resolvable extension.
35 extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js'] 38 extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']