server/spec/fixtures/location

Test utilities to generate location-related data.

Source:

Methods

(static) location(dataopt) → {Promise.<Location>}

Source:

Generates a random location record and saves it to the database.

All of the generated location's properties are assigned random values unless changed with the data argument.

const locationFixtures = require('../spec/fixtures/location');

const location = await locationFixtures.location({
  name: 'Custom name'
});

console.log(location.get('name'));        // "Custom name"
console.log(location.get('short_name'));  // "Lorem ipsum"
Parameters:
Name Type Attributes Default Description
data object <optional>
{}

Custom location data.

Properties
Name Type Attributes Default Description
bbox object <optional>

A bounding box within which the generated location should be

Properties
Name Type Description
southWest Array.<number>

A longitude/latitude pair indicating the south-west corner of the bounding box

northEast Array.<number>

A longitude/latitude pair indicating the north-east corner of the bounding box

name string <optional>
shortName string <optional>

Set to null to create a location without a short name.

description string <optional>
phone string <optional>
photoUrl string <optional>
siteUrl string <optional>
geometry object <optional>
properties object <optional>
{}
address object <optional>
Properties
Name Type Attributes Description
street string <optional>
number string <optional>

Set to null to create an address without a number

zipCode string <optional>
city string <optional>
state string <optional>
Returns:

A promise that will be resolved with the saved location.

Type
Promise.<Location>

(static) name() → {string}

Source:

Generates a unique random location name.

const locationFixtures = require('../spec/fixtures/location');

locationFixtures.name();  // "Lorem ipsum aute ad dolor exercitation labore amet"
Returns:

A name for a location.

Type
string

(static) shortName() → {string}

Source:

Generates a unique random location short name.

const locationFixtures = require('../spec/fixtures/location');

locationFixtures.shortName();  // "Lorem"
Returns:

A short name for a location.

Type
string