We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I use TestBed with NativeScript. This spec is not working:
import 'reflect-metadata'; import {Router} from '@angular/router'; import {BaseRequestOptions, Response, Http, ResponseOptions} from '@angular/http'; import {MockBackend} from '@angular/http/testing'; import {Page} from 'ui/page'; import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing'; import {inject, TestBed} from '@angular/core/testing'; import {SettingsService, AuthService, Logger, User} from '@abc/angular-common'; import * as appSettings from 'application-settings'; import {ApplicationSettingsService} from '../../services/app_settings.service'; import {AppLogService} from '../../services/app_logger.service'; import {RouterMock} from '../mocks/router.mock'; import {ProfileComponent} from '../../components/profile/profile.component'; import {MockConnection} from '@angular/http/testing/mock_backend'; TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); describe('ProfileComponent', () => { // provide our implementations or mocks to the dependency injector beforeEach(() => { appSettings.clear(); TestBed.configureTestingModule({ providers: [ {provide: Router, useClass: RouterMock}, {provide: Logger, useClass: AppLogService}, {provide: SettingsService, useClass: ApplicationSettingsService}, BaseRequestOptions, MockBackend, { provide: Http, useFactory: (backend, defaultOptions) => { return new Http(backend, defaultOptions); }, deps: [MockBackend, BaseRequestOptions] }, AuthService, Page, ProfileComponent ] }); }); it('should init', inject([ProfileComponent], (profile) => { expect(profile).toBeDefined(); })); it('should get user on init', inject([ProfileComponent, AuthService], (profile, authService) => { let user: User = new User(); user.username = 'test'; spyOn(authService, 'getUser').and.callFake(() => { return user; }); // trigger init to get user profile.ngOnInit(); expect(authService.getUser).toHaveBeenCalled(); expect(profile.user).toBe(user); })); });
TestBed would be nice as it gives the ability to have several injects in a test case
The text was updated successfully, but these errors were encountered:
any news on this?
Sorry, something went wrong.
Closing in favor of #479
Successfully merging a pull request may close this issue.
How can I use TestBed with NativeScript. This spec is not working:
TestBed would be nice as it gives the ability to have several injects in a test case
The text was updated successfully, but these errors were encountered: