-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add testbed test that exposed now fixed issue
- Loading branch information
Showing
5 changed files
with
89 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,54 @@ | ||
import { ParentModule } from './test-fixtures'; | ||
import { Component } from '@angular/core'; | ||
import { async, ComponentFixture, getTestBed, TestBed } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { | ||
BrowserDynamicTestingModule, | ||
platformBrowserDynamicTesting | ||
} from '@angular/platform-browser-dynamic/testing'; | ||
|
||
import { ExampleComponent, ParentModule } from './test-fixtures'; | ||
import { MockModule } from './mock-module'; | ||
|
||
@Component({ | ||
selector: 'component-subject', | ||
template: ` | ||
<example-component></example-component> | ||
<span example-directive></span> | ||
{{ test | examplePipe }} | ||
` | ||
}) | ||
class ComponentSubject { | ||
test = 'test'; | ||
} | ||
|
||
describe('MockModule', () => { | ||
let fixture: ComponentFixture<ComponentSubject>; | ||
|
||
getTestBed().initTestEnvironment( | ||
BrowserDynamicTestingModule, | ||
platformBrowserDynamicTesting() | ||
); | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
ComponentSubject | ||
], | ||
imports: [ | ||
MockModule(ParentModule) | ||
], | ||
}) | ||
.compileComponents() | ||
.then(() => { | ||
fixture = TestBed.createComponent(ComponentSubject); | ||
fixture.detectChanges(); | ||
}); | ||
})); | ||
|
||
it('should do stuff', () => { | ||
MockModule(ParentModule); | ||
const mockedComponent = fixture.debugElement | ||
.query(By.css('example-component')) | ||
.componentInstance as ExampleComponent; | ||
expect(mockedComponent).not.toBeNull(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters