mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 03:23:57 +08:00
Functional guards and resolvers were introduced in the Angular router in v14.2. This commit adds the ability to generate functional router guards by specifying `--guardType` instead of `--implements`. These guards are also accompanied by a test that includes a helper function for executing the guard in the `TestBed` environment so that any `inject` calls in the guard will work properly. Functional resolvers are generated by adding the `--functional` flag.
17 lines
441 B
Plaintext
17 lines
441 B
Plaintext
import { TestBed } from '@angular/core/testing';
|
|
|
|
import { <%= classify(name) %>Resolver } from './<%= dasherize(name) %>.resolver';
|
|
|
|
describe('<%= classify(name) %>Resolver', () => {
|
|
let resolver: <%= classify(name) %>Resolver;
|
|
|
|
beforeEach(() => {
|
|
TestBed.configureTestingModule({});
|
|
resolver = TestBed.inject(<%= classify(name) %>Resolver);
|
|
});
|
|
|
|
it('should be created', () => {
|
|
expect(resolver).toBeTruthy();
|
|
});
|
|
});
|