Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel committed Oct 16, 2024
1 parent 7b05393 commit 1316d20
Showing 1 changed file with 96 additions and 96 deletions.
192 changes: 96 additions & 96 deletions test/equatable_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -721,102 +721,102 @@ void main() {
});
});

group('List Equatable', () {
test('should return when values are same', () {
final instanceA = SimpleEquatable(['A', 'B']);
final instanceB = SimpleEquatable(['A', 'B']);
expect(instanceA == instanceB, true);
expect(instanceA.hashCode == instanceB.hashCode, true);
});

test('should return when values are different', () {
final instanceA = SimpleEquatable(['A', 'B']);
final instanceB = SimpleEquatable(['a', 'b']);
expect(instanceA != instanceB, true);
expect(instanceA.hashCode != instanceB.hashCode, true);
});

test('should return when values are different', () {
final instanceA = SimpleEquatable(['A', 'B']);
final instanceB = SimpleEquatable(['C', 'D']);
expect(instanceA != instanceB, true);
expect(instanceA.hashCode != instanceB.hashCode, true);
});

test('should return when contents are same but different kind of List',
() {
final instanceA = SimpleEquatable<List<String>>(
CustomList<String>(['A', 'B'], growable: true),
);
final instanceB = SimpleEquatable<List<String>>(['A', 'B']);
expect(instanceA == instanceB, true);
expect(instanceA.hashCode == instanceB.hashCode, true);
});

test(
'should return different hashCode '
'when instance properties are different', () {
final instanceA = SimpleEquatable(<String>['A', 'B']);
final instanceB = SimpleEquatable(<String>['B']);

expect(instanceA != instanceB, true);
expect(instanceA.hashCode != instanceB.hashCode, true);
});

test(
'should return different hashCode '
'when instance properties are modified', () {
final list = ['A', 'B'];
final instanceA = SimpleEquatable(list);
final hashCodeA = instanceA.hashCode;
list.removeLast();
final hashCodeB = instanceA.hashCode;
expect(hashCodeA != hashCodeB, true);
});
});

group('Map Equatable', () {
test('should return true when values are same', () {
final instanceA = SimpleEquatable({1: 'A', 2: 'B'});
final instanceB = SimpleEquatable({1: 'A', 2: 'B'});
expect(instanceA == instanceB, true);
expect(instanceA.hashCode == instanceB.hashCode, true);
});

test('should return false when values are different', () {
final instanceA = SimpleEquatable({1: 'A', 2: 'B'});
final instanceB = SimpleEquatable({1: 'a', 2: 'b'});
expect(instanceA != instanceB, true);
expect(instanceA.hashCode != instanceB.hashCode, true);
});

test('should return false when values are different', () {
final instanceA = SimpleEquatable({1: 'A', 2: 'B'});
final instanceB = SimpleEquatable({1: 'C', 2: 'D'});
expect(instanceA != instanceB, true);
expect(instanceA.hashCode != instanceB.hashCode, true);
});

test(
'should return different hashCode '
'when instance properties are different', () {
final instanceA = SimpleEquatable({1: 'A', 2: 'B'});
final instanceB = SimpleEquatable({2: 'B'});

expect(instanceA != instanceB, true);
expect(instanceA.hashCode != instanceB.hashCode, true);
});

test(
'should return different hashCode '
'when instance properties are modified', () {
final map = {1: 'A', 2: 'B'};
final instanceA = SimpleEquatable(map);
final hashCodeA = instanceA.hashCode;
map.remove(1);
final hashCodeB = instanceA.hashCode;
expect(hashCodeA != hashCodeB, true);
});
group('List Equatable', () {
test('should return when values are same', () {
final instanceA = SimpleEquatable(['A', 'B']);
final instanceB = SimpleEquatable(['A', 'B']);
expect(instanceA == instanceB, true);
expect(instanceA.hashCode == instanceB.hashCode, true);
});

test('should return when values are different', () {
final instanceA = SimpleEquatable(['A', 'B']);
final instanceB = SimpleEquatable(['a', 'b']);
expect(instanceA != instanceB, true);
expect(instanceA.hashCode != instanceB.hashCode, true);
});

test('should return when values are different', () {
final instanceA = SimpleEquatable(['A', 'B']);
final instanceB = SimpleEquatable(['C', 'D']);
expect(instanceA != instanceB, true);
expect(instanceA.hashCode != instanceB.hashCode, true);
});

test('should return when contents are same but different kind of List',
() {
final instanceA = SimpleEquatable<List<String>>(
CustomList<String>(['A', 'B'], growable: true),
);
final instanceB = SimpleEquatable<List<String>>(['A', 'B']);
expect(instanceA == instanceB, true);
expect(instanceA.hashCode == instanceB.hashCode, true);
});

test(
'should return different hashCode '
'when instance properties are different', () {
final instanceA = SimpleEquatable(<String>['A', 'B']);
final instanceB = SimpleEquatable(<String>['B']);

expect(instanceA != instanceB, true);
expect(instanceA.hashCode != instanceB.hashCode, true);
});

test(
'should return different hashCode '
'when instance properties are modified', () {
final list = ['A', 'B'];
final instanceA = SimpleEquatable(list);
final hashCodeA = instanceA.hashCode;
list.removeLast();
final hashCodeB = instanceA.hashCode;
expect(hashCodeA != hashCodeB, true);
});
});

group('Map Equatable', () {
test('should return true when values are same', () {
final instanceA = SimpleEquatable({1: 'A', 2: 'B'});
final instanceB = SimpleEquatable({1: 'A', 2: 'B'});
expect(instanceA == instanceB, true);
expect(instanceA.hashCode == instanceB.hashCode, true);
});

test('should return false when values are different', () {
final instanceA = SimpleEquatable({1: 'A', 2: 'B'});
final instanceB = SimpleEquatable({1: 'a', 2: 'b'});
expect(instanceA != instanceB, true);
expect(instanceA.hashCode != instanceB.hashCode, true);
});

test('should return false when values are different', () {
final instanceA = SimpleEquatable({1: 'A', 2: 'B'});
final instanceB = SimpleEquatable({1: 'C', 2: 'D'});
expect(instanceA != instanceB, true);
expect(instanceA.hashCode != instanceB.hashCode, true);
});

test(
'should return different hashCode '
'when instance properties are different', () {
final instanceA = SimpleEquatable({1: 'A', 2: 'B'});
final instanceB = SimpleEquatable({2: 'B'});

expect(instanceA != instanceB, true);
expect(instanceA.hashCode != instanceB.hashCode, true);
});

test(
'should return different hashCode '
'when instance properties are modified', () {
final map = {1: 'A', 2: 'B'};
final instanceA = SimpleEquatable(map);
final hashCodeA = instanceA.hashCode;
map.remove(1);
final hashCodeB = instanceA.hashCode;
expect(hashCodeA != hashCodeB, true);
});
});

group('Set Equatable', () {
Expand Down

0 comments on commit 1316d20

Please sign in to comment.