Commit 50a53289994312567e4cc7ff6411b14b38e9fb13

Authored by ABNER SILVA DE OLIVEIRA
1 parent 69b2897c

adicionado arquivos da aplicação nos testes

karma.conf.js
... ... @@ -23,6 +23,8 @@ function listFiles() {
23 23  
24 24 var patterns = [].concat(wiredep(wiredepOptions).js)
25 25 .concat([
  26 + './src/commons.js',
  27 + './src/noosfero.js',
26 28 './src/noosfero-specs.js'
27 29 ]
28 30 //[
... ... @@ -124,7 +126,8 @@ module.exports = function (config) {
124 126 // It was not possible to do it there because karma doesn't let us now if we are
125 127 // running a single test or not
126 128 configuration.preprocessors = {
127   - 'src/**/*.js': ['sourcemap']
  129 + 'src/**/*.js': ['sourcemap'],
  130 + 'src/**/*.ts': ['sourcemap']
128 131 };
129 132 // 'src/**/*.js': ['sourcemap'],
130 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 8 const tcb = new TestComponentBuilder();
9 9  
10 10  
  11 +let html = '<noosfero-article [article]="ctr.article" [profile]="ctrl.profile"></noosfero-article>';
  12 +
11 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 15 class TestArticleDirective {
14 16 article = { type: 'TinyMceArticle' };
15 17 profile = { name: 'profile-name' };
16   - constructor(){
  18 + constructor() {
17 19 }
18 20 }
19 21  
20 22  
21 23 describe("Article Directive", () => {
22 24 it("receives the article and profile as inputs", done => {
23   - let html = '<noosfero-article [article]="ctr.article" [profile]="ctrl.profile"></noosfero-article>';
24 25 tcb
25   - .overrideTemplate(TestArticleDirective, html)
26 26 .createAsync(TestArticleDirective).then(fixture => {
27 27 let myComponent: ArticleDirective = fixture.componentInstance;
28 28 expect(myComponent.article.type).toEqual("TinyMceArticle");
... ... @@ -32,4 +32,28 @@ describe(&quot;Article Directive&quot;, () =&gt; {
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 60 \ No newline at end of file
... ...
src/app/index.ts
1 1  
  2 +import "core-js/shim";
2 3 import "reflect-metadata";
3 4 import {NoosferoApp} from "./index.module";
4 5 import {noosferoModuleConfig} from "./index.config";
... ...
webpack.config.js
... ... @@ -3,7 +3,8 @@
3 3 var argv = require("yargs").argv;
4 4 var path = require("path");
5 5 var glob = require("glob");
6   -var webpack = require("webpack");
  6 +
  7 +var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
7 8  
8 9 var extension = ".js";
9 10 if (argv.production) {
... ... @@ -27,6 +28,7 @@ var webpackConfig = {
27 28 'noosfero-specs': './src/spec.ts'
28 29 },
29 30  
  31 + plugins: [ new CommonsChunkPlugin("commons.js")],
30 32  
31 33 output: {
32 34 path: path.join(__dirname, "src"),
... ...