Commit 50a53289994312567e4cc7ff6411b14b38e9fb13
1 parent
69b2897c
Exists in
master
and in
35 other branches
adicionado arquivos da aplicação nos testes
Showing
4 changed files
with
36 additions
and
6 deletions
Show diff stats
karma.conf.js
@@ -23,6 +23,8 @@ function listFiles() { | @@ -23,6 +23,8 @@ function listFiles() { | ||
23 | 23 | ||
24 | var patterns = [].concat(wiredep(wiredepOptions).js) | 24 | var patterns = [].concat(wiredep(wiredepOptions).js) |
25 | .concat([ | 25 | .concat([ |
26 | + './src/commons.js', | ||
27 | + './src/noosfero.js', | ||
26 | './src/noosfero-specs.js' | 28 | './src/noosfero-specs.js' |
27 | ] | 29 | ] |
28 | //[ | 30 | //[ |
@@ -124,7 +126,8 @@ module.exports = function (config) { | @@ -124,7 +126,8 @@ module.exports = function (config) { | ||
124 | // It was not possible to do it there because karma doesn't let us now if we are | 126 | // It was not possible to do it there because karma doesn't let us now if we are |
125 | // running a single test or not | 127 | // running a single test or not |
126 | configuration.preprocessors = { | 128 | configuration.preprocessors = { |
127 | - 'src/**/*.js': ['sourcemap'] | 129 | + 'src/**/*.js': ['sourcemap'], |
130 | + 'src/**/*.ts': ['sourcemap'] | ||
128 | }; | 131 | }; |
129 | // 'src/**/*.js': ['sourcemap'], | 132 | // 'src/**/*.js': ['sourcemap'], |
130 | // 'src/**/*.[sS]pec.ts': ['sourcemap'] | 133 | // 'src/**/*.[sS]pec.ts': ['sourcemap'] |
src/app/components/noosfero-articles/article/article.directive.spec.ts
@@ -8,21 +8,21 @@ import {ArticleDirective} from './article.directive'; | @@ -8,21 +8,21 @@ import {ArticleDirective} from './article.directive'; | ||
8 | const tcb = new TestComponentBuilder(); | 8 | const tcb = new TestComponentBuilder(); |
9 | 9 | ||
10 | 10 | ||
11 | +let html = '<noosfero-article [article]="ctr.article" [profile]="ctrl.profile"></noosfero-article>'; | ||
12 | + | ||
11 | // Create a component to include your testing component | 13 | // Create a component to include your testing component |
12 | -@Component({ selector: 'my-test' , template: '<hr />'}) | 14 | +@Component({ selector: 'my-test', template: html, directives: [ArticleDirective] }) |
13 | class TestArticleDirective { | 15 | class TestArticleDirective { |
14 | article = { type: 'TinyMceArticle' }; | 16 | article = { type: 'TinyMceArticle' }; |
15 | profile = { name: 'profile-name' }; | 17 | profile = { name: 'profile-name' }; |
16 | - constructor(){ | 18 | + constructor() { |
17 | } | 19 | } |
18 | } | 20 | } |
19 | 21 | ||
20 | 22 | ||
21 | describe("Article Directive", () => { | 23 | describe("Article Directive", () => { |
22 | it("receives the article and profile as inputs", done => { | 24 | it("receives the article and profile as inputs", done => { |
23 | - let html = '<noosfero-article [article]="ctr.article" [profile]="ctrl.profile"></noosfero-article>'; | ||
24 | tcb | 25 | tcb |
25 | - .overrideTemplate(TestArticleDirective, html) | ||
26 | .createAsync(TestArticleDirective).then(fixture => { | 26 | .createAsync(TestArticleDirective).then(fixture => { |
27 | let myComponent: ArticleDirective = fixture.componentInstance; | 27 | let myComponent: ArticleDirective = fixture.componentInstance; |
28 | expect(myComponent.article.type).toEqual("TinyMceArticle"); | 28 | expect(myComponent.article.type).toEqual("TinyMceArticle"); |
@@ -32,4 +32,28 @@ describe("Article Directive", () => { | @@ -32,4 +32,28 @@ describe("Article Directive", () => { | ||
32 | }); | 32 | }); |
33 | }); | 33 | }); |
34 | 34 | ||
35 | + it("renders a directive corresponding to the article type", done => { | ||
36 | + | ||
37 | + @Component({ selector: 'noosfero-TinyMceArticle', template: "<h1>custom component</h1>" }) | ||
38 | + class CustomArticleComponent { | ||
39 | + | ||
40 | + } | ||
41 | + | ||
42 | + @Component({ selector: 'custom-article-type-test', template: html, directives: [ArticleDirective, CustomArticleComponent] }) | ||
43 | + class CustomArticleType { | ||
44 | + article = { type: 'TinyMceArticle' }; | ||
45 | + profile = { name: 'profile-name' }; | ||
46 | + constructor() { | ||
47 | + } | ||
48 | + } | ||
49 | + tcb | ||
50 | + .createAsync(CustomArticleType).then(fixture => { | ||
51 | + let myComponent: CustomArticleType = fixture.componentInstance; | ||
52 | + expect(myComponent.article.type).toEqual("TinyMceArticle"); | ||
53 | + expect(myComponent.profile.name).toEqual("profile-name"); | ||
54 | + console.log(fixture.debugElement); | ||
55 | + done(); | ||
56 | + }); | ||
57 | + }); | ||
58 | + | ||
35 | }); | 59 | }); |
36 | \ No newline at end of file | 60 | \ No newline at end of file |
src/app/index.ts
webpack.config.js
@@ -3,7 +3,8 @@ | @@ -3,7 +3,8 @@ | ||
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 | -var webpack = require("webpack"); | 6 | + |
7 | +var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"); | ||
7 | 8 | ||
8 | var extension = ".js"; | 9 | var extension = ".js"; |
9 | if (argv.production) { | 10 | if (argv.production) { |
@@ -27,6 +28,7 @@ var webpackConfig = { | @@ -27,6 +28,7 @@ var webpackConfig = { | ||
27 | 'noosfero-specs': './src/spec.ts' | 28 | 'noosfero-specs': './src/spec.ts' |
28 | }, | 29 | }, |
29 | 30 | ||
31 | + plugins: [ new CommonsChunkPlugin("commons.js")], | ||
30 | 32 | ||
31 | output: { | 33 | output: { |
32 | path: path.join(__dirname, "src"), | 34 | path: path.join(__dirname, "src"), |