diff --git a/ng2-components/ng2-alfresco-webscript/karma-test-shim.js b/ng2-components/ng2-alfresco-webscript/karma-test-shim.js index 9662cebf0a..4ce01e2d4c 100644 --- a/ng2-components/ng2-alfresco-webscript/karma-test-shim.js +++ b/ng2-components/ng2-alfresco-webscript/karma-test-shim.js @@ -54,17 +54,8 @@ var map = { 'ng2-translate': 'npm:ng2-translate', '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-datatable': 'npm:ng2-alfresco-datatable/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' }; @@ -74,17 +65,8 @@ var packages = { 'ng2-translate': { 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-datatable': { 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'} }; diff --git a/ng2-components/ng2-alfresco-webscript/karma.conf.js b/ng2-components/ng2-alfresco-webscript/karma.conf.js index f6004cd36b..cbda411a68 100644 --- a/ng2-components/ng2-alfresco-webscript/karma.conf.js +++ b/ng2-components/ng2-alfresco-webscript/karma.conf.js @@ -44,18 +44,8 @@ module.exports = function (config) { {pattern: 'dist/**/*.css', included: true, served: true, watched: true}, // 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-datatable/dist/**/*.js', 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-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 }, + { pattern: 'node_modules/ng2-alfresco-datatable/dist/**/*.*', included: false, served: true, watched: false }, // paths to support debugging with source maps in dev tools {pattern: 'src/**/*.ts', included: false, watched: false}, @@ -115,6 +105,7 @@ module.exports = function (config) { subdir: 'report', reporters: [ {type: 'text'}, + {type: 'text-summary'}, {type: 'json', file: 'coverage-final.json'}, {type: 'html'}, {type: 'lcov'} diff --git a/ng2-components/ng2-alfresco-webscript/src/webscript.component.spec.ts b/ng2-components/ng2-alfresco-webscript/src/webscript.component.spec.ts index 4e4375d1b6..a53eaec353 100644 --- a/ng2-components/ng2-alfresco-webscript/src/webscript.component.spec.ts +++ b/ng2-components/ng2-alfresco-webscript/src/webscript.component.spec.ts @@ -15,65 +15,67 @@ * limitations under the License. */ -describe('WebscriptComponent', () => { - it('should be upgraded', () => { - expect(true).toBe(true); - }); -}); - -/* -import { PLATFORM_PIPES } from '@angular/core'; -import { describe, expect, it, inject, beforeEachProviders, beforeEach, afterEach, xit } from '@angular/core/testing'; -import { TestComponentBuilder } from '@angular/compiler/testing'; +import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { WebscriptComponent } from '../src/webscript.component'; -import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService, AlfrescoPipeTranslate } from 'ng2-alfresco-core'; +import { DebugElement } from '@angular/core'; +import { + AlfrescoAuthenticationService, + AlfrescoSettingsService, + AlfrescoApiService, + CoreModule +} from 'ng2-alfresco-core'; +import { DataTableModule } from 'ng2-alfresco-datatable'; declare let jasmine: any; describe('Test ng2-alfresco-webscript', () => { - let webscriptComponentFixture, element, component; + let component: any; + let fixture: ComponentFixture; + let debug: DebugElement; + let element: HTMLElement; - beforeEachProviders(() => { - return [ - AlfrescoSettingsService, - AlfrescoAuthenticationService, - AlfrescoApiService, - { provide: PLATFORM_PIPES, useValue: AlfrescoPipeTranslate, multi: true } - ]; - }); - - beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { - return tcb - .createAsync(WebscriptComponent) - .then(fixture => { - webscriptComponentFixture = fixture; - element = webscriptComponentFixture.nativeElement; - component = webscriptComponentFixture.componentInstance; - component.scriptPath = 'fakePath'; - component.showData = true; - }); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ + CoreModule, + DataTableModule + ], + declarations: [WebscriptComponent], + providers: [ + AlfrescoSettingsService, + AlfrescoAuthenticationService, + AlfrescoApiService + ] + }).compileComponents(); })); + beforeEach(() => { + fixture = TestBed.createComponent(WebscriptComponent); + component = fixture.componentInstance; + + debug = fixture.debugElement; + element = fixture.nativeElement; + component = fixture.componentInstance; + component.scriptPath = 'fakePath'; + component.showData = true; + fixture.detectChanges(); + }); + describe('View', () => { - it('webscript html wrapper should be present', () => { + it('html wrapper should be present', () => { expect(element.querySelector('#webscript-html-wrapper')).toBeDefined(); }); - it('webscript wrapper should be hide if showData is false', () => { - webscriptComponentFixture.detectChanges(); - expect(element.querySelector('#webscript-html-wrapper')).toBe.undefined; + it('wrapper should be hide if showData is false', () => { + expect(element.querySelector('#webscript-html-wrapper')).toBeDefined(); }); - it('webscript JSON datatable wrapper should be present', () => { - webscriptComponentFixture.detectChanges(); - + it('JSON datatable wrapper should be present', () => { expect(element.querySelector('#webscript-json-wrapper')).toBeDefined(); }); - it('webscript plain text datatable wrapper should be present', () => { - webscriptComponentFixture.detectChanges(); - + it('plain text datatable wrapper should be present', () => { expect(element.querySelector('#webscript-plaintext-wrapper')).toBeDefined(); }); }); @@ -88,11 +90,11 @@ describe('Test ng2-alfresco-webscript', () => { jasmine.Ajax.uninstall(); }); - it('webscript url should be the one configured by the input param', (done) => { + it('url should be the one configured by the input param', (done) => { component.scriptPath = 'sample/folder/Company%20Home'; component.ngOnChanges().then(() => { - webscriptComponentFixture.detectChanges(); + fixture.detectChanges(); expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:8080/alfresco/service/sample/folder/Company%20Home'); done(); }); @@ -104,12 +106,12 @@ describe('Test ng2-alfresco-webscript', () => { }); }); - it('webscript TEXT response should be displayed', (done) => { + it('TEXT response should be displayed', (done) => { component.scriptPath = 'sample/folder/Company%20Home'; component.contentType = 'TEXT'; component.ngOnChanges().then(() => { - webscriptComponentFixture.detectChanges(); + fixture.detectChanges(); expect(element.querySelector('#webscript-data-TEXT').innerHTML) .toBe('text test'); done(); @@ -122,12 +124,12 @@ describe('Test ng2-alfresco-webscript', () => { }); }); - it('webscript JSON response should be displayed', (done) => { + it('JSON response should be displayed', (done) => { component.scriptPath = 'sample/folder/Company%20Home'; component.contentType = 'JSON'; component.ngOnChanges().then(() => { - webscriptComponentFixture.detectChanges(); + fixture.detectChanges(); expect(JSON.parse(element.querySelector('#webscript-data-JSON').innerHTML)[0].name).toBe('Name 1'); expect(JSON.parse(element.querySelector('#webscript-data-JSON').innerHTML)[1].name).toBe('Name 2'); done(); @@ -141,12 +143,12 @@ describe('Test ng2-alfresco-webscript', () => { }); }); - xit('webscript HTML response should be displayed', (done) => { + xit('HTML response should be displayed', (done) => { component.scriptPath = 'sample/folder/Company%20Home'; component.contentType = 'HTML'; component.ngOnChanges().then(() => { - webscriptComponentFixture.detectChanges(); + fixture.detectChanges(); expect(element.querySelector('#webscript-data-HTML').innerHTML) .toBe('<test-element-id><test-elemt-id>'); done(); @@ -159,13 +161,16 @@ describe('Test ng2-alfresco-webscript', () => { }); }); - it('webscript Datatable response should be displayed', (done) => { + it('datatable response should be displayed', (done) => { + // reset MDL handler + window['componentHandler'] = null; + component.scriptPath = 'sample/folder/Company%20Home'; component.contentType = 'DATATABLE'; component.ngOnChanges().then(() => { - webscriptComponentFixture.detectChanges(); - expect(element.querySelector('#webscript-datatable-wrapper').innerHTML).not.toBe.undefined; + fixture.detectChanges(); + expect(element.querySelector('#webscript-datatable-wrapper').innerHTML).toBeDefined(); done(); }); @@ -194,13 +199,16 @@ describe('Test ng2-alfresco-webscript', () => { }); }); - it('webscript Datatable response should be displayed also if no schema is provided', (done) => { + it('datatable response should be displayed also if no schema is provided', (done) => { + // reset MDL handler + window['componentHandler'] = null; + component.scriptPath = 'sample/folder/Company%20Home'; component.contentType = 'DATATABLE'; component.ngOnChanges().then(() => { - webscriptComponentFixture.detectChanges(); - expect(element.querySelector('#webscript-datatable-wrapper').innerHTML).not.toBe.undefined; + fixture.detectChanges(); + expect(element.querySelector('#webscript-datatable-wrapper').innerHTML).toBeDefined(); done(); }); @@ -219,4 +227,3 @@ describe('Test ng2-alfresco-webscript', () => { }); }); }); -*/ diff --git a/ng2-components/ng2-alfresco-webscript/tsconfig.json b/ng2-components/ng2-alfresco-webscript/tsconfig.json index ae39a67a17..ce6e770c51 100644 --- a/ng2-components/ng2-alfresco-webscript/tsconfig.json +++ b/ng2-components/ng2-alfresco-webscript/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "es5", - "module": "system", + "module": "commonjs", "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true,