@schematics/angular 15.1.0-next.0 → 15.1.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,3 @@
1
- import { EnvironmentInjector } from '@angular/core';
2
1
  import { TestBed } from '@angular/core/testing';
3
2
  import { <%= guardType %> } from '@angular/router';
4
3
 
@@ -6,13 +5,13 @@ import { <%= camelize(name) %>Guard } from './<%= dasherize(name) %>.guard';
6
5
 
7
6
  describe('<%= camelize(name) %>Guard', () => {
8
7
  const executeGuard: <%= guardType %> = (...guardParameters) =>
9
- TestBed.inject(EnvironmentInjector).runInContext(() => <%= camelize(name) %>Guard(...guardParameters));
8
+ TestBed.runInInjectionContext(() => <%= camelize(name) %>Guard(...guardParameters));
10
9
 
11
10
  beforeEach(() => {
12
11
  TestBed.configureTestingModule({});
13
12
  });
14
13
 
15
14
  it('should be created', () => {
16
- expect(<%= camelize(name) %>Guard).toBeTruthy();
15
+ expect(executeGuard).toBeTruthy();
17
16
  });
18
17
  });
@@ -0,0 +1,16 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { <%= camelize(name) %>Interceptor } from './<%= dasherize(name) %>.interceptor';
4
+
5
+ describe('<%= camelize(name) %>Interceptor', () => {
6
+ const interceptor: HttpInterceptorFn = (req, next) =>
7
+ TestBed.runInInjectionContext(() => <%= camelize(name) %>Interceptor(req, next));
8
+
9
+ beforeEach(() => {
10
+ TestBed.configureTestingModule({});
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(interceptor).toBeTruthy();
15
+ });
16
+ });
@@ -0,0 +1,5 @@
1
+ import { HttpInterceptorFn } from '@angular/common/http';
2
+
3
+ export const <%= camelize(name) %>Interceptor: HttpInterceptorFn = (req, next) => {
4
+ return next(req);
5
+ }
@@ -12,8 +12,11 @@ function default_1(options) {
12
12
  // This schematic uses an older method to implement the flat option
13
13
  const flat = options.flat;
14
14
  options.flat = true;
15
- return (0, generate_from_files_1.generateFromFiles)(options, {
15
+ const extraTemplateValues = {
16
16
  'if-flat': (s) => (flat ? '' : s),
17
- });
17
+ };
18
+ return options.functional
19
+ ? (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory: './functional-files' }, extraTemplateValues)
20
+ : (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory: './class-files' }, extraTemplateValues);
18
21
  }
19
22
  exports.default = default_1;
@@ -6,6 +6,10 @@ export interface Schema {
6
6
  * When true (the default), creates files at the top level of the project.
7
7
  */
8
8
  flat?: boolean;
9
+ /**
10
+ * Creates the interceptor as a `HttpInterceptorFn`.
11
+ */
12
+ functional?: boolean;
9
13
  /**
10
14
  * The name of the interceptor.
11
15
  */
@@ -40,6 +40,11 @@
40
40
  "type": "boolean",
41
41
  "description": "Do not create \"spec.ts\" test files for the new interceptor.",
42
42
  "default": false
43
+ },
44
+ "functional": {
45
+ "type": "boolean",
46
+ "description": "Creates the interceptor as a `HttpInterceptorFn`.",
47
+ "default": false
43
48
  }
44
49
  },
45
50
  "required": ["name", "project"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematics/angular",
3
- "version": "15.1.0-next.0",
3
+ "version": "15.1.0-next.1",
4
4
  "description": "Schematics specific to Angular",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "keywords": [
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "schematics": "./collection.json",
25
25
  "dependencies": {
26
- "@angular-devkit/core": "15.1.0-next.0",
27
- "@angular-devkit/schematics": "15.1.0-next.0",
26
+ "@angular-devkit/core": "15.1.0-next.1",
27
+ "@angular-devkit/schematics": "15.1.0-next.1",
28
28
  "jsonc-parser": "3.2.0"
29
29
  },
30
30
  "repository": {
@@ -5,13 +5,13 @@ import { <%= camelize(name) %>Resolver } from './<%= dasherize(name) %>.resolver
5
5
 
6
6
  describe('<%= camelize(name) %>Resolver', () => {
7
7
  const executeResolver: ResolveFn<boolean> = (...resolverParameters) =>
8
- TestBed.inject(EnvironmentInjector).runInContext(() => <%= camelize(name) %>Resolver(...resolverParameters));
8
+ TestBed.runInInjectionContext(() => <%= camelize(name) %>Resolver(...resolverParameters));
9
9
 
10
10
  beforeEach(() => {
11
11
  TestBed.configureTestingModule({});
12
12
  });
13
13
 
14
14
  it('should be created', () => {
15
- expect(resolver).toBeTruthy();
15
+ expect(executeResolver).toBeTruthy();
16
16
  });
17
17
  });