forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication_config_spec.ts
52 lines (45 loc) · 1.67 KB
/
application_config_spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {ApplicationConfig, InjectionToken, mergeApplicationConfig} from '@angular/core';
describe('ApplicationConfig', () => {
describe('mergeApplicationConfig', () => {
const FOO_TOKEN = new InjectionToken('foo');
const BAR_TOKEN = new InjectionToken('bar');
const BUZ_TOKEN = new InjectionToken('buz');
const BASE_CONFIG: ApplicationConfig = {
providers: [{provide: FOO_TOKEN, useValue: 'foo'}],
};
const APP_CONFIG_EXPECT: ApplicationConfig = {
providers: [
{provide: FOO_TOKEN, useValue: 'foo'},
{provide: BAR_TOKEN, useValue: 'bar'},
{provide: BUZ_TOKEN, useValue: 'buz'},
],
};
it('should merge 2 configs from left to right', () => {
const extraConfig: ApplicationConfig = {
providers: [
{provide: BAR_TOKEN, useValue: 'bar'},
{provide: BUZ_TOKEN, useValue: 'buz'},
],
};
const config = mergeApplicationConfig(BASE_CONFIG, extraConfig);
expect(config).toEqual(APP_CONFIG_EXPECT);
});
it('should merge more than 2 configs from left to right', () => {
const extraConfigOne: ApplicationConfig = {
providers: [{provide: BAR_TOKEN, useValue: 'bar'}],
};
const extraConfigTwo: ApplicationConfig = {
providers: [{provide: BUZ_TOKEN, useValue: 'buz'}],
};
const config = mergeApplicationConfig(BASE_CONFIG, extraConfigOne, extraConfigTwo);
expect(config).toEqual(APP_CONFIG_EXPECT);
});
});
});