Skip to content

Commit 7585767

Browse files
committed
ngdart: refactoring
1 parent f3c38f6 commit 7585767

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+220
-218
lines changed

_tests/test/compiler/ast_directive_normalizer_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ void main() {
170170
type: CompileTypeMetadata(name: 'A', moduleUrl: 'package:a/a.dart'),
171171
template: CompileTemplateMetadata(
172172
template: '',
173-
encapsulation: ViewEncapsulation.Emulated,
173+
encapsulation: ViewEncapsulation.emulated,
174174
),
175175
);
176176
metadata = await normalizer.normalizeDirective(metadata);
177-
expect(metadata.template.encapsulation, ViewEncapsulation.None);
177+
expect(metadata.template.encapsulation, ViewEncapsulation.none);
178178
});
179179

180180
test('should resolve inline stylesheets', () async {
@@ -205,7 +205,7 @@ void main() {
205205
),
206206
);
207207
metadata = await normalizer.normalizeDirective(metadata);
208-
expect(metadata.template.encapsulation, ViewEncapsulation.Emulated);
208+
expect(metadata.template.encapsulation, ViewEncapsulation.emulated);
209209
expect(
210210
metadata.template.styles,
211211
[

_tests/test/compiler_integration/invalid_change_detection_link_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void main() {
1919
@Component(
2020
selector: 'test',
2121
template: '',
22-
changeDetection: ChangeDetectionStrategy.OnPush,
22+
changeDetection: ChangeDetectionStrategy.onPush,
2323
)
2424
class OnPushComponent {}
2525
""");
@@ -39,7 +39,7 @@ void main() {
3939
""", errors: [
4040
allOf([
4141
contains(
42-
'Only supported on components that use "OnPush" change detection',
42+
'Only supported on components that use "onPush" change detection',
4343
),
4444
containsSourceLocation(4, 9),
4545
]),
@@ -57,7 +57,7 @@ void main() {
5757
""", errors: [
5858
allOf([
5959
contains(
60-
'Only supported on components that use "OnPush" change detection',
60+
'Only supported on components that use "onPush" change detection',
6161
),
6262
containsSourceLocation(4, 9),
6363
]),

_tests/test/compiler_integration/on_push_validation_test.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:ngcompiler/v2/context.dart';
77
void main() {
88
CompileContext.overrideForTesting();
99

10-
test('emits warning for Default component in OnPush template', () async {
10+
test('emits warning for Default component in onPush template', () async {
1111
await compilesExpecting("""
1212
import '$ngImport';
1313
@@ -24,22 +24,22 @@ void main() {
2424
<default></default>
2525
</div>
2626
''',
27-
changeDetection: ChangeDetectionStrategy.OnPush,
27+
changeDetection: ChangeDetectionStrategy.onPush,
2828
directives: [DefaultComponent],
2929
)
3030
class TestComponent {}
3131
""", warnings: [
3232
allOf([
3333
contains('<default>'),
3434
contains(
35-
'"DefaultComponent" doesn\'t use "ChangeDetectionStrategy.OnPush"',
35+
'"DefaultComponent" doesn\'t use "ChangeDetectionStrategy.onPush"',
3636
),
3737
]),
3838
]);
3939
});
4040

4141
group('@skipOnPushValidation', () {
42-
test('silences warning for Default component in OnPush template', () async {
42+
test('silences warning for Default component in onPush template', () async {
4343
await compilesNormally("""
4444
import '$ngImport';
4545
@@ -56,7 +56,7 @@ void main() {
5656
<default @skipOnPushValidation></default>
5757
</div>
5858
''',
59-
changeDetection: ChangeDetectionStrategy.OnPush,
59+
changeDetection: ChangeDetectionStrategy.onPush,
6060
directives: [DefaultComponent],
6161
)
6262
class TestComponent {}
@@ -73,7 +73,7 @@ void main() {
7373
template: '''
7474
<div @skipOnPushValidation></div>
7575
''',
76-
changeDetection: ChangeDetectionStrategy.OnPush,
76+
changeDetection: ChangeDetectionStrategy.onPush,
7777
)
7878
class TestComponent {}
7979
""", errors: [
@@ -91,7 +91,7 @@ void main() {
9191
@Component(
9292
selector: 'on-push',
9393
template: '',
94-
changeDetection: ChangeDetectionStrategy.OnPush,
94+
changeDetection: ChangeDetectionStrategy.onPush,
9595
)
9696
class OnPushComponent {}
9797
@@ -101,15 +101,15 @@ void main() {
101101
<on-push @skipOnPushValidation></on-push>
102102
''',
103103
directives: [OnPushComponent],
104-
changeDetection: ChangeDetectionStrategy.OnPush,
104+
changeDetection: ChangeDetectionStrategy.onPush,
105105
)
106106
class TestComponent {}
107107
""", errors: [
108108
allOf([
109109
contains('@skipOnPushValidation'),
110110
contains(
111111
'Can only be applied to a component using '
112-
'"ChangeDetectionStrategy.Default"',
112+
'"ChangeDetectionStrategy.default_"',
113113
),
114114
]),
115115
]);
@@ -138,7 +138,7 @@ void main() {
138138
contains('@skipOnPushValidation'),
139139
contains(
140140
'Can only be used in the template of a component using '
141-
'"ChangeDetectionStrategy.OnPush"',
141+
'"ChangeDetectionStrategy.onPush"',
142142
),
143143
]),
144144
]);

_tests/test/core/change_detection/change_detection_link_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class DefaultComponent {
110110
@Component(
111111
selector: 'on-push-container',
112112
template: '<template #container></template>',
113-
changeDetection: ChangeDetectionStrategy.OnPush,
113+
changeDetection: ChangeDetectionStrategy.onPush,
114114
)
115115
class OnPushContainerComponent {
116116
@Input()
@@ -142,7 +142,7 @@ class LoadInOnPush {
142142
</on-push-container>
143143
''',
144144
directives: [OnPushContainerComponent],
145-
changeDetection: ChangeDetectionStrategy.OnPush,
145+
changeDetection: ChangeDetectionStrategy.onPush,
146146
)
147147
class OnPushAncestorComponent {
148148
@Input()
@@ -170,7 +170,7 @@ class LoadInOnPushDescendant {
170170
</ng-container>
171171
''',
172172
directives: [NgIf],
173-
changeDetection: ChangeDetectionStrategy.OnPush,
173+
changeDetection: ChangeDetectionStrategy.onPush,
174174
)
175175
class OnPushEmbeddedContainerComponent {
176176
OnPushEmbeddedContainerComponent(this._changeDetectorRef, this._ngZone);

_tests/test/core/change_detection/detached_lifecycle_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void main() {
1111

1212
setUp(() => logs = []);
1313

14-
test('ChangeDetectionStrategy.Detached should behave strangely', () async {
14+
test('ChangeDetectionStrategy.detached should behave strangely', () async {
1515
final testBed = NgTestBed<TestDetachedViaStrategy>(
1616
ng.createTestDetachedViaStrategyFactory(),
1717
);
@@ -214,7 +214,7 @@ class Logger implements OnInit, AfterChanges, AfterViewInit, AfterContentInit {
214214
</span>
215215
''',
216216
// ignore: deprecated_member_use
217-
changeDetection: ChangeDetectionStrategy.Detached,
217+
changeDetection: ChangeDetectionStrategy.detached,
218218
)
219219
class DetachedViaStrategy extends Logger {}
220220

_tests/test/core/change_detection/mark_child_for_check_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void main() {
109109
@Component(
110110
selector: 'child',
111111
template: '{{value}}',
112-
changeDetection: ChangeDetectionStrategy.OnPush,
112+
changeDetection: ChangeDetectionStrategy.onPush,
113113
)
114114
class Child {
115115
var value = '';
@@ -245,7 +245,7 @@ abstract class HasValue {
245245
providers: [
246246
ExistingProvider(HasValue, ChildWithExistingProvider),
247247
],
248-
changeDetection: ChangeDetectionStrategy.OnPush,
248+
changeDetection: ChangeDetectionStrategy.onPush,
249249
)
250250
class ChildWithExistingProvider implements HasValue {
251251
@override

_tests/test/core/change_detection/mark_for_check_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class UsesOnPushComponent {
7676
directives: [
7777
NgIf,
7878
],
79-
changeDetection: ChangeDetectionStrategy.OnPush,
79+
changeDetection: ChangeDetectionStrategy.onPush,
8080
)
8181
class OnPushComponent {
8282
final ChangeDetectorRef _changeDetector;

_tests/test/core/change_detection/on_push_embedded_view_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ void main() {
2323
// When these parents are the same, embedded views are well behaved.
2424
//
2525
// However, when an embedded view is hosted in the view container of another
26-
// OnPush view, it may cease to correctly receive updates from its
26+
// onPush view, it may cease to correctly receive updates from its
2727
// `<template>` parent.
2828
//
29-
// When embedded within an OnPush component, an embedded view is only change
29+
// When embedded within an onPush component, an embedded view is only change
3030
// detected when that parent is marked to be checked. This poses a problem for
3131
// embedded views with expressions bound to their `<template>` parent. When
32-
// such an embedded view is hosted in the view container of another OnPush
32+
// such an embedded view is hosted in the view container of another onPush
3333
// component, there's currently no mechanism in the framework that marks that
3434
// component to be checked when the `<template>` parent receives a change that
3535
// could invalidate a binding within the `<template>`.
@@ -65,7 +65,7 @@ void main() {
6565

6666
// The above change only causes the template producer and its child nested
6767
// views to be updated. Any templates that originated within its view that
68-
// are embedded in a foreign OnPush view don't receive these changes.
68+
// are embedded in a foreign onPush view don't receive these changes.
6969
expect(
7070
component.templateConsumer!.text,
7171
contains('Hello template!'),
@@ -77,7 +77,7 @@ void main() {
7777
});
7878

7979
// The above change that was previously expected is now observed in the
80-
// template embedded in a foreign view container with an OnPush parent.
80+
// template embedded in a foreign view container with an onPush parent.
8181
expect(
8282
component.templateConsumer!.text,
8383
contains('Hello template!'),
@@ -124,7 +124,7 @@ class TestComponent {
124124
template: '''
125125
<template #template>{{templateText}}</template>
126126
''',
127-
changeDetection: ChangeDetectionStrategy.OnPush,
127+
changeDetection: ChangeDetectionStrategy.onPush,
128128
exportAs: 'templateProducer',
129129
)
130130
class TemplateProducerComponent implements OnInit {
@@ -149,7 +149,7 @@ class TemplateProducerComponent implements OnInit {
149149
<template #container></template>
150150
<div>{{text}}</div>
151151
''',
152-
changeDetection: ChangeDetectionStrategy.OnPush,
152+
changeDetection: ChangeDetectionStrategy.onPush,
153153
)
154154
class TemplateConsumerComponent implements OnInit {
155155
@ViewChild('container', read: ViewContainerRef)

_tests/test/core/linker/component_loader_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ class DynamicComp extends Lifecycles {
317317
@Component(
318318
selector: 'dynamic-comp',
319319
template: 'Dynamic{{input}}',
320-
changeDetection: ChangeDetectionStrategy.OnPush,
320+
changeDetection: ChangeDetectionStrategy.onPush,
321321
)
322322
class DynamicOnPushComp extends Lifecycles {
323323
DynamicOnPushComp(super.log);

_tests/test/core/linker/integration/on_push_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void main() {
9999

100100
@Component(
101101
selector: 'push-cmp-with-ref',
102-
changeDetection: ChangeDetectionStrategy.OnPush,
102+
changeDetection: ChangeDetectionStrategy.onPush,
103103
template: '{{field}}',
104104
)
105105
class PushCmpWithRef {
@@ -150,15 +150,15 @@ class ManualCheckLoadedComponent {
150150
@Component(
151151
selector: 'event-cmp',
152152
template: '<div (click)="noop()"></div>',
153-
changeDetection: ChangeDetectionStrategy.OnPush,
153+
changeDetection: ChangeDetectionStrategy.onPush,
154154
)
155155
class EventCmp {
156156
void noop() {}
157157
}
158158

159159
@Component(
160160
selector: 'push-cmp',
161-
changeDetection: ChangeDetectionStrategy.OnPush,
161+
changeDetection: ChangeDetectionStrategy.onPush,
162162
template: '{{field}}<div (click)="noop()"></div><div *ngIf="true" '
163163
'(click)="noop()"></div><event-cmp></event-cmp>',
164164
directives: [EventCmp, NgIf],
@@ -203,7 +203,7 @@ class PushCmpWithRefHostComponent {
203203

204204
@Component(
205205
selector: 'push-cmp-with-async',
206-
changeDetection: ChangeDetectionStrategy.OnPush,
206+
changeDetection: ChangeDetectionStrategy.onPush,
207207
template: r'{{$pipe.async(field)}}',
208208
pipes: [AsyncPipe],
209209
)

0 commit comments

Comments
 (0)