-
-
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.
feat(core): hidden usage of MockBuilder in TestBed if kept and mock m…
…odules are used together #4344
- Loading branch information
Showing
26 changed files
with
518 additions
and
57 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 was deleted.
Oops, something went wrong.
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,9 @@ | ||
import { isNgModuleDefWithProviders } from './func.is-ng-module-def-with-providers'; | ||
|
||
export default (provider: any): any => { | ||
return provider && typeof provider === 'object' && provider.provide | ||
? provider.provide | ||
: isNgModuleDefWithProviders(provider) | ||
? provider.ngModule | ||
: provider; | ||
}; |
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
8 changes: 2 additions & 6 deletions
8
libs/ng-mocks/src/lib/mock-builder/promise/apply-platform-modules.ts
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,19 +1,15 @@ | ||
import { getTestBed } from '@angular/core/testing'; | ||
|
||
import { flatten } from '../../common/core.helpers'; | ||
import funcGetType from '../../common/func.get-type'; | ||
import ngMocksUniverse from '../../common/ng-mocks-universe'; | ||
|
||
export default () => { | ||
const testBed = getTestBed(); | ||
// istanbul ignore else | ||
if (testBed.ngModule) { | ||
for (const def of flatten<any>(testBed.ngModule)) { | ||
// istanbul ignore if | ||
if (typeof def === 'object' && /* istanbul ignore next */ def.ngModule) { | ||
ngMocksUniverse.touches.add(def.ngModule); | ||
} else { | ||
ngMocksUniverse.touches.add(def); | ||
} | ||
ngMocksUniverse.touches.add(funcGetType(def)); | ||
} | ||
} | ||
}; |
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
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,13 +1,15 @@ | ||
import { flatten } from '../common/core.helpers'; | ||
import funcGetProvider from '../common/func.get-provider'; | ||
import funcGetType from '../common/func.get-type'; | ||
import ngMocksUniverse from '../common/ng-mocks-universe'; | ||
|
||
export default (providers?: any[]): void => { | ||
for (const provider of flatten(providers ?? [])) { | ||
const provide = funcGetProvider(provider); | ||
const provide = funcGetType(provider); | ||
|
||
const config = ngMocksUniverse.configInstance.get(provide) ?? {}; | ||
config.exported = true; | ||
if (!config.exported) { | ||
config.exported = true; | ||
} | ||
ngMocksUniverse.configInstance.set(provide, config); | ||
} | ||
}; |
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
Oops, something went wrong.