forked from eatvio/eatvio_app
48 lines
1.3 KiB
Dart
48 lines
1.3 KiB
Dart
import 'package:eatvio_app/features/complaining/models/complain_model.dart';
|
||
import 'package:flutter_test/flutter_test.dart';
|
||
|
||
void main() {
|
||
group('ComplainModel', () {
|
||
test('создает экземпляр с дефолтными значениями', () {
|
||
const model = ComplainModel();
|
||
|
||
expect(model.description, null);
|
||
expect(model.tags, []);
|
||
});
|
||
|
||
test('создает экземпляр с description и tags', () {
|
||
const model = ComplainModel(
|
||
description: 'Test description',
|
||
tags: ['tag1', 'tag2'],
|
||
);
|
||
|
||
expect(model.description, 'Test description');
|
||
expect(model.tags, ['tag1', 'tag2']);
|
||
});
|
||
|
||
test('fromJson создает модель из JSON', () {
|
||
final json = {
|
||
'description': 'Test description',
|
||
'tags': ['tag1', 'tag2'],
|
||
};
|
||
|
||
final model = ComplainModel.fromJson(json);
|
||
|
||
expect(model.description, 'Test description');
|
||
expect(model.tags, ['tag1', 'tag2']);
|
||
});
|
||
|
||
test('toJson преобразует модель в JSON', () {
|
||
const model = ComplainModel(
|
||
description: 'Test description',
|
||
tags: ['tag1', 'tag2'],
|
||
);
|
||
|
||
final json = model.toJson();
|
||
|
||
expect(json['description'], 'Test description');
|
||
expect(json['tags'], ['tag1', 'tag2']);
|
||
});
|
||
});
|
||
}
|