Skip to content

Commit

Permalink
test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
alann-maulana committed Apr 26, 2021
1 parent e278e83 commit 54a7ea4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/beacon/authorization_status_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions test/beacon/beacon_broadcast_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ main() {
expect(beacon.txPower, -58);
expect(beacon.advertisingMode, AdvertisingMode.high);
expect(beacon.advertisingTxPowerLevel, AdvertisingTxPowerLevel.low);
expect(beacon.toJson, isMap);
});
}
15 changes: 15 additions & 0 deletions test/beacon/beacon_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ main() {
major: 1,
minor: 2,
txPower: -59,
rssi: null,
);
expect(beacon3.proximity, Proximity.near);
expect(beacon3.rssi, -1);
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -152,6 +166,7 @@ main() {
'rssi': -60,
'accuracy': 1.23,
'proximity': 'far',
'macAddress': 'MAC',
}));
});
}
19 changes: 19 additions & 0 deletions test/beacon/bluetooth_state_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 54a7ea4

Please sign in to comment.