Skip to content

Commit

Permalink
Add unit tests for validateGeofenceId (#9964)
Browse files Browse the repository at this point in the history
  • Loading branch information
slaymance authored Jun 7, 2022
1 parent e7220da commit 1a5018a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/geo/__tests__/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
validateCoordinates,
validateLinearRing,
validatePolygon,
validateGeofenceId,
validateGeofencesInput,
} from '../src/util';

Expand Down Expand Up @@ -127,6 +128,40 @@ describe('Geo utility functions', () => {
});
});

describe('validateGeofenceId', () => {
test('should not throw an error for a geofence ID with letters and numbers', () => {
expect(() => validateGeofenceId('ExampleGeofence1')).not.toThrowError();
});

test('should not throw an error for a geofence ID with a dash', () => {
expect(() => validateGeofenceId('ExampleGeofence-1')).not.toThrowError();
});

test('should not throw an error for a geofence ID with a period', () => {
expect(() => validateGeofenceId('ExampleGeofence.1')).not.toThrowError();
});

test('should not throw an error for a geofence ID with an underscore', () => {
expect(() => validateGeofenceId('ExampleGeofence_1')).not.toThrowError();
});

test('should not throw an error for a geofence ID with non-basic Latin character', () => {
expect(() => validateGeofenceId('ExampleGeòfence-1')).not.toThrowError();
});

test('should not throw an error for a geofence ID with superscript and subscript numbers', () => {
expect(() => validateGeofenceId('ExampleGeofence-⁴₆')).not.toThrowError();
});

test('should throw an error for an empty string', () => {
expect(() => validateGeofenceId('')).toThrowError();
});

test('should throw an error for a geofence ID with an invalid character', () => {
expect(() => validateGeofenceId('ExampleGeofence-1&')).toThrowError();
});
});

describe('validateGeofencesInput', () => {
test('should not throw an error for valid geofences', () => {
const result = validateGeofencesInput(validGeofences);
Expand Down

0 comments on commit 1a5018a

Please sign in to comment.