mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
Merge pull request #840 from Alfresco/dev-eromano-webscriptTestFix
fix test webscript
This commit is contained in:
commit
79fc3085c0
@ -54,17 +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-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'
|
'ng2-alfresco-webscript': 'npm:ng2-alfresco-webscript/dist'
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -74,17 +65,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-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'}
|
'ng2-alfresco-webscript': { main: './index.js', defaultExtension: 'js'}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,18 +44,8 @@ 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-datatable/dist/**/*.*', 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 },
|
|
||||||
|
|
||||||
// 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},
|
||||||
@ -115,6 +105,7 @@ module.exports = function (config) {
|
|||||||
subdir: 'report',
|
subdir: 'report',
|
||||||
reporters: [
|
reporters: [
|
||||||
{type: 'text'},
|
{type: 'text'},
|
||||||
|
{type: 'text-summary'},
|
||||||
{type: 'json', file: 'coverage-final.json'},
|
{type: 'json', file: 'coverage-final.json'},
|
||||||
{type: 'html'},
|
{type: 'html'},
|
||||||
{type: 'lcov'}
|
{type: 'lcov'}
|
||||||
|
@ -15,65 +15,67 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
describe('WebscriptComponent', () => {
|
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||||
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 { WebscriptComponent } from '../src/webscript.component';
|
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;
|
declare let jasmine: any;
|
||||||
|
|
||||||
describe('Test ng2-alfresco-webscript', () => {
|
describe('Test ng2-alfresco-webscript', () => {
|
||||||
|
|
||||||
let webscriptComponentFixture, element, component;
|
let component: any;
|
||||||
|
let fixture: ComponentFixture<WebscriptComponent>;
|
||||||
|
let debug: DebugElement;
|
||||||
|
let element: HTMLElement;
|
||||||
|
|
||||||
beforeEachProviders(() => {
|
beforeEach(async(() => {
|
||||||
return [
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
CoreModule,
|
||||||
|
DataTableModule
|
||||||
|
],
|
||||||
|
declarations: [WebscriptComponent],
|
||||||
|
providers: [
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoApiService,
|
AlfrescoApiService
|
||||||
{ provide: PLATFORM_PIPES, useValue: AlfrescoPipeTranslate, multi: true }
|
]
|
||||||
];
|
}).compileComponents();
|
||||||
});
|
|
||||||
|
|
||||||
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(() => {
|
||||||
|
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', () => {
|
describe('View', () => {
|
||||||
it('webscript html wrapper should be present', () => {
|
it('html wrapper should be present', () => {
|
||||||
expect(element.querySelector('#webscript-html-wrapper')).toBeDefined();
|
expect(element.querySelector('#webscript-html-wrapper')).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('webscript wrapper should be hide if showData is false', () => {
|
it('wrapper should be hide if showData is false', () => {
|
||||||
webscriptComponentFixture.detectChanges();
|
expect(element.querySelector('#webscript-html-wrapper')).toBeDefined();
|
||||||
expect(element.querySelector('#webscript-html-wrapper')).toBe.undefined;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('webscript JSON datatable wrapper should be present', () => {
|
it('JSON datatable wrapper should be present', () => {
|
||||||
webscriptComponentFixture.detectChanges();
|
|
||||||
|
|
||||||
expect(element.querySelector('#webscript-json-wrapper')).toBeDefined();
|
expect(element.querySelector('#webscript-json-wrapper')).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('webscript plain text datatable wrapper should be present', () => {
|
it('plain text datatable wrapper should be present', () => {
|
||||||
webscriptComponentFixture.detectChanges();
|
|
||||||
|
|
||||||
expect(element.querySelector('#webscript-plaintext-wrapper')).toBeDefined();
|
expect(element.querySelector('#webscript-plaintext-wrapper')).toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -88,11 +90,11 @@ describe('Test ng2-alfresco-webscript', () => {
|
|||||||
jasmine.Ajax.uninstall();
|
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.scriptPath = 'sample/folder/Company%20Home';
|
||||||
|
|
||||||
component.ngOnChanges().then(() => {
|
component.ngOnChanges().then(() => {
|
||||||
webscriptComponentFixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:8080/alfresco/service/sample/folder/Company%20Home');
|
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:8080/alfresco/service/sample/folder/Company%20Home');
|
||||||
done();
|
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.scriptPath = 'sample/folder/Company%20Home';
|
||||||
component.contentType = 'TEXT';
|
component.contentType = 'TEXT';
|
||||||
|
|
||||||
component.ngOnChanges().then(() => {
|
component.ngOnChanges().then(() => {
|
||||||
webscriptComponentFixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(element.querySelector('#webscript-data-TEXT').innerHTML)
|
expect(element.querySelector('#webscript-data-TEXT').innerHTML)
|
||||||
.toBe('text test');
|
.toBe('text test');
|
||||||
done();
|
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.scriptPath = 'sample/folder/Company%20Home';
|
||||||
component.contentType = 'JSON';
|
component.contentType = 'JSON';
|
||||||
|
|
||||||
component.ngOnChanges().then(() => {
|
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)[0].name).toBe('Name 1');
|
||||||
expect(JSON.parse(element.querySelector('#webscript-data-JSON').innerHTML)[1].name).toBe('Name 2');
|
expect(JSON.parse(element.querySelector('#webscript-data-JSON').innerHTML)[1].name).toBe('Name 2');
|
||||||
done();
|
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.scriptPath = 'sample/folder/Company%20Home';
|
||||||
component.contentType = 'HTML';
|
component.contentType = 'HTML';
|
||||||
|
|
||||||
component.ngOnChanges().then(() => {
|
component.ngOnChanges().then(() => {
|
||||||
webscriptComponentFixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(element.querySelector('#webscript-data-HTML').innerHTML)
|
expect(element.querySelector('#webscript-data-HTML').innerHTML)
|
||||||
.toBe('<test-element-id><test-elemt-id>');
|
.toBe('<test-element-id><test-elemt-id>');
|
||||||
done();
|
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.scriptPath = 'sample/folder/Company%20Home';
|
||||||
component.contentType = 'DATATABLE';
|
component.contentType = 'DATATABLE';
|
||||||
|
|
||||||
component.ngOnChanges().then(() => {
|
component.ngOnChanges().then(() => {
|
||||||
webscriptComponentFixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(element.querySelector('#webscript-datatable-wrapper').innerHTML).not.toBe.undefined;
|
expect(element.querySelector('#webscript-datatable-wrapper').innerHTML).toBeDefined();
|
||||||
done();
|
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.scriptPath = 'sample/folder/Company%20Home';
|
||||||
component.contentType = 'DATATABLE';
|
component.contentType = 'DATATABLE';
|
||||||
|
|
||||||
component.ngOnChanges().then(() => {
|
component.ngOnChanges().then(() => {
|
||||||
webscriptComponentFixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(element.querySelector('#webscript-datatable-wrapper').innerHTML).not.toBe.undefined;
|
expect(element.querySelector('#webscript-datatable-wrapper').innerHTML).toBeDefined();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -219,4 +227,3 @@ describe('Test ng2-alfresco-webscript', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
@ -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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user