Skip to content

Commit

Permalink
chore: Format tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drager committed Mar 13, 2021
1 parent cdb2c31 commit 2476dde
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 34 deletions.
12 changes: 8 additions & 4 deletions test/specs/address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ void main() {

test('should be able to generate city', () {
for (var i = 0; i < 20; i++) {
expect(faker.address.city(), anyOf(matches(r'^[^ ]+ [^ ]+[^]+$'),
matches(r'^[^ ]+ [^ ]+$'), matches(r"^[\w']+[\w]+$")));
expect(
faker.address.city(),
anyOf(matches(r'^[^ ]+ [^ ]+[^]+$'), matches(r'^[^ ]+ [^ ]+$'),
matches(r"^[\w']+[\w]+$")));
}
});

Expand All @@ -32,7 +34,8 @@ void main() {
});

test('should be able to generate street address', () {
expect(faker.address.streetAddress(), matches(RegExp(r'^[^ ]+ [^ ]+ [^ ]+$')));
expect(faker.address.streetAddress(),
matches(RegExp(r'^[^ ]+ [^ ]+ [^ ]+$')));
});

test('should be able to generate street suffix', () {
Expand All @@ -48,7 +51,8 @@ void main() {
});

test('should be able to generate country', () {
expect(faker.address.country(), matches(RegExp(r"^[\w,éÅô\.Ç\-()'^ ]+$")));
expect(
faker.address.country(), matches(RegExp(r"^[\w,éÅô\.Ç\-()'^ ]+$")));
});

test('should be able to generate country code', () {
Expand Down
6 changes: 4 additions & 2 deletions test/specs/company.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ void main() {
group('company', () {
test('should be able to generate name', () {
for (var i = 0; i < 10; i++) {
expect(faker.company.name(), anyOf(matches(r'^[^ ]+ [^ ]$'),
matches(r"^[\w-']+$"), matches(r"^[\w,' ]+[\w ]$")));
expect(
faker.company.name(),
anyOf(matches(r'^[^ ]+ [^ ]$'), matches(r"^[\w-']+$"),
matches(r"^[\w,' ]+[\w ]$")));
}
});

Expand Down
3 changes: 1 addition & 2 deletions test/specs/date.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ void main() {
});

test('should be able to generate a year', () {
expect(
faker.date.year(), matches(RegExp(r'^([0-9]){1,5}( (BC|AD))?$')));
expect(faker.date.year(), matches(RegExp(r'^([0-9]){1,5}( (BC|AD))?$')));
});

test('should be able to generate a time', () {
Expand Down
6 changes: 4 additions & 2 deletions test/specs/guid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import 'package:faker/faker.dart';
void main() {
group('guid', () {
test('should be able to generate a guid', () {
expect(faker.guid.guid(), matches(RegExp(r'^[\da-f]{8}\-[\da-f]{4}\-[\da-f]{4}\-[\da-f]{4}\-[\da-f]{12}$')));

expect(
faker.guid.guid(),
matches(RegExp(
r'^[\da-f]{8}\-[\da-f]{4}\-[\da-f]{4}\-[\da-f]{4}\-[\da-f]{12}$')));
});
});
}
2 changes: 1 addition & 1 deletion test/specs/lorem.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:faker/faker.dart';
import 'package:test/test.dart';

void main() {
group('Lorem', (){
group('Lorem', () {
group('words', () {
test('should be able to generate single word', () {
expect(faker.lorem.word(), matches(RegExp(r'^[\w-^]+$')));
Expand Down
7 changes: 4 additions & 3 deletions test/specs/person.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ void main() {
group('person', () {
test('should be able to generate name', () {
for (var i = 0; i < 20; i++) {
expect(faker.person.name(), anyOf(matches(r'^[^ ]+ [^ ]+$'),
matches(r'^[^ ]+ [^ ]+ [^ ]+$'),
matches(r'^[^ ]+ [^ ]+ [^ ]+ [^ ]+$')));
expect(
faker.person.name(),
anyOf(matches(r'^[^ ]+ [^ ]+$'), matches(r'^[^ ]+ [^ ]+ [^ ]+$'),
matches(r'^[^ ]+ [^ ]+ [^ ]+ [^ ]+$')));
}
});

Expand Down
34 changes: 14 additions & 20 deletions test/specs/seed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,34 @@ void main() {
expect(faker1.address.country(), equals(faker2.address.country()));
expect(faker1.company.name(), equals(faker2.company.name()));
expect(faker1.currency.code(), equals(faker2.currency.code()));
expect(faker1.internet.ipv4Address(), equals(faker2.internet.ipv4Address()));
expect(
faker1.internet.ipv4Address(), equals(faker2.internet.ipv4Address()));
expect(faker1.job.title(), equals(faker2.job.title()));
expect(faker1.person.firstName(), equals(faker2.person.firstName()));
expect(faker1.sport.name(), equals(faker2.sport.name()));

// Generate a random amount of IP v4 addresses (max 10).
expect(
faker1.randomGenerator.amount((_) => faker1.internet.ipv4Address(), 10),
equals(faker2.randomGenerator.amount((_) => faker2.internet.ipv4Address(), 10))
);
faker1.randomGenerator
.amount((_) => faker1.internet.ipv4Address(), 10),
equals(faker2.randomGenerator
.amount((_) => faker2.internet.ipv4Address(), 10)));

// Generate random boolean.
expect(
faker1.randomGenerator.boolean(),
equals(faker2.randomGenerator.boolean())
);
expect(faker1.randomGenerator.boolean(),
equals(faker2.randomGenerator.boolean()));

// Generate random decimal.
expect(
faker1.randomGenerator.decimal(),
equals(faker2.randomGenerator.decimal())
);
expect(faker1.randomGenerator.decimal(),
equals(faker2.randomGenerator.decimal()));

// Generate random DateTime, between the years 2000 and 2020
expect(
faker1.date.dateTime(minYear: 2000, maxYear: 2020),
equals(faker2.date.dateTime(minYear: 2000, maxYear: 2020))
);
expect(faker1.date.dateTime(minYear: 2000, maxYear: 2020),
equals(faker2.date.dateTime(minYear: 2000, maxYear: 2020)));

// Generate random User Agent, with osName iOS
expect(
faker1.internet.userAgent(osName: 'iOS'),
equals(faker2.internet.userAgent(osName: 'iOS'))
);
expect(faker1.internet.userAgent(osName: 'iOS'),
equals(faker2.internet.userAgent(osName: 'iOS')));
});
});
}

0 comments on commit 2476dde

Please sign in to comment.