forked from help-me-mom/ng-mocks
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(MockBuilder): touches kept modules in standalone components help-…
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Component, NgModule, VERSION } from '@angular/core'; | ||
|
||
import { MockBuilder, MockRender } from 'ng-mocks'; | ||
|
||
// @see https://github.com/help-me-mom/ng-mocks/issues/5520 | ||
describe('issue-5520', () => { | ||
if (Number.parseInt(VERSION.major, 10) < 15) { | ||
it('needs a15', () => { | ||
// pending('Need Angular 15+'); | ||
expect(true).toBeTruthy(); | ||
}); | ||
|
||
return; | ||
} | ||
|
||
@Component({ | ||
selector: 'dependency', | ||
template: '', | ||
}) | ||
class DependencyComponent { | ||
dependency5520() {} | ||
} | ||
|
||
@NgModule({ | ||
declarations: [DependencyComponent], | ||
exports: [DependencyComponent], | ||
}) | ||
class DependencyModule {} | ||
|
||
@Component( | ||
{ | ||
selector: 'standalone', | ||
standalone: true, | ||
template: '<dependency></dependency>', | ||
imports: [DependencyModule], | ||
} as never /* TODO: remove after upgrade to a15 */, | ||
) | ||
class StandaloneComponent { | ||
standalone5520() {} | ||
} | ||
|
||
beforeEach(() => | ||
MockBuilder(StandaloneComponent, null) | ||
.keep(DependencyModule) | ||
.mock(DependencyComponent), | ||
); | ||
// Error: MockBuilder has found a missing dependency: DependencyModule. It means no module provides it. | ||
// Please, use the "export" flag if you want to add it explicitly. https://ng-mocks.sudo.eu/api/MockBuilder#export-flag | ||
|
||
it('creates StandaloneComponent', () => { | ||
expect(() => MockRender(StandaloneComponent)).not.toThrow(); | ||
}); | ||
}); |