Skip to content

Commit

Permalink
fix: omit apostrophe (#3)
Browse files Browse the repository at this point in the history
* feat: add pubspec override to get from path

* refactor: add appostraphe to ignore chars when stripping non alpha chars

* feat: add e2e test

* feat: update package description

* feat: bump version and add to changelog
  • Loading branch information
mrgnhnt96 authored Jan 6, 2023
1 parent 2b0b9d3 commit bf3ab80
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 7 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.1.0

- Ignore apostrophes when stripping non-alphanumeric characters
- Add some e2e tests

# 1.0.2

- Update dependencies (minor)
Expand All @@ -15,7 +20,7 @@
# 1.0.0+2

- Add example

# 1.0.0+1

- Update links to github
Expand Down
3 changes: 3 additions & 0 deletions example/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependency_overrides:
change_case:
path: ../
4 changes: 2 additions & 2 deletions lib/src/change_case_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ChangeCaseConfig {
];

/// ```dart
/// RegExp('[^A-Z0-9]+', caseSensitive: false)
/// RegExp('[^A-Z0-9']+', caseSensitive: false)
/// ```
///
/// _matches any non-alphanumeric char_
Expand All @@ -95,7 +95,7 @@ class ChangeCaseConfig {
/// - camelCase
/// - PascalCase
static final removeNonAlphaPattern =
RegExp('[^A-Z0-9]+', caseSensitive: false);
RegExp("[^A-Z0-9']+", caseSensitive: false);

/// ```dart
/// RegExp('([a-z])([A-Z0-9])')
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: change_case
description: An extension on String to transform a string between camelCase, PascalCase, Capital Case, snake_case, param-case, CONSTANT_CASE and others.
version: 1.0.2
description: An extension on String for the missing methods for camelCase, PascalCase, Capital Case, snake_case, param-case, CONSTANT_CASE and others.
version: 1.1.0
repository: https://github.com/mrgnhnt96/change_case
homepage: https://github.com/mrgnhnt96/change_case

Expand Down
47 changes: 47 additions & 0 deletions test/e2e/e2e_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:change_case/change_case.dart';
import 'package:test/test.dart';

void main() {
test('Title Case', () {
final tests = <String, String>{
"WE'RE ALMOST HERE": "WE'RE ALMOST HERE",
"we're almost here": "We're Almost Here",
'test string': 'Test String',
'Test String': 'Test String',
'testString': 'testString',
'tEst stRing': 'tEst stRing',
};

for (final entry in tests.entries) {
expect(entry.key.toTitleCase(), entry.value);
}
});

test('No Case', () {
final tests = <String, String>{
"WE'RE ALMOST HERE": "we're almost here",
'test string': 'test string',
'Test String': 'test string',
'testString': 'test string',
'tEst stRing': 't est st ring',
};

for (final entry in tests.entries) {
expect(entry.key.toNoCase(), entry.value);
}
});

test('No case to Title case', () {
final tests = <String, String>{
"WE'RE ALMOST HERE": "We're Almost Here",
'test string': 'Test String',
'Test String': 'Test String',
'testString': 'Test String',
'tEst stRing': 'T Est St Ring',
};

for (final entry in tests.entries) {
expect(entry.key.toNoCase().toTitleCase(), entry.value);
}
});
}
2 changes: 1 addition & 1 deletion test/src/change_case_config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void main() {
});

group('strip patterns', () {
final removeNonAlphaPattern = RegExp('[^A-Z0-9]+', caseSensitive: false);
final removeNonAlphaPattern = RegExp("[^A-Z0-9']+", caseSensitive: false);
final lowerToNumOrUpperPattern = RegExp('([a-z])([A-Z0-9])');

test('#removeNonAlphaPattern', () {
Expand Down
2 changes: 1 addition & 1 deletion test/src/change_case_helper_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void main() {
});

test('should remove non alphanumeric', () {
const string = '!@#\$%^&*()_+-=[]{}|;\':",./<>?';
const string = r'!@#\$%^&*()_+-=[]{}|;:",./<>?';
final result = helper.stripString(string);

expect(result, ph);
Expand Down

0 comments on commit bf3ab80

Please sign in to comment.