From 75a38d5c54997c67ae2c95a20b46036dbe1b41d7 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Tue, 14 Jun 2016 19:10:07 +0100 Subject: [PATCH] fix uploader test RC1 --- .../ng2-alfresco-upload/karma-test-shim.js | 12 +++++--- .../ng2-alfresco-upload/karma.conf.js | 3 ++ .../file-uploading-dialog.component.spec.ts | 24 ++++++---------- .../upload-button.component.spec.ts | 28 ++++++------------- 4 files changed, 29 insertions(+), 38 deletions(-) diff --git a/ng2-components/ng2-alfresco-upload/karma-test-shim.js b/ng2-components/ng2-alfresco-upload/karma-test-shim.js index 5760992362..0e75b01bf5 100644 --- a/ng2-components/ng2-alfresco-upload/karma-test-shim.js +++ b/ng2-components/ng2-alfresco-upload/karma-test-shim.js @@ -8,12 +8,16 @@ __karma__.loaded = function() {}; var map = { 'app': 'base/dist', 'rxjs': 'base/node_modules/rxjs', - '@angular': 'base/node_modules/@angular' + '@angular': 'base/node_modules/@angular', + 'ng2-alfresco-core/dist': '/base/node_modules/ng2-alfresco-core/dist', + 'ng2-translate' : '/base/node_modules/ng2-translate' }; var packages = { 'app': { main: 'main.js', defaultExtension: 'js' }, - 'rxjs': { defaultExtension: 'js' } + 'rxjs': { defaultExtension: 'js' }, + 'ng2-alfresco-core/dist': { defaultExtension: 'js' }, + 'ng2-translate': { defaultExtension: 'js' } }; var packageNames = [ @@ -26,7 +30,7 @@ var packageNames = [ '@angular/router', '@angular/router-deprecated', '@angular/testing', - '@angular/upgrade', + '@angular/upgrade' ]; packageNames.forEach(function(pkgName) { @@ -54,7 +58,7 @@ System.import('@angular/platform-browser/src/browser/browser_adapter') __karma__.start(); }, function(error) { - if(typeof __karma__.error == 'fucntion') { + if(typeof __karma__.error == 'function') { __karma__.error(error.stack || error); }else{ console.error(error); diff --git a/ng2-components/ng2-alfresco-upload/karma.conf.js b/ng2-components/ng2-alfresco-upload/karma.conf.js index 3a287de24c..5330c069d6 100644 --- a/ng2-components/ng2-alfresco-upload/karma.conf.js +++ b/ng2-components/ng2-alfresco-upload/karma.conf.js @@ -12,8 +12,11 @@ module.exports = function (config) { {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: false}, {pattern: 'node_modules/zone.js/dist/zone.js', included: true, watched: true}, {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/rxjs/**/*.map', included: false, watched: false}, {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, {pattern: 'node_modules/@angular/**/*.map', included: false, watched: false}, + {pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false}, + {pattern: 'node_modules/ng2-translate/**/*.js', included: false, served: true, watched: false}, {pattern: 'karma-test-shim.js', included: true, watched: true}, diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.spec.ts b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.spec.ts index 880ad0e21c..7949ed91a6 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.spec.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.spec.ts @@ -15,18 +15,13 @@ * limitations under the License. */ -import { describe, it, expect } from '@angular/core/testing'; - -describe('FileUploadDialog', () => { - it ('should be migrated to angular 2 rc.1', () => { - expect(false).toBe(true); - }); -}); - -/* -import { TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS } from 'angular2/platform/testing/browser'; -import { it, describe, expect, injectAsync, beforeEachProviders, TestComponentBuilder, setBaseTestProviders } from 'angular2/testing'; -import { provide } from 'angular2/core'; +import { describe, expect, it, inject, beforeEachProviders, setBaseTestProviders } from '@angular/core/testing'; +import { TestComponentBuilder } from '@angular/compiler/testing'; +import { + TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, + TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS +} from '@angular/platform-browser-dynamic/testing'; +import { provide } from '@angular/core'; import { FileUploadingDialogComponent } from './file-uploading-dialog.component'; import { FileModel } from '../models/file.model'; import { AlfrescoTranslationService } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; @@ -34,7 +29,7 @@ import { TranslationMock } from '../assets/translation.service.mock'; describe('FileUploadDialog', () => { - setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS); + setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); beforeEachProviders(() => { return [ @@ -42,7 +37,7 @@ describe('FileUploadDialog', () => { ]; }); - it('should render dialog box with css class show', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + it('should render dialog box with css class show', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb .createAsync(FileUploadingDialogComponent) .then((fixture) => { @@ -62,4 +57,3 @@ describe('FileUploadDialog', () => { }); })); }); -*/ diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts index 5f041bc983..09f2a85b9f 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts @@ -15,25 +15,15 @@ * limitations under the License. */ - -import { describe, it, expect } from '@angular/core/testing'; - -describe('AlfrescoUploadButton', () => { - it ('should be migrated to angular 2 rc.1', () => { - expect(false).toBe(true); - }); -}); - -/* -import { it, describe, expect, injectAsync, beforeEachProviders, TestComponentBuilder } from 'angular2/testing'; -import { provide } from 'angular2/core'; +import { describe, expect, it, inject, beforeEachProviders } from '@angular/core/testing'; +import { TestComponentBuilder } from '@angular/compiler/testing'; +import { provide } from '@angular/core'; import { UploadButtonComponent } from './upload-button.component'; import { AlfrescoTranslationService } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; import { TranslationMock } from '../assets/translation.service.mock'; import { UploadServiceMock } from '../assets/upload.service.mock'; import { UploadService } from '../services/upload.service'; - describe('AlfrescoUploadButton', () => { beforeEachProviders(() => { @@ -44,7 +34,7 @@ describe('AlfrescoUploadButton', () => { }); it('should render upload-single-file button as default', - injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb .createAsync(UploadButtonComponent) .then((fixture) => { @@ -57,7 +47,7 @@ describe('AlfrescoUploadButton', () => { })); it('should render upload-multiple-file button if multipleFiles is true', - injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb .createAsync(UploadButtonComponent) .then((fixture) => { @@ -70,7 +60,7 @@ describe('AlfrescoUploadButton', () => { })); it('should render an uploadFolder button if uploadFolder is true', - injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb .createAsync(UploadButtonComponent) .then((fixture) => { @@ -82,7 +72,7 @@ describe('AlfrescoUploadButton', () => { }); })); - it('should call onFilesAdded method', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + it('should call onFilesAdded method', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb .createAsync(UploadButtonComponent) .then((fixture) => { @@ -101,7 +91,7 @@ describe('AlfrescoUploadButton', () => { })); it('should render dialog box with css class show', - injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb .createAsync(UploadButtonComponent) .then((fixture) => { @@ -115,4 +105,4 @@ describe('AlfrescoUploadButton', () => { }); })); }); -*/ +