diff --git a/ng2-components/ng2-alfresco-search/karma-test-shim.js b/ng2-components/ng2-alfresco-search/karma-test-shim.js index b0cc54dc38..45a2f4f180 100644 --- a/ng2-components/ng2-alfresco-search/karma-test-shim.js +++ b/ng2-components/ng2-alfresco-search/karma-test-shim.js @@ -54,6 +54,21 @@ System.config(config); System.import('@angular/platform-browser/src/browser/browser_adapter') .then(function(browser_adapter) { browser_adapter.BrowserDomAdapter.makeCurrent(); }) + .then(function () { + return Promise.all([ + System.import('@angular/core/testing'), + System.import('@angular/platform-browser-dynamic/testing') + ]) + }) + .then(function (providers) { + var testing = providers[0]; + var testingBrowser = providers[1]; + + testing.setBaseTestProviders( + testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, + testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); + + }) .then(function() { return Promise.all(resolveTestFiles()); }) .then( function() { diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.spec.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.spec.ts index a6dde9dea2..9dc2702de5 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.spec.ts +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.spec.ts @@ -16,11 +16,7 @@ */ import { provide } from '@angular/core'; -import { - TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, - TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS -} from '@angular/platform-browser-dynamic/testing'; -import { it, describe, expect, inject, beforeEachProviders, setBaseTestProviders } from '@angular/core/testing'; +import { it, describe, expect, inject, beforeEachProviders } from '@angular/core/testing'; import { TestComponentBuilder } from '@angular/compiler/testing'; import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocomplete.component'; import { SearchServiceMock } from './../assets/alfresco-search.service.mock'; @@ -35,8 +31,6 @@ describe('AlfrescoSearchAutocompleteComponent', () => { let searchService; - setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); - beforeEachProviders(() => { searchService = new SearchServiceMock(); diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.spec.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.spec.ts index 1e27eb7651..95cc4e9c3b 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.spec.ts +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.spec.ts @@ -15,17 +15,35 @@ * limitations under the License. */ -import { - TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, - TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS -} from '@angular/platform-browser-dynamic/testing'; -import { it, describe, expect, inject, setBaseTestProviders } from '@angular/core/testing'; +import { provide } from '@angular/core'; +import { it, describe, expect, inject, beforeEachProviders } from '@angular/core/testing'; import { TestComponentBuilder } from '@angular/compiler/testing'; import { AlfrescoSearchControlComponent } from './alfresco-search-control.component'; +import { SearchServiceMock } from './../assets/alfresco-search.service.mock'; +import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service'; +import { TranslationMock } from './../assets/translation.service.mock'; +import { + AlfrescoSettingsService, + AlfrescoAuthenticationService, + AlfrescoContentService, + AlfrescoTranslationService } from 'ng2-alfresco-core'; describe('AlfrescoSearchControlComponent', () => { - setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); + let searchService; + + beforeEachProviders(() => { + searchService = new SearchServiceMock(); + + return [ + searchService.getProviders(), + provide(AlfrescoThumbnailService, {}), + provide(AlfrescoTranslationService, {useClass: TranslationMock}), + provide(AlfrescoSettingsService, {}), + provide(AlfrescoAuthenticationService, {}), + provide(AlfrescoContentService, {}) + ]; + }); it('should setup i18n folder', () => { @@ -40,13 +58,15 @@ describe('AlfrescoSearchControlComponent', () => { it('should emit searchChange when search term changed', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { - return tcb.createAsync(AlfrescoSearchControlComponent).then((componentFixture) => { - componentFixture.componentInstance.searchTerm = 'customSearchTerm'; - componentFixture.detectChanges(); - componentFixture.componentInstance.searchChange.subscribe(e => { - expect(e.value).toBe('customSearchTerm'); + return tcb + .createAsync(AlfrescoSearchControlComponent) + .then((componentFixture) => { + componentFixture.componentInstance.searchTerm = 'customSearchTerm'; + componentFixture.detectChanges(); + componentFixture.componentInstance.searchChange.subscribe(e => { + expect(e.value).toBe('customSearchTerm'); + }); }); - }); })); describe('Component rendering', () => { diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.spec.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.spec.ts index f13ee022ca..02f45e3ed9 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.spec.ts +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.spec.ts @@ -16,16 +16,13 @@ */ import { provide } from '@angular/core'; -import { - TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, - TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS -} from '@angular/platform-browser-dynamic/testing'; -import { it, describe, expect, inject, beforeEachProviders, setBaseTestProviders } from '@angular/core/testing'; +import { it, describe, expect, inject, beforeEachProviders } from '@angular/core/testing'; import { TestComponentBuilder } from '@angular/compiler/testing'; import { RouteParams } from '@angular/router-deprecated'; import { AlfrescoSearchComponent } from './alfresco-search.component'; import { SearchServiceMock } from './../assets/alfresco-search.service.mock'; import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service'; +import { TranslationMock } from './../assets/translation.service.mock'; import { AlfrescoSettingsService, AlfrescoAuthenticationService, @@ -36,15 +33,13 @@ describe('AlfrescoSearchComponent', () => { let searchService; - setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); - beforeEachProviders(() => { searchService = new SearchServiceMock(); return [ searchService.getProviders(), provide(AlfrescoThumbnailService, {}), - provide(AlfrescoTranslationService, {}), + provide(AlfrescoTranslationService, {useClass: TranslationMock}), provide(AlfrescoSettingsService, {}), provide(AlfrescoAuthenticationService, {}), provide(AlfrescoContentService, {})