-
-
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: mocking token more intelligently
- Loading branch information
Showing
11 changed files
with
504 additions
and
48 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
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Injectable, NgModule } from '@angular/core'; | ||
import { TestBed } from '@angular/core/testing'; | ||
import { MockBuilder } from 'ng-mocks'; | ||
|
||
@Injectable() | ||
abstract class LoggerInterface { | ||
abstract log(message: string): void; | ||
} | ||
|
||
@Injectable() | ||
class Logger implements LoggerInterface { | ||
public lastMessage = ''; | ||
|
||
log(message: string): void { | ||
this.lastMessage = message; | ||
} | ||
} | ||
|
||
@NgModule({ | ||
providers: [ | ||
{ | ||
provide: LoggerInterface, | ||
useClass: Logger, | ||
}, | ||
], | ||
}) | ||
class TargetModule {} | ||
|
||
describe('abstract-methods-provider', () => { | ||
beforeEach(() => MockBuilder().mock(TargetModule)); | ||
|
||
it('provides a mocked copy with an implemented abstract method', () => { | ||
const actual: LoggerInterface = TestBed.get(LoggerInterface); | ||
|
||
expect(actual.log).toBeDefined(); | ||
}); | ||
}); |
Oops, something went wrong.