Test runner improvements

- now all tests are running
This commit is contained in:
Denys Vuika
2016-06-23 13:41:58 +01:00
committed by Will Abson
parent 58a21ea4ad
commit 1296087170
4 changed files with 51 additions and 27 deletions

View File

@@ -54,6 +54,21 @@ System.config(config);
System.import('@angular/platform-browser/src/browser/browser_adapter') System.import('@angular/platform-browser/src/browser/browser_adapter')
.then(function(browser_adapter) { browser_adapter.BrowserDomAdapter.makeCurrent(); }) .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() { return Promise.all(resolveTestFiles()); })
.then( .then(
function() { function() {

View File

@@ -16,11 +16,7 @@
*/ */
import { provide } from '@angular/core'; import { provide } from '@angular/core';
import { import { it, describe, expect, inject, beforeEachProviders } from '@angular/core/testing';
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 { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocomplete.component'; import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocomplete.component';
import { SearchServiceMock } from './../assets/alfresco-search.service.mock'; import { SearchServiceMock } from './../assets/alfresco-search.service.mock';
@@ -35,8 +31,6 @@ describe('AlfrescoSearchAutocompleteComponent', () => {
let searchService; let searchService;
setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
beforeEachProviders(() => { beforeEachProviders(() => {
searchService = new SearchServiceMock(); searchService = new SearchServiceMock();

View File

@@ -15,17 +15,35 @@
* limitations under the License. * limitations under the License.
*/ */
import { import { provide } from '@angular/core';
TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, import { it, describe, expect, inject, beforeEachProviders } from '@angular/core/testing';
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
} from '@angular/platform-browser-dynamic/testing';
import { it, describe, expect, inject, setBaseTestProviders } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { AlfrescoSearchControlComponent } from './alfresco-search-control.component'; 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', () => { 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', () => { it('should setup i18n folder', () => {
@@ -40,13 +58,15 @@ describe('AlfrescoSearchControlComponent', () => {
it('should emit searchChange when search term changed', it('should emit searchChange when search term changed',
inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb.createAsync(AlfrescoSearchControlComponent).then((componentFixture) => { return tcb
componentFixture.componentInstance.searchTerm = 'customSearchTerm'; .createAsync(AlfrescoSearchControlComponent)
componentFixture.detectChanges(); .then((componentFixture) => {
componentFixture.componentInstance.searchChange.subscribe(e => { componentFixture.componentInstance.searchTerm = 'customSearchTerm';
expect(e.value).toBe('customSearchTerm'); componentFixture.detectChanges();
componentFixture.componentInstance.searchChange.subscribe(e => {
expect(e.value).toBe('customSearchTerm');
});
}); });
});
})); }));
describe('Component rendering', () => { describe('Component rendering', () => {

View File

@@ -16,16 +16,13 @@
*/ */
import { provide } from '@angular/core'; import { provide } from '@angular/core';
import { import { it, describe, expect, inject, beforeEachProviders } from '@angular/core/testing';
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 { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { RouteParams } from '@angular/router-deprecated'; import { RouteParams } from '@angular/router-deprecated';
import { AlfrescoSearchComponent } from './alfresco-search.component'; import { AlfrescoSearchComponent } from './alfresco-search.component';
import { SearchServiceMock } from './../assets/alfresco-search.service.mock'; import { SearchServiceMock } from './../assets/alfresco-search.service.mock';
import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service'; import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service';
import { TranslationMock } from './../assets/translation.service.mock';
import { import {
AlfrescoSettingsService, AlfrescoSettingsService,
AlfrescoAuthenticationService, AlfrescoAuthenticationService,
@@ -36,15 +33,13 @@ describe('AlfrescoSearchComponent', () => {
let searchService; let searchService;
setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
beforeEachProviders(() => { beforeEachProviders(() => {
searchService = new SearchServiceMock(); searchService = new SearchServiceMock();
return [ return [
searchService.getProviders(), searchService.getProviders(),
provide(AlfrescoThumbnailService, {}), provide(AlfrescoThumbnailService, {}),
provide(AlfrescoTranslationService, {}), provide(AlfrescoTranslationService, {useClass: TranslationMock}),
provide(AlfrescoSettingsService, {}), provide(AlfrescoSettingsService, {}),
provide(AlfrescoAuthenticationService, {}), provide(AlfrescoAuthenticationService, {}),
provide(AlfrescoContentService, {}) provide(AlfrescoContentService, {})