Skip to content

Commit

Permalink
Field | Added constructor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Minyewoo committed Nov 29, 2023
1 parent cc7b7a9 commit 21ccdbb
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions test/unit/table_schema/field/field_constructor_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import 'package:ext_rw/src/table_schema/field.dart';
import 'package:ext_rw/src/table_schema/relation.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
group('Field constructor', () {
test('sets default values with only required parameters provided', () {
const key = '';
const field = Field(key: key);
expect(field.key, equals(key));
expect(field.name, equals(key));
expect(field.hidden, equals(false));
expect(field.edit, equals(true));
expect(field.relation, equals(const Relation.empty()));
});
test('sets provided values', () {
const valueMaps = [
{
'key': '123af',
'name': 'wejlrk',
'hidden': true,
'edit': true,
'relation': Relation(id: '1', field: '_+-+()*&^%\$;:?№"#@!`~\\|/.,[]{}'),
},
{
'key': '_+-+()*&^%\$;:?№"#@!`~\\|/.,[]{}',
'name': 'WEJLRK',
'hidden': false,
'edit': false,
'relation': Relation(id: '_+-+()*&^%\$;:?№"#@!`~\\|/.,[]{}', field: 'reydfg'),
},
{
'key': 'KJLSDFKJuio)()',
'name': '_+-+()*&^%\$;:?№"#@!`~\\|/.,[]{}',
'hidden': true,
'edit': false,
'relation': Relation.empty(),
},
{
'key': '&^A*23jh4b#@\$%^&',
'name': '&^*(hjl)',
'hidden': false,
'edit': true,
'relation': Relation(id: '235', field: 'dfghew54'),
},
{
'key': '35i4ilj32n',
'name': 'nsewjri',
'hidden': true,
'edit': false,
'relation': Relation(id: '1sgd43', field: 'sdg543'),
},
];
for(final map in valueMaps) {
final {
'key': key,
'name': name,
'hidden': hidden,
'edit': edit,
'relation': relation,
} = map;
final field = Field(
key: key as String,
name: name as String,
hidden: hidden as bool,
edit: edit as bool,
relation: relation as Relation,
);
expect(field.key, equals(key));
expect(field.name, equals(name));
expect(field.hidden, equals(hidden));
expect(field.edit, equals(edit));
expect(field.relation, equals(relation));
}
});
});
}

0 comments on commit 21ccdbb

Please sign in to comment.