Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should raise an error when call function with invalid arguments', () => {
// $ExpectError: first argument is required
startLocationUpdatesAsync();
// $ExpectError: first argument mush be a string
startLocationUpdatesAsync(1337);
// $ExpectError: second argument must be an object
startLocationUpdatesAsync('taskName', 69);
startLocationUpdatesAsync('taskName', {
// $ExpectError: invalid accuracy
accuracy: 1,
// $ExpectError: invalid activityType
activityType: 1,
// $ExpectError: `notificationTitle` is required props
foregroundService: { notificationBody: 'str' },
});
});
});
it('should raise an error when call function with invalid arguments', () => {
// $ExpectError: first argument is required
startLocationUpdatesAsync();
// $ExpectError: first argument mush be a string
startLocationUpdatesAsync(1337);
// $ExpectError: second argument must be an object
startLocationUpdatesAsync('taskName', 69);
startLocationUpdatesAsync('taskName', {
// $ExpectError: invalid accuracy
accuracy: 1,
// $ExpectError: invalid activityType
activityType: 1,
// $ExpectError: `notificationTitle` is required props
foregroundService: { notificationBody: 'str' },
});
});
});
it('should raise an error when call function with invalid arguments', () => {
// $ExpectError: first argument is required
startLocationUpdatesAsync();
// $ExpectError: first argument mush be a string
startLocationUpdatesAsync(1337);
// $ExpectError: second argument must be an object
startLocationUpdatesAsync('taskName', 69);
startLocationUpdatesAsync('taskName', {
// $ExpectError: invalid accuracy
accuracy: 1,
// $ExpectError: invalid activityType
activityType: 1,
// $ExpectError: `notificationTitle` is required props
foregroundService: { notificationBody: 'str' },
});
});
});
it('should raise an error when call function with invalid arguments', () => {
// $ExpectError: need an object
getCurrentPositionAsync(11);
// $ExpectError: `__accuracy` is missing in enum
getCurrentPositionAsync({ __accuracy: 1 });
});
});
it('should passes when used properly', () => {
getCurrentPositionAsync({
accuracy: Accuracy.High,
}).then(result => {
const { coords, timestamp } = result;
(timestamp: number);
(coords.latitude: number);
(coords.speed: number);
// $ExpectError: check any
(coords.speed: string);
});
});
it('should raise an error when call function with invalid arguments', () => {
// $ExpectError: first argument is required
startGeofencingAsync();
// $ExpectError: first argument mush be a string
startGeofencingAsync(1337);
startGeofencingAsync('taskName', [
// $ExpectError: must be a region object
69,
]);
startGeofencingAsync('taskName', [
{
latitude: 14,
longitude: 48,
// $ExpectError: must be a number
radius: '69',
},
]);
startGeofencingAsync('taskName', [
it('should raise an error when call function with invalid arguments', () => {
// $ExpectError: need a string
stopLocationUpdatesAsync(69);
});
});
it('should passes when used properly', () => {
stopLocationUpdatesAsync('taskName').then(result => {
(result: void);
// $ExpectError: check any
(result: string);
});
});
it('should raise an error when call function with invalid arguments', () => {
// $ExpectError: first argument is required
watchPositionAsync();
// $ExpectError: first argument must be a n object
watchPositionAsync(69);
// $ExpectError: second argument must be a function
watchPositionAsync({}, 69);
watchPositionAsync(
{
// $ExpectError: invalid accuracy value
accuracy: 1,
},
() => {}
);
});
});
it('should passes when used properly', () => {
watchPositionAsync({}, data => {
const { coords, timestamp } = data;
(timestamp: number);
(coords.latitude: number);
(coords.speed: number);
// $ExpectError: check any
(coords.speed: string);
});
watchPositionAsync({}, async () => {}).then(result => {
result.remove();
});
});