2019-06-10 06:28:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Zender & Kurtz GbR.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Christian Pauly <krille@famedly.com>
|
|
|
|
* Marcel Radzio <mtrnord@famedly.com>
|
|
|
|
*
|
|
|
|
* This file is part of famedlysdk.
|
|
|
|
*
|
|
|
|
* famedlysdk is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* famedlysdk is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-06-21 12:38:07 +00:00
|
|
|
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
2019-06-10 06:28:21 +00:00
|
|
|
*/
|
|
|
|
|
2019-10-04 09:44:32 +00:00
|
|
|
import 'package:test/test.dart';
|
2019-06-10 06:28:21 +00:00
|
|
|
import 'package:famedlysdk/src/utils/ChatTime.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
/// All Tests related to the ChatTime
|
|
|
|
group("ChatTime", () {
|
|
|
|
test("Comparing", () async {
|
2019-06-21 12:38:07 +00:00
|
|
|
final int originServerTs = DateTime.now().millisecondsSinceEpoch -
|
|
|
|
(ChatTime.minutesBetweenEnvironments - 1) * 1000 * 60;
|
|
|
|
final int oldOriginServerTs = DateTime.now().millisecondsSinceEpoch -
|
|
|
|
(ChatTime.minutesBetweenEnvironments + 1) * 1000 * 60;
|
2019-06-10 06:28:21 +00:00
|
|
|
|
|
|
|
final ChatTime chatTime = ChatTime(originServerTs);
|
|
|
|
final ChatTime oldChatTime = ChatTime(oldOriginServerTs);
|
|
|
|
final ChatTime nowTime = ChatTime.now();
|
|
|
|
|
|
|
|
expect(chatTime.toTimeStamp(), originServerTs);
|
2019-06-21 12:38:07 +00:00
|
|
|
expect(nowTime.toTimeStamp() > chatTime.toTimeStamp(), true);
|
|
|
|
expect(nowTime.sameEnvironment(chatTime), true);
|
|
|
|
expect(nowTime.sameEnvironment(oldChatTime), false);
|
2019-06-10 06:28:21 +00:00
|
|
|
|
|
|
|
expect(chatTime > oldChatTime, true);
|
|
|
|
expect(chatTime < oldChatTime, false);
|
|
|
|
expect(chatTime >= oldChatTime, true);
|
|
|
|
expect(chatTime <= oldChatTime, false);
|
|
|
|
expect(chatTime == chatTime, true);
|
|
|
|
expect(chatTime == oldChatTime, false);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Formatting", () async {
|
2019-06-11 06:59:22 +00:00
|
|
|
final int timestamp = DateTime.now().millisecondsSinceEpoch;
|
2019-06-10 06:28:21 +00:00
|
|
|
final ChatTime chatTime = ChatTime(timestamp);
|
2019-06-11 06:45:45 +00:00
|
|
|
//expect(chatTime.toTimeString(),"05:36"); // This depends on the time and your timezone ;)
|
2019-06-21 12:38:07 +00:00
|
|
|
expect(chatTime.toTimeString(), chatTime.toEventTimeString());
|
2019-06-10 06:28:21 +00:00
|
|
|
|
|
|
|
final ChatTime oldChatTime = ChatTime(156014498475);
|
2019-06-21 12:38:07 +00:00
|
|
|
expect(oldChatTime.toString(), "11.12.1974");
|
2019-06-10 06:28:21 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|