diff --git a/lib/src/locales/en_us/en_us.dart b/lib/src/locales/en_us/en_us.dart index fd3ce78..3c1ecbc 100644 --- a/lib/src/locales/en_us/en_us.dart +++ b/lib/src/locales/en_us/en_us.dart @@ -98,13 +98,15 @@ class EnUsLorem extends Lorem { EnUsLorem(this.locale) : super(locale); String paragraph({ - int maxSentences = 1, + int maxSentences = 3, + int minSentences = 1, }) => provide( DataKeys.paragraph, locale, args: lorem_536.ParagraphArgs( maxSentences: maxSentences, + minSentences: minSentences, ), ); } diff --git a/lib/src/locales/fa_ir/fa_ir.dart b/lib/src/locales/fa_ir/fa_ir.dart index 003144c..f7af892 100644 --- a/lib/src/locales/fa_ir/fa_ir.dart +++ b/lib/src/locales/fa_ir/fa_ir.dart @@ -88,13 +88,15 @@ class FaIrLorem extends Lorem { FaIrLorem(this.locale) : super(locale); String paragraph({ - int maxSentences = 1, + int maxSentences = 3, + int minSentences = 1, }) => provide( DataKeys.paragraph, locale, args: lorem_536.ParagraphArgs( maxSentences: maxSentences, + minSentences: minSentences, ), ); } diff --git a/lib/src/locales/global/datasources/lorem.dart b/lib/src/locales/global/datasources/lorem.dart index 349d0d6..6b848cf 100644 --- a/lib/src/locales/global/datasources/lorem.dart +++ b/lib/src/locales/global/datasources/lorem.dart @@ -2,18 +2,22 @@ import 'package:faker_x/src/base/base.dart'; class ParagraphArgs { final int maxSentences; + final int minSentences; - ParagraphArgs({this.maxSentences = 1}); + ParagraphArgs({this.maxSentences = 3, this.minSentences = 1}); } final paragraph = StringDataSource.withBuilder( dataKey: DataKeys.paragraph, locale: Locales.en_us, builder: (ParagraphArgs args, FakerXLocale locale) { - final sentenceCount = randomInt(args.maxSentences); - return List.generate( + final sentenceCount = randomInt(args.maxSentences, min: args.minSentences); + + final sentences = List.generate( sentenceCount, (_) => provide(DataKeys.sentence, locale), - ).join('. '); + ); + + return sentences.join(' '); }, ); diff --git a/test/manual/en_us/paragraph_test.dart b/test/manual/en_us/paragraph_test.dart index 32c615a..8bccfc8 100644 --- a/test/manual/en_us/paragraph_test.dart +++ b/test/manual/en_us/paragraph_test.dart @@ -7,6 +7,8 @@ import '../../utils.dart'; void main() { test("en_us -> lorem -> paragraph test", () async { - // TODO: please write test manually to test FakerX.localized.en_us.lorem.paragraph(args) + for (var i = 0; i < testRepeatCount; i++) { + assertFakeValue(FakerX.localized.en_us.lorem.paragraph(maxSentences: 4)); + } }); } diff --git a/test/manual/fa_ir/paragraph_test.dart b/test/manual/fa_ir/paragraph_test.dart index 306e065..1f8c979 100644 --- a/test/manual/fa_ir/paragraph_test.dart +++ b/test/manual/fa_ir/paragraph_test.dart @@ -7,6 +7,9 @@ import '../../utils.dart'; void main() { test("fa_ir -> lorem -> paragraph test", () async { - // TODO: please write test manually to test FakerX.localized.fa_ir.lorem.paragraph(args) + for (var i = 0; i < testRepeatCount; i++) { + final sentence = FakerX.localized.fa_ir.lorem.sentence; + assertFakeValue(FakerX.localized.fa_ir.lorem.paragraph(maxSentences: 4)); + } }); } diff --git a/test/utils.dart b/test/utils.dart index 96a0731..a865558 100644 --- a/test/utils.dart +++ b/test/utils.dart @@ -2,7 +2,7 @@ import 'package:faker_x/src/base/utils.dart'; import 'package:test/expect.dart'; -const testRepeatCount = 10000; +const testRepeatCount = 1; void assertFakeValue(dynamic value) { expect(value, isNotNull);