From 54a7ea488867dc0df212525e1f5ac9a4997fea70 Mon Sep 17 00:00:00 2001 From: Alann Maulana Date: Tue, 27 Apr 2021 05:37:20 +0700 Subject: [PATCH] test improvements --- test/beacon/authorization_status_test.dart | 19 +++++++++++++++++++ test/beacon/beacon_broadcast_test.dart | 1 + test/beacon/beacon_test.dart | 15 +++++++++++++++ test/beacon/bluetooth_state_test.dart | 19 +++++++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/test/beacon/authorization_status_test.dart b/test/beacon/authorization_status_test.dart index 617ceade..0345fbb1 100644 --- a/test/beacon/authorization_status_test.dart +++ b/test/beacon/authorization_status_test.dart @@ -13,6 +13,25 @@ void main() { expect(authorizationStatus.isIOS, isTrue); }); + test('authorization must be equal', () { + final statusA = AuthorizationStatus.init( + 'VALUE', + isAndroid: false, + isIOS: true, + ); + final statusB = AuthorizationStatus.init( + 'VALUE', + isAndroid: false, + isIOS: true, + ); + expect(statusA, statusB); + expect(statusA.hashCode, statusB.hashCode); + expect(statusA.value, statusB.value); + expect(statusA.isAndroid, statusB.isAndroid); + expect(statusA.isIOS, statusB.isIOS); + expect(statusA.toString(), statusB.toString()); + }); + test('authorization value', () { expect(AuthorizationStatus.allowed.value, 'ALLOWED'); expect(AuthorizationStatus.always.value, 'ALWAYS'); diff --git a/test/beacon/beacon_broadcast_test.dart b/test/beacon/beacon_broadcast_test.dart index 2f345b89..d42fb42b 100644 --- a/test/beacon/beacon_broadcast_test.dart +++ b/test/beacon/beacon_broadcast_test.dart @@ -20,5 +20,6 @@ main() { expect(beacon.txPower, -58); expect(beacon.advertisingMode, AdvertisingMode.high); expect(beacon.advertisingTxPowerLevel, AdvertisingTxPowerLevel.low); + expect(beacon.toJson, isMap); }); } diff --git a/test/beacon/beacon_test.dart b/test/beacon/beacon_test.dart index 7d03849c..d043bb88 100644 --- a/test/beacon/beacon_test.dart +++ b/test/beacon/beacon_test.dart @@ -39,6 +39,7 @@ main() { major: 1, minor: 2, txPower: -59, + rssi: null, ); expect(beacon3.proximity, Proximity.near); expect(beacon3.rssi, -1); @@ -127,6 +128,16 @@ main() { test('beacon json must be equal', () { final beacon = Beacon.fromJson({ + 'macAddress': 'MAC', + 'proximityUUID': 'UUID', + 'major': 1, + 'minor': 2, + 'rssi': -60, + 'accuracy': 1.23, + 'proximity': 'far', + }); + final beacon2 = Beacon.fromJson({ + 'macAddress': 'MAC', 'proximityUUID': 'UUID', 'major': 1, 'minor': 2, @@ -135,7 +146,10 @@ main() { 'proximity': 'far', }); + expect(beacon, beacon2); + expect(beacon.hashCode, beacon2.hashCode); expect(beacon.toJson, { + 'macAddress': 'MAC', 'proximityUUID': 'UUID', 'major': 1, 'minor': 2, @@ -152,6 +166,7 @@ main() { 'rssi': -60, 'accuracy': 1.23, 'proximity': 'far', + 'macAddress': 'MAC', })); }); } diff --git a/test/beacon/bluetooth_state_test.dart b/test/beacon/bluetooth_state_test.dart index e9fd6f19..a4aa81b0 100644 --- a/test/beacon/bluetooth_state_test.dart +++ b/test/beacon/bluetooth_state_test.dart @@ -13,6 +13,25 @@ void main() { expect(bluetoothState.isIOS, isTrue); }); + test('bluetooth state must be equal', () { + final stateA = BluetoothState.init( + 'VALUE', + isAndroid: true, + isIOS: false, + ); + final stateB = BluetoothState.init( + 'VALUE', + isAndroid: true, + isIOS: false, + ); + expect(stateA, stateB); + expect(stateA.hashCode, stateB.hashCode); + expect(stateA.value, stateB.value); + expect(stateA.isAndroid, stateB.isAndroid); + expect(stateA.isIOS, stateB.isIOS); + expect(stateA.toString(), stateB.toString()); + }); + test('bluetooth state value', () { expect(BluetoothState.stateOff.value, 'STATE_OFF'); expect(BluetoothState.stateTurningOff.value, 'STATE_TURNING_OFF');