Files
apidash/test/models/name_value_model_test.dart
2024-01-08 00:17:48 +05:30

31 lines
903 B
Dart

import 'package:test/test.dart';
import 'package:apidash/models/name_value_model.dart';
void main() {
const nmRow1 = NameValueModel(name: "harry", value: 23);
test('Testing toString()', () {
const resultExpected = 'NameValueModel(name: harry, value: 23)';
expect(nmRow1.toString(), resultExpected);
});
test('Testing toJson()', () {
const resultExpected = {"name": "harry", "value": 23};
expect(nmRow1.toJson(), resultExpected);
});
test('Testing fromJson()', () {
const resultExpected = nmRow1;
expect(NameValueModel.fromJson({"name": "harry", "value": 23}),
resultExpected);
});
test('Testing copyWith()', () {
const resultExpected = NameValueModel(name: "winter", value: "26");
expect(nmRow1.copyWith(name: "winter", value: "26"), resultExpected);
});
test('Testing hashcode', () {
expect(nmRow1.hashCode, greaterThan(0));
});
}