Skip to content

Commit

Permalink
Merge branch 'master' into Schema-read/write
Browse files Browse the repository at this point in the history
  • Loading branch information
a-givertzman authored Dec 25, 2023
2 parents 7f06331 + a7ca577 commit 288ebb5
Show file tree
Hide file tree
Showing 7 changed files with 451 additions and 129 deletions.
50 changes: 0 additions & 50 deletions test/unit/auth/user_login/user_login_validate_message_test.dart

This file was deleted.

64 changes: 0 additions & 64 deletions test/unit/auth/user_login/user_login_validate_regex_test.dart

This file was deleted.

15 changes: 0 additions & 15 deletions test/unit/auth/user_login/user_login_value_test.dart

This file was deleted.

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 = '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));
}
});
});
}
124 changes: 124 additions & 0 deletions test/unit/table_schema/field_value/field_value_constructor_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import 'package:ext_rw/src/table_schema/field_value.dart';
import 'package:flutter_test/flutter_test.dart';

class _TestObject {
const _TestObject();
}

void main() {
group('FieldValue constructor', () {
test('sets default values with only required parameters provided', () {
const values = [3456, 0, -124 -2345.56, 0.0, 234111.0, 'abc', '', true, _TestObject()];
for(final value in values) {
final fieldValue = FieldValue(value);
expect(fieldValue.value, equals(value));
expect(fieldValue.type, equals(FieldType.string));
}
});
test('sets provided arguments', () {
const valueMaps = [
{
'value': '_+-+()*&^%\$;:?№"#@!`~\\|/.,[]{}',
'type': FieldType.string,
},
{
'value': '_+-+()*&^%\$;:?№"#@!`~\\|/.,[]{}',
'type': FieldType.int,
},
{
'value': '_+-+()*&^%\$;:?№"#@!`~\\|/.,[]{}',
'type': FieldType.double,
},
{
'value': '_+-+()*&^%\$;:?№"#@!`~\\|/.,[]{}',
'type': FieldType.bool,
},
{
'value': 123,
'type': FieldType.string,
},
{
'value': 123,
'type': FieldType.int,
},
{
'value': 123,
'type': FieldType.double,
},
{
'value': 123,
'type': FieldType.bool,
},
{
'value': 321.321,
'type': FieldType.string,
},
{
'value': 321.321,
'type': FieldType.int,
},
{
'value': 321.321,
'type': FieldType.double,
},
{
'value': 321.321,
'type': FieldType.bool,
},
{
'value': false,
'type': FieldType.string,
},
{
'value': false,
'type': FieldType.int,
},
{
'value': false,
'type': FieldType.double,
},
{
'value': false,
'type': FieldType.bool,
},
{
'value': null,
'type': FieldType.string,
},
{
'value': null,
'type': FieldType.int,
},
{
'value': null,
'type': FieldType.double,
},
{
'value': null,
'type': FieldType.bool,
},
{
'value': _TestObject(),
'type': FieldType.string,
},
{
'value': _TestObject(),
'type': FieldType.int,
},
{
'value': _TestObject(),
'type': FieldType.double,
},
{
'value': _TestObject(),
'type': FieldType.bool,
},
];
for(final {'value': value, 'type': type as FieldType} in valueMaps) {
final fieldValue = FieldValue(value, type: type);
expect(fieldValue.value, equals(value));
expect(fieldValue.type, equals(type));
}
});
});
}
Loading

0 comments on commit 288ebb5

Please sign in to comment.