@@ -11,7 +11,7 @@ import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeBuilder } from '../setup';
11
11
12
12
describeBuilder ( execute , KARMA_BUILDER_INFO , ( harness ) => {
13
13
describe ( 'Option: "styles"' , ( ) => {
14
- it ( 'includes unnamed styles in compilation' , async ( ) => {
14
+ it ( `processes ' styles.css' styles` , async ( ) => {
15
15
await harness . writeFiles ( {
16
16
'src/styles.css' : 'p {display: none}' ,
17
17
'src/app/app.component.ts' : `
@@ -54,5 +54,80 @@ describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
54
54
const { result } = await harness . executeOnce ( ) ;
55
55
expect ( result ?. success ) . toBeTrue ( ) ;
56
56
} ) ;
57
+
58
+ it ( 'processes style with bundleName' , async ( ) => {
59
+ await harness . writeFiles ( {
60
+ 'src/dark-theme.css' : '' ,
61
+ 'src/app/app.module.ts' : `
62
+ import { BrowserModule } from '@angular/platform-browser';
63
+ import { NgModule } from '@angular/core';
64
+ import { HttpClientModule } from '@angular/common/http';
65
+ import { AppComponent } from './app.component';
66
+ @NgModule({
67
+ declarations: [
68
+ AppComponent
69
+ ],
70
+ imports: [
71
+ BrowserModule,
72
+ HttpClientModule
73
+ ],
74
+ providers: [],
75
+ bootstrap: [AppComponent]
76
+ })
77
+ export class AppModule { }
78
+ ` ,
79
+ 'src/app/app.component.ts' : `
80
+ import { Component } from '@angular/core';
81
+ import { HttpClient } from '@angular/common/http';
82
+ @Component({
83
+ selector: 'app-root',
84
+ template: '<p *ngFor="let asset of css">{{ asset.content }}</p>'
85
+ })
86
+ export class AppComponent {
87
+ public assets = [
88
+ { path: './dark-theme.css', content: '' },
89
+ ];
90
+ constructor(private http: HttpClient) {
91
+ this.assets.forEach(asset => http.get(asset.path, { responseType: 'text' })
92
+ .subscribe(res => asset.content = res));
93
+ }
94
+ }` ,
95
+ 'src/app/app.component.spec.ts' : `
96
+ import { TestBed } from '@angular/core/testing';
97
+ import { HttpClientModule } from '@angular/common/http';
98
+ import { AppComponent } from './app.component';
99
+ describe('AppComponent', () => {
100
+ beforeEach(async () => {
101
+ await TestBed.configureTestingModule({
102
+ imports: [
103
+ HttpClientModule
104
+ ],
105
+ declarations: [
106
+ AppComponent
107
+ ]
108
+ }).compileComponents();
109
+ });
110
+ it('should create the app', () => {
111
+ const fixture = TestBed.createComponent(AppComponent);
112
+ const app = fixture.debugElement.componentInstance;
113
+ expect(app).toBeTruthy();
114
+ });
115
+ });` ,
116
+ } ) ;
117
+
118
+ harness . useTarget ( 'test' , {
119
+ ...BASE_OPTIONS ,
120
+ styles : [
121
+ {
122
+ inject : false ,
123
+ input : 'src/dark-theme.css' ,
124
+ bundleName : 'dark-theme' ,
125
+ } ,
126
+ ] ,
127
+ } ) ;
128
+
129
+ const { result } = await harness . executeOnce ( ) ;
130
+ expect ( result ?. success ) . toBeTrue ( ) ;
131
+ } ) ;
57
132
} ) ;
58
133
} ) ;
0 commit comments