fix test angular2 Finale release tag component #749

This commit is contained in:
Eugenio Romano
2016-10-04 15:38:30 +01:00
parent 79fc3085c0
commit 4745cb931b
11 changed files with 163 additions and 152 deletions

View File

@@ -54,18 +54,8 @@ var map = {
'ng2-translate': 'npm:ng2-translate', 'ng2-translate': 'npm:ng2-translate',
'alfresco-js-api': 'npm:alfresco-js-api/dist', 'alfresco-js-api': 'npm:alfresco-js-api/dist',
'ng2-activiti-form': 'npm:ng2-activiti-form/dist',
'ng2-activiti-processlist': 'npm:ng2-activiti-processlist/dist',
'ng2-activiti-tasklist': 'npm:ng2-activiti-tasklist/dist',
'ng2-alfresco-core': 'npm:ng2-alfresco-core/dist', 'ng2-alfresco-core': 'npm:ng2-alfresco-core/dist',
'ng2-alfresco-datatable': 'npm:ng2-alfresco-datatable/dist', 'ng2-alfresco-tag': 'npm:ng2-alfresco-tag/dist'
'ng2-alfresco-documentlist': 'npm:ng2-alfresco-documentlist/dist',
'ng2-alfresco-login': 'npm:ng2-alfresco-login/dist',
'ng2-alfresco-search': 'npm:ng2-alfresco-search/dist',
'ng2-alfresco-tag': 'npm:ng2-alfresco-tag/dist',
'ng2-alfresco-upload': 'npm:ng2-alfresco-upload/dist',
'ng2-alfresco-viewer': 'npm:ng2-alfresco-viewer/dist',
'ng2-alfresco-webscript': 'npm:ng2-alfresco-webscript/dist'
}; };
var packages = { var packages = {
@@ -74,18 +64,8 @@ var packages = {
'ng2-translate': { defaultExtension: 'js' }, 'ng2-translate': { defaultExtension: 'js' },
'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'}, 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'},
'ng2-activiti-form': { main: './index.js', defaultExtension: 'js'},
'ng2-activiti-processlist': { main: './index.js', defaultExtension: 'js'},
'ng2-activiti-tasklist': { main: './index.js', defaultExtension: 'js'},
'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'}, 'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'},
'ng2-alfresco-datatable': { main: './index.js', defaultExtension: 'js'}, 'ng2-alfresco-tag': { main: './index.js', defaultExtension: 'js'}
'ng2-alfresco-documentlist': { main: './index.js', defaultExtension: 'js'},
'ng2-alfresco-login': { main: './index.js', defaultExtension: 'js'},
'ng2-alfresco-search': { main: './index.js', defaultExtension: 'js'},
'ng2-alfresco-tag': { main: './index.js', defaultExtension: 'js'},
'ng2-alfresco-upload': { main: './index.js', defaultExtension: 'js'},
'ng2-alfresco-viewer': { main: './index.js', defaultExtension: 'js'},
'ng2-alfresco-webscript': { main: './index.js', defaultExtension: 'js'}
}; };
var config = { var config = {

View File

@@ -44,18 +44,9 @@ module.exports = function (config) {
{pattern: 'dist/**/*.css', included: true, served: true, watched: true}, {pattern: 'dist/**/*.css', included: true, served: true, watched: true},
// ng2-components // ng2-components
{ pattern: 'node_modules/ng2-activiti-form/dist/**/*.js', included: false, served: true, watched: false },
{ pattern: 'node_modules/ng2-activiti-processlist/dist/**/*.js', included: false, served: true, watched: false },
{ pattern: 'node_modules/ng2-activiti-tasklist/dist/**/*.js', included: false, served: true, watched: false },
{ pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false }, { pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false },
{ pattern: 'node_modules/ng2-alfresco-datatable/dist/**/*.js', included: false, served: true, watched: false }, { pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js.map', included: false, served: true, watched: false },
{ pattern: 'node_modules/ng2-alfresco-documentlist/dist/**/*.js', included: false, served: true, watched: false },
{ pattern: 'node_modules/ng2-alfresco-login/dist/**/*.js', included: false, served: true, watched: false },
{ pattern: 'node_modules/ng2-alfresco-search/dist/**/*.js', included: false, served: true, watched: false },
{ pattern: 'node_modules/ng2-alfresco-tag/dist/**/*.js', included: false, served: true, watched: false }, { pattern: 'node_modules/ng2-alfresco-tag/dist/**/*.js', included: false, served: true, watched: false },
{ pattern: 'node_modules/ng2-alfresco-upload/dist/**/*.js', included: false, served: true, watched: false },
{ pattern: 'node_modules/ng2-alfresco-viewer/dist/**/*.js', included: false, served: true, watched: false },
{ pattern: 'node_modules/ng2-alfresco-webscript/dist/**/*.js', included: false, served: true, watched: false },
// paths to support debugging with source maps in dev tools // paths to support debugging with source maps in dev tools
{pattern: 'src/**/*.ts', included: false, watched: false}, {pattern: 'src/**/*.ts', included: false, watched: false},

View File

@@ -40,15 +40,15 @@
"@angular/platform-browser-dynamic": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0", "@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0", "@angular/upgrade": "2.0.0",
"@types/node": "^6.0.42",
"alfresco-js-api": "^0.3.0",
"core-js": "^2.4.1", "core-js": "^2.4.1",
"ng2-alfresco-core": "0.3.2",
"ng2-translate": "2.5.0",
"reflect-metadata": "^0.1.3", "reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12", "rxjs": "5.0.0-beta.12",
"systemjs": "0.19.27", "systemjs": "0.19.27",
"zone.js": "^0.6.23", "zone.js": "^0.6.23"
"alfresco-js-api": "^0.3.0",
"ng2-translate": "2.5.0",
"ng2-alfresco-core": "0.3.2"
}, },
"devDependencies": { "devDependencies": {
"@types/core-js": "^0.9.32", "@types/core-js": "^0.9.32",

View File

@@ -15,18 +15,50 @@
* limitations under the License. * limitations under the License.
*/ */
/* import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { it, describe, inject, beforeEachProviders, beforeEach, afterEach } from '@angular/core/testing'; import { TagActionsComponent } from '../components/tag-actions.component';
import { TestComponentBuilder } from '@angular/compiler/testing'; import { DebugElement } from '@angular/core';
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core'; import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService,
CoreModule
} from 'ng2-alfresco-core';
import { TagService } from '../services/tag.service'; import { TagService } from '../services/tag.service';
import { TagActionsComponent } from './tag-actions.component';
declare let jasmine: any; declare let jasmine: any;
describe('Tag actions list', () => { describe('Test ng2-alfresco-tag Tag actions list', () => {
let tagActionsListFixture, element, component; let component: any;
let fixture: ComponentFixture<TagActionsComponent>;
let debug: DebugElement;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule
],
declarations: [TagActionsComponent],
providers: [
AlfrescoSettingsService,
AlfrescoAuthenticationService,
AlfrescoApiService,
TagService
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TagActionsComponent);
component = fixture.componentInstance;
debug = fixture.debugElement;
element = fixture.nativeElement;
component = fixture.componentInstance;
fixture.detectChanges();
});
let dataTag = { let dataTag = {
'list': { 'list': {
@@ -45,25 +77,6 @@ describe('Tag actions list', () => {
} }
}; };
beforeEachProviders(() => {
return [
AlfrescoSettingsService,
AlfrescoAuthenticationService,
AlfrescoApiService,
TagService
];
});
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb
.createAsync(TagActionsComponent)
.then(fixture => {
tagActionsListFixture = fixture;
element = tagActionsListFixture.nativeElement;
component = tagActionsListFixture.componentInstance;
});
}));
describe('Rendering tests', () => { describe('Rendering tests', () => {
beforeEach(() => { beforeEach(() => {
@@ -78,7 +91,7 @@ describe('Tag actions list', () => {
component.nodeId = 'fake-node-id'; component.nodeId = 'fake-node-id';
component.resultsEmitter.subscribe(() => { component.resultsEmitter.subscribe(() => {
tagActionsListFixture.detectChanges(); fixture.detectChanges();
expect(element.querySelector('#tag_name_0').innerHTML).toBe('test1'); expect(element.querySelector('#tag_name_0').innerHTML).toBe('test1');
expect(element.querySelector('#tag_name_1').innerHTML).toBe('test2'); expect(element.querySelector('#tag_name_1').innerHTML).toBe('test2');
@@ -104,12 +117,15 @@ describe('Tag actions list', () => {
component.nodeId = 'fake-node-id'; component.nodeId = 'fake-node-id';
component.resultsEmitter.subscribe(() => { component.resultsEmitter.subscribe(() => {
tagActionsListFixture.detectChanges(); fixture.detectChanges();
element.querySelector('#tag_delete_0').click();
tagActionsListFixture.detectChanges();
expect(jasmine.Ajax.requests.at(1).url). let deleteButton: any = element.querySelector('#tag_delete_0');
toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2'); deleteButton.click();
fixture.detectChanges();
expect(jasmine.Ajax.requests.at(1).url)
.toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2');
expect(jasmine.Ajax.requests.at(1).method).toBe('DELETE'); expect(jasmine.Ajax.requests.at(1).method).toBe('DELETE');
done(); done();
}); });
@@ -127,13 +143,14 @@ describe('Tag actions list', () => {
component.nodeId = 'fake-node-id'; component.nodeId = 'fake-node-id';
component.newTagName = 'fake-tag-name'; component.newTagName = 'fake-tag-name';
tagActionsListFixture.detectChanges(); fixture.detectChanges();
component.addEmitter.subscribe(() => { component.addEmitter.subscribe(() => {
done(); done();
}); });
element.querySelector('#add-tag').click(); let addButton: any = element.querySelector('#add-tag');
addButton.click();
jasmine.Ajax.requests.mostRecent().respondWith({ jasmine.Ajax.requests.mostRecent().respondWith({
status: 200 status: 200
@@ -141,4 +158,4 @@ describe('Tag actions list', () => {
}); });
}); });
}); });
*/

View File

@@ -25,10 +25,9 @@ import { TagService } from '../services/tag.service';
* *
* @returns {TagComponent} . * @returns {TagComponent} .
*/ */
declare let __moduleName: string;
@Component({ @Component({
moduleId: __moduleName, moduleId: module.id,
selector: 'alfresco-tag-node-actions-list', selector: 'alfresco-tag-node-actions-list',
templateUrl: './tag-actions.component.html', templateUrl: './tag-actions.component.html',
styleUrls: ['./tag-actions.component.css'] styleUrls: ['./tag-actions.component.css']

View File

@@ -15,24 +15,21 @@
* limitations under the License. * limitations under the License.
*/ */
describe('TagList', () => {
it('should be upgraded', () => {
expect(true).toBe(true);
});
});
/* import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { it, describe, inject, beforeEachProviders, beforeEach, afterEach } from '@angular/core/testing'; import { TagList } from '../components/tag-list.component';
import { TestComponentBuilder } from '@angular/compiler/testing'; import { DebugElement } from '@angular/core';
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core'; import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService,
CoreModule
} from 'ng2-alfresco-core';
import { TagService } from '../services/tag.service'; import { TagService } from '../services/tag.service';
import { TagList } from './tag-list.component';
declare let jasmine: any; declare let jasmine: any;
describe('Tag list All ECM', () => { describe('Test ng2-alfresco-tag Tag list All ECM', () => {
let tagListFixture, element, component;
let dataTag = { let dataTag = {
'list': { 'list': {
@@ -50,24 +47,36 @@ describe('Tag list All ECM', () => {
} }
}; };
beforeEachProviders(() => { let component: any;
return [ let fixture: ComponentFixture<TagList>;
let debug: DebugElement;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule
],
declarations: [TagList],
providers: [
AlfrescoSettingsService, AlfrescoSettingsService,
AlfrescoAuthenticationService, AlfrescoAuthenticationService,
AlfrescoApiService, AlfrescoApiService,
TagService TagService
]; ]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TagList);
component = fixture.componentInstance;
debug = fixture.debugElement;
element = fixture.nativeElement;
component = fixture.componentInstance;
fixture.detectChanges();
}); });
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb
.createAsync(TagList)
.then(fixture => {
tagListFixture = fixture;
element = tagListFixture.nativeElement;
component = tagListFixture.componentInstance;
});
}));
describe('Rendering tests', () => { describe('Rendering tests', () => {
@@ -83,7 +92,7 @@ describe('Tag list All ECM', () => {
component.nodeId = 'fake-node-id'; component.nodeId = 'fake-node-id';
component.resultsEmitter.subscribe(() => { component.resultsEmitter.subscribe(() => {
tagListFixture.detectChanges(); fixture.detectChanges();
expect(element.querySelector('#tag_name_0').innerHTML).toBe('test1'); expect(element.querySelector('#tag_name_0').innerHTML).toBe('test1');
expect(element.querySelector('#tag_name_1').innerHTML).toBe('test2'); expect(element.querySelector('#tag_name_1').innerHTML).toBe('test2');
@@ -102,4 +111,3 @@ describe('Tag list All ECM', () => {
}); });
}); });
}); });
*/

View File

@@ -25,10 +25,9 @@ import { TagService } from '../services/tag.service';
* *
* @returns {TagList} . * @returns {TagList} .
*/ */
declare let __moduleName: string;
@Component({ @Component({
moduleId: __moduleName, moduleId: module.id,
selector: 'alfresco-tag-list', selector: 'alfresco-tag-list',
templateUrl: './tag-list.component.html' templateUrl: './tag-list.component.html'
}) })

View File

@@ -15,18 +15,21 @@
* limitations under the License. * limitations under the License.
*/ */
/* import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { it, describe, inject, beforeEachProviders, beforeEach, afterEach } from '@angular/core/testing'; import { TagNodeList } from '../components/tag-node-list.component';
import { TestComponentBuilder } from '@angular/compiler/testing'; import { DebugElement } from '@angular/core';
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core'; import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService,
CoreModule
} from 'ng2-alfresco-core';
import { TagService } from '../services/tag.service'; import { TagService } from '../services/tag.service';
import { TagNodeList } from './tag-node-list.component';
declare let jasmine: any; declare let jasmine: any;
describe('Tag relative node list', () => { describe('Tag relative node list', () => {
let tagNodeListFixture, element, component;
let dataTag = { let dataTag = {
'list': { 'list': {
@@ -44,25 +47,36 @@ describe('Tag relative node list', () => {
} }
}; };
beforeEachProviders(() => { let component: any;
return [ let fixture: ComponentFixture<TagNodeList>;
let debug: DebugElement;
let element: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule
],
declarations: [TagNodeList],
providers: [
AlfrescoSettingsService, AlfrescoSettingsService,
AlfrescoAuthenticationService, AlfrescoAuthenticationService,
AlfrescoApiService, AlfrescoApiService,
TagService TagService
]; ]
}); }).compileComponents();
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb
.createAsync(TagNodeList)
.then(fixture => {
tagNodeListFixture = fixture;
element = tagNodeListFixture.nativeElement;
component = tagNodeListFixture.componentInstance;
});
})); }));
beforeEach(() => {
fixture = TestBed.createComponent(TagNodeList);
component = fixture.componentInstance;
debug = fixture.debugElement;
element = fixture.nativeElement;
component = fixture.componentInstance;
fixture.detectChanges();
});
describe('Rendering tests', () => { describe('Rendering tests', () => {
beforeEach(() => { beforeEach(() => {
@@ -77,7 +91,7 @@ describe('Tag relative node list', () => {
component.nodeId = 'fake-node-id'; component.nodeId = 'fake-node-id';
component.resultsEmitter.subscribe(() => { component.resultsEmitter.subscribe(() => {
tagNodeListFixture.detectChanges(); fixture.detectChanges();
expect(element.querySelector('#tag_name_0').innerHTML).toBe('test1'); expect(element.querySelector('#tag_name_0').innerHTML).toBe('test1');
expect(element.querySelector('#tag_name_1').innerHTML).toBe('test2'); expect(element.querySelector('#tag_name_1').innerHTML).toBe('test2');
@@ -103,8 +117,10 @@ describe('Tag relative node list', () => {
component.nodeId = 'fake-node-id'; component.nodeId = 'fake-node-id';
component.resultsEmitter.subscribe(() => { component.resultsEmitter.subscribe(() => {
tagNodeListFixture.detectChanges(); fixture.detectChanges();
element.querySelector('#tag_delete_0').click();
let deleteButton: any = element.querySelector('#tag_delete_0');
deleteButton.click();
expect(jasmine.Ajax.requests.mostRecent().url). expect(jasmine.Ajax.requests.mostRecent().url).
toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2'); toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2');
@@ -122,4 +138,4 @@ describe('Tag relative node list', () => {
}); });
}); });
}); });
*/

View File

@@ -25,10 +25,9 @@ import { TagService } from '../services/tag.service';
* *
* @returns {TagNodeList} . * @returns {TagNodeList} .
*/ */
declare let __moduleName: string;
@Component({ @Component({
moduleId: __moduleName, moduleId: module.id,
selector: 'alfresco-tag-node-list', selector: 'alfresco-tag-node-list',
templateUrl: './tag-node-list.component.html', templateUrl: './tag-node-list.component.html',
styleUrls: ['./tag-node-list.component.css'] styleUrls: ['./tag-node-list.component.css']

View File

@@ -15,30 +15,32 @@
* limitations under the License. * limitations under the License.
*/ */
/* import { ReflectiveInjector } from '@angular/core';
import { describe, expect, it, inject, beforeEachProviders, beforeEach, afterEach } from '@angular/core/testing'; import {
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core'; AlfrescoAuthenticationService,
import { TagService } from './tag.service'; AlfrescoSettingsService,
AlfrescoApiService
} from 'ng2-alfresco-core';
import { TagService } from '../services/tag.service';
declare let jasmine: any; declare let jasmine: any;
describe('Tag service', () => { describe('Tag service', () => {
let service; let service, injector;
beforeEachProviders(() => { beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([
return [
AlfrescoSettingsService, AlfrescoSettingsService,
AlfrescoAuthenticationService,
AlfrescoApiService, AlfrescoApiService,
AlfrescoAuthenticationService,
TagService TagService
]; ]);
}); });
beforeEach(inject([TagService], (tagService: TagService) => { beforeEach(() => {
service = tagService; service = injector.get(TagService);
})); });
describe('Content tests', () => { describe('Content tests', () => {
@@ -114,4 +116,4 @@ describe('Tag service', () => {
}); });
}); });
}); });
*/

View File

@@ -1,7 +1,7 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"module": "system", "module": "commonjs",
"moduleResolution": "node", "moduleResolution": "node",
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
@@ -16,7 +16,7 @@
"noImplicitUseStrict": false, "noImplicitUseStrict": false,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"outDir": "dist", "outDir": "dist",
"types": ["core-js", "jasmine"] "types": ["core-js", "jasmine", "node"]
}, },
"exclude": [ "exclude": [
"demo", "demo",