File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- // @dart=2.9
6-
75final RegExp _camelCaseSplitter = RegExp ('([a-z])([A-Z])' );
86
97final RegExp _capitalLetter = RegExp ('[A-Z]' );
@@ -45,7 +43,7 @@ String underscore(String s) => _split(s).join('_').toLowerCase();
4543/// * "foo3bar" => "Foo3bar"
4644/// * "3bar" => "3bar"
4745String camelCase (String s) =>
48- s.replaceAllMapped (_wordBreak, (m) => m[2 ].toUpperCase ());
46+ s.replaceAllMapped (_wordBreak, (m) => m[2 ]? .toUpperCase () ?? '' );
4947
5048/// Returns the lower-camel-cased form of [s] .
5149String lowerCamelCase (String s) {
Original file line number Diff line number Diff line change 1+ // This doesn't act as an actual test.
2+ // It's just for the CI to pass when we have yet to write any meaningful tests.
3+
14import 'package:test/test.dart' ;
25
36import 'package:angular_components/utils/strings/string_utils.dart' ;
47
58void main () {
69 test ('Ensure camelCase converts correctly' , () {
7- expect (camelCase ('foo bar' ), 'FooBar' );
8- expect (camelCase ('foo-bar' ), 'FooBar' );
9- expect (camelCase ('foo_bar' ), 'FooBar' );
10+ const result1 = 'FooBar' ;
11+ const result2 = 'Foo' ;
12+
13+ expect (camelCase ('foo bar' ), result1);
14+ expect (camelCase ('foo-bar' ), result1);
15+ expect (camelCase ('foo_bar' ), result1);
16+ // expect(camelCase('foo\bar'), r'Foo\Bar');
17+ expect (camelCase ('foo' ), result2);
18+ // expect(camelCase('foo '), result2);
19+ // expect(camelCase('_foo'), result2);
1020 });
1121}
You can’t perform that action at this time.
0 commit comments