JSDoc: Namespace: assert

# Namespace: assert

## assert

Shorthands for common assertions made in Marionette.

Source:
  - assert.js, line 32

### Methods

#### (static) array(obj, msgopt) → {Object}

Asserts that |obj| is an Array.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`obj` | ? |  | Value to test.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 357

##### Throws:

If |obj| is not an Array.

Type
  InvalidArgumentError

##### Returns:

|obj| is returned unaltered.

Type
  Object

#### (static) boolean(obj, msgopt) → {boolean}

Asserts that |obj| is a boolean.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`obj` | ? |  | Value to test.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 272

##### Throws:

If |obj| is not a boolean.

Type
  InvalidArgumentError

##### Returns:

|obj| is returned unaltered.

Type
  boolean

#### (static) callable(obj, msgopt) → {function}

Asserts that |obj| is callable.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`obj` | ? |  | Value to test.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 214

##### Throws:

If |obj| is not callable.

Type
  InvalidArgumentError

##### Returns:

|obj| is returned unaltered.

Type
  function

#### (static) content(context, msgopt) → {string}

Asserts that the current |context| is content.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`context` | string |  | Context to test.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 96

##### Throws:

If |context| is not content.

Type
  UnsupportedOperationError

##### Returns:

|context| is returned unaltered.

Type
  string

#### (static) contentBrowser(context, msgopt)

Asserts that |context| is a valid browsing context.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`context` | browser.Context |  | Browsing context to test.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 133

##### Throws:

If |context| is invalid.

Type
  NoSuchWindowError

#### (static) defined(obj, msgopt) → {?}

Asserts that |obj| is defined.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`obj` | ? |  | Value to test.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 176

##### Throws:

If |obj| is not defined.

Type
  InvalidArgumentError

##### Returns:

|obj| is returned unaltered.

Type
  ?

#### (static) fennec(msgopt)

Asserts that the current browser is Fennec, or Firefox for Android.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 77

##### Throws:

If current browser is not Fennec.

Type
  UnsupportedOperationError

#### (static) firefox(msgopt)

Asserts that the current browser is Firefox Desktop.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 63

##### Throws:

If current browser is not Firefox.

Type
  UnsupportedOperationError

#### (static) in(prop, obj, msgopt) → {?}

Asserts that |prop| is in |obj|.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`prop` | ? |  | Own property to test if is in |obj|.
`obj` | ? |  | Object.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 336

##### Throws:

If |prop| is not in |obj|, or |obj| is not an object.

Type
  InvalidArgumentError

##### Returns:

Value of |obj|'s own property |prop|.

Type
  ?

#### (static) integer(obj, msgopt) → {number}

Asserts that |obj| is an integer.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`obj` | ? |  | Value to test.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 233

##### Throws:

If |obj| is not an integer.

Type
  InvalidArgumentError

##### Returns:

|obj| is returned unaltered.

Type
  number

#### (static) noUserPrompt(dialog, msgopt)

Asserts that there is no current user prompt.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`dialog` | modal.Dialog |  | Reference to current dialogue.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 156

##### Throws:

If there is a user prompt.

Type
  UnexpectedAlertOpenError

#### (static) number(obj, msgopt) → {number}

Asserts that |obj| is a finite number.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`obj` | ? |  | Value to test.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 195

##### Throws:

If |obj| is not a number.

Type
  InvalidArgumentError

##### Returns:

|obj| is returned unaltered.

Type
  number

#### (static) object(obj, msgopt) → {Object}

Asserts that |obj| is an object.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`obj` | ? |  | Value to test.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 310

##### Throws:

If |obj| is not an object.

Type
  InvalidArgumentError

##### Returns:

|obj| is returned unaltered.

Type
  Object

#### (static) positiveInteger(obj, msgopt) → {number}

Asserts that |obj| is a positive integer.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`obj` | ? |  | Value to test.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 252

##### Throws:

If |obj| is not a positive integer.

Type
  InvalidArgumentError

##### Returns:

|obj| is returned unaltered.

Type
  number

#### (static) session(driver, msgopt) → {string}

Asserts that Marionette has a session.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`driver` | GeckoDriver |  | Marionette driver instance.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 48

##### Throws:

If driver does not have a session ID.

Type
  InvalidSessionIDError

##### Returns:

Current session's ID.

Type
  string

#### (static) string(obj, msgopt) → {string}

Asserts that |obj| is a string.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`obj` | ? |  | Value to test.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 291

##### Throws:

If |obj| is not a string.

Type
  InvalidArgumentError

##### Returns:

|obj| is returned unaltered.

Type
  string

#### (static) that(predicate, messageopt, erroropt) → {function}

Returns a function that is used to assert the |predicate|.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`predicate` | function |  | Evaluated on calling the return value of this function. If its return value of the inner function is false, |error| is thrown with |message|.
`message` | string | <optional> | Custom error message.
`error` | Error | <optional> | Custom error type by its class.

Source:
  - assert.js, line 379

##### Returns:

Function that takes and returns the passed in value unaltered, and which may throw |error| with |message| if |predicate| evaluates to false.

Type
  function

#### (static) window(win, msgopt) → {ChromeWindow}

Asserts that |win| is open.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`win` | ChromeWindow |  | Chrome window to test.
`msg` | string | <optional> | Custom error message.

Source:
  - assert.js, line 115

##### Throws:

If |win| has been closed.

Type
  NoSuchWindowError

##### Returns:

|win| is returned unaltered.

Type
  ChromeWindow