forked from roughike/inKino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request roughike#89 from roughike/bugfix/equals-in-viewmodels
Fix hashcode & equals in viewmodels
- Loading branch information
Showing
10 changed files
with
264 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'package:inkino/models/event.dart'; | ||
import 'package:inkino/models/loading_status.dart'; | ||
import 'package:inkino/ui/events/events_page_view_model.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('EventsPageViewModel', () { | ||
test('equal', () { | ||
var first = EventsPageViewModel( | ||
status: LoadingStatus.success, | ||
events: <Event>[ | ||
Event(id: 'abc123'), | ||
], | ||
refreshEvents: () {}, | ||
); | ||
|
||
var second = EventsPageViewModel( | ||
status: LoadingStatus.success, | ||
events: <Event>[ | ||
Event(id: 'abc123'), | ||
], | ||
refreshEvents: () {}, | ||
); | ||
|
||
expect(first, second); | ||
}); | ||
|
||
test('not equal', () { | ||
var first = EventsPageViewModel( | ||
status: LoadingStatus.success, | ||
events: <Event>[ | ||
Event(id: 'abc123'), | ||
], | ||
refreshEvents: () {}, | ||
); | ||
|
||
var second = EventsPageViewModel( | ||
status: LoadingStatus.success, | ||
events: <Event>[ | ||
Event(id: 'xyz456'), | ||
], | ||
refreshEvents: () {}, | ||
); | ||
|
||
expect(first, isNot(second)); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import 'package:inkino/models/loading_status.dart'; | ||
import 'package:inkino/models/show.dart'; | ||
import 'package:inkino/ui/showtimes/showtime_page_view_model.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('ShowtimesPageViewModel', () { | ||
test('equal', () { | ||
var first = ShowtimesPageViewModel( | ||
status: LoadingStatus.success, | ||
dates: <DateTime>[DateTime(2018)], | ||
selectedDate: null, | ||
shows: <Show>[ | ||
Show(id: 'abc123'), | ||
], | ||
changeCurrentDate: (DateTime newDate) {}, | ||
refreshShowtimes: () {}, | ||
); | ||
|
||
var second = ShowtimesPageViewModel( | ||
status: LoadingStatus.success, | ||
dates: <DateTime>[DateTime(2018)], | ||
selectedDate: null, | ||
shows: <Show>[ | ||
Show(id: 'abc123'), | ||
], | ||
changeCurrentDate: (DateTime newDate) {}, | ||
refreshShowtimes: () {}, | ||
); | ||
|
||
expect(first, second); | ||
}); | ||
|
||
test('not equal', () { | ||
var first = ShowtimesPageViewModel( | ||
status: LoadingStatus.success, | ||
dates: <DateTime>[DateTime(2018)], | ||
selectedDate: null, | ||
shows: <Show>[ | ||
Show(id: 'abc123'), | ||
], | ||
changeCurrentDate: (DateTime newDate) {}, | ||
refreshShowtimes: () {}, | ||
); | ||
|
||
var second = ShowtimesPageViewModel( | ||
status: LoadingStatus.success, | ||
dates: <DateTime>[DateTime(2018)], | ||
selectedDate: null, | ||
shows: <Show>[ | ||
Show(id: 'xyz456'), | ||
], | ||
changeCurrentDate: (DateTime newDate) {}, | ||
refreshShowtimes: () {}, | ||
); | ||
|
||
expect(first, isNot(second)); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import 'package:inkino/models/theater.dart'; | ||
import 'package:inkino/ui/theater_list/theater_list_view_model.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('TheaterListViewModel', () { | ||
test('equal', () { | ||
var first = TheaterListViewModel( | ||
currentTheater: Theater(id: 'abc123', name: 'Test 1'), | ||
theaters: <Theater>[ | ||
Theater(id: 'abc123', name: 'Test 1'), | ||
Theater(id: 'xyz456', name: 'Test 2'), | ||
], | ||
changeCurrentTheater: (Theater newTheater) {}, | ||
); | ||
|
||
var second = TheaterListViewModel( | ||
currentTheater: Theater(id: 'abc123', name: 'Test 1'), | ||
theaters: <Theater>[ | ||
Theater(id: 'abc123', name: 'Test 1'), | ||
Theater(id: 'xyz456', name: 'Test 2'), | ||
], | ||
changeCurrentTheater: (Theater newTheater) {}, | ||
); | ||
|
||
expect(first, second); | ||
}); | ||
|
||
test('not equal', () { | ||
var first = TheaterListViewModel( | ||
currentTheater: Theater(id: 'abc123', name: 'Test 1'), | ||
theaters: <Theater>[ | ||
Theater(id: 'abc123', name: 'Test 1'), | ||
Theater(id: 'xyz456', name: 'Test 2'), | ||
], | ||
changeCurrentTheater: (Theater newTheater) {}, | ||
); | ||
|
||
var second = TheaterListViewModel( | ||
currentTheater: Theater(id: 'abc123', name: 'Test 1'), | ||
theaters: <Theater>[ | ||
Theater(id: 'efg123', name: 'Test 3'), | ||
Theater(id: 'hjk456', name: 'Test 4'), | ||
], | ||
changeCurrentTheater: (Theater newTheater) {}, | ||
); | ||
|
||
expect(first, isNot(second)); | ||
}); | ||
}); | ||
} |