mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#46 Fixed test after translation task.
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
"tsc": "tsc",
|
||||
"tsc:w": "tsc -w",
|
||||
"typings": "typings",
|
||||
"test": "live-server --open=index.html --entry-file=test/ "
|
||||
"test": "live-server --open=index.html --entry-file=test/ ",
|
||||
"test:w": "concurrently \"npm run tsc:w\" \"npm run test\" "
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -51,7 +52,8 @@
|
||||
"live-server": "^0.9.2",
|
||||
"tslint": "^3.8.1",
|
||||
"typescript": "^1.8.10",
|
||||
"typings": "^0.7.12"
|
||||
"typings": "^0.7.12",
|
||||
"concurrently": "^2.0.0"
|
||||
},
|
||||
"license-check-config": {
|
||||
"src": [
|
||||
|
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {provide, EventEmitter} from 'angular2/core';
|
||||
import {LangChangeEvent} from 'ng2-translate/ng2-translate';
|
||||
|
||||
|
||||
export class TranslationMock {
|
||||
|
||||
public onLangChange: EventEmitter<LangChangeEvent> = new EventEmitter<LangChangeEvent>();
|
||||
|
||||
setDefaultLang() {
|
||||
|
||||
}
|
||||
|
||||
use() {
|
||||
}
|
||||
|
||||
public get(key: string|Array<string>, interpolateParams?: Object): Observable<string|any> {
|
||||
if (!key) {
|
||||
throw new Error('Parameter "key" required');
|
||||
}
|
||||
return Observable.of(key);
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
import {TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS} from 'angular2/platform/testing/browser';
|
||||
import {it, describe, expect, injectAsync, TestComponentBuilder, setBaseTestProviders} from 'angular2/testing';
|
||||
import {Component} from 'angular2/core';
|
||||
import {FileUploadingDialogComponent} from '../../../src/components/file-uploading-dialog.component';
|
||||
|
||||
describe('FileUploadDialog', () => {
|
||||
|
||||
//setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
|
||||
|
||||
it('should render dialog box with css class show', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(FileUploadingDialogComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
component._showDialog();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(compiled.querySelector('.file-dialog').getAttribute('class')).toEqual('file-dialog show');
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
@@ -17,14 +17,22 @@
|
||||
|
||||
|
||||
import {TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS} from 'angular2/platform/testing/browser';
|
||||
import {it, describe, expect, injectAsync, TestComponentBuilder, setBaseTestProviders} from 'angular2/testing';
|
||||
import {it, describe, expect, injectAsync, beforeEachProviders, TestComponentBuilder, setBaseTestProviders} from 'angular2/testing';
|
||||
import {Component, provide, Injector} from 'angular2/core';
|
||||
import {UploadButtonComponent} from '../../../src/components/upload-button.component';
|
||||
import {TranslateService, LangChangeEvent} from 'ng2-translate/ng2-translate';
|
||||
import {TranslationMock} from '../assets/translation.service.mock';
|
||||
|
||||
describe('AlfrescoUploadButton', () => {
|
||||
|
||||
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
|
||||
|
||||
beforeEachProviders(() => {
|
||||
return [
|
||||
provide(TranslateService, {useClass: TranslationMock})
|
||||
];
|
||||
});
|
||||
|
||||
it('should render upload-single-file button as default', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(UploadButtonComponent)
|
||||
|
@@ -29,7 +29,17 @@
|
||||
System.config({
|
||||
packages: {
|
||||
'test': {defaultExtension: 'js'},
|
||||
'src': {defaultExtension: 'js'}
|
||||
'src': {defaultExtension: 'js'},
|
||||
'ng2-translate': {
|
||||
defaultExtension: 'js'
|
||||
},
|
||||
'rxjs': {
|
||||
defaultExtension: 'js'
|
||||
}
|
||||
},
|
||||
map: {
|
||||
'ng2-translate': '../node_modules/ng2-translate',
|
||||
'rxjs': '../node_modules/rxjs'
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -67,14 +67,12 @@ describe('AlfrescoUploadService', () => {
|
||||
});
|
||||
|
||||
it('should add an element in the queue and returns it', () => {
|
||||
service.setXMLHttpRequest(xhr);
|
||||
let filesFake = [{name: 'fake-name', size: 10}];
|
||||
service.addToQueue(filesFake);
|
||||
expect(service.getQueue().length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should add two elements in the queue and returns them', () => {
|
||||
service.setXMLHttpRequest(xhr);
|
||||
let filesFake = [{name: 'fake-name', size: 10}, {name: 'fake-name2', size: 20} ];
|
||||
service.addToQueue(filesFake);
|
||||
expect(service.getQueue().length).toEqual(2);
|
||||
@@ -84,7 +82,7 @@ describe('AlfrescoUploadService', () => {
|
||||
service.setXMLHttpRequest(xhr);
|
||||
let filesFake = [{name: 'fake-name', size: 10}];
|
||||
service.addToQueue(filesFake);
|
||||
|
||||
service.uploadFilesInTheQueue('');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('/some/cool/url');
|
||||
expect(doneFn).not.toHaveBeenCalled();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -99,7 +97,7 @@ describe('AlfrescoUploadService', () => {
|
||||
service.setXMLHttpRequest(xhr);
|
||||
let filesFake = [{name: 'fake-name', size: 10}];
|
||||
service.addToQueue(filesFake);
|
||||
|
||||
service.uploadFilesInTheQueue('');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('/some/cool/url');
|
||||
expect(doneFn).not.toHaveBeenCalled();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -114,6 +112,7 @@ describe('AlfrescoUploadService', () => {
|
||||
service.setXMLHttpRequest(xhr);
|
||||
let filesFake = [{name: 'fake-name', size: 10}];
|
||||
service.addToQueue(filesFake);
|
||||
service.uploadFilesInTheQueue('');
|
||||
let file = service.getQueue();
|
||||
file[0].setAbort();
|
||||
expect(xhr.abort).toHaveBeenCalled();
|
||||
|
Reference in New Issue
Block a user