ngCordovaMocks API

  • Estimated read time: 5 min read
  • Written by Chad Campbell on Aug 19th 2014

This API is intended to complement ngCordova. This API provides some additional properties to help make automated testing easier. If you clone the source repository, and build it with Grunt, you will see the docs in the /dist/docs directory.

To get a peak at what's available, those properties are documented here. To see how they're used, please look at the tests in the source repository. It should be noted that properties marked with 'This property should only be used in automated tests.' should only be used in automated tests. They should NOT be used in your production code.

$cordovaCamera

throwsError

A flag that signals whether a promise should be rejected or not. This property should only be used in automated tests.

$cordovaCapture

throwsError

A flag that signals whether a promise should be rejected or not. This property should only be used in automated tests.

$cordovaContacts

throwsError

A flag that signals whether a promise should be rejected or not. This property should only be used in automated tests.

contacts

An in-memory collection of contacts. This property should only be used in automated tests.

$cordovaDevice

device

The name of the 'device'. This property should only be used in automated tests.

cordova

The version of cordova in use. This property should only be used in automated tests.

model

The model of the device using the app. This property should only be used in automated tests.

platform

The name of the operating system in use. This property should only be used in automated tests.

uuid

The unique identifier of a device. This property should only be used in automated tests.

version

The version of the operating system. This property should only be used in automated tests.

$cordovaDeviceMotion

currentAcceleration

The current acceleration. This property should only be used in automated tests.

throwsError

A flag that signals whether a promise should be rejected or not. This property should only be used in automated tests.

positions

The collection of 'positions' that have been logged. This property should only be used in automated tests.

watchIntervals

The collection of watchers that are currently active. This property should only be used in automated tests.

$cordovaDeviceOrientation

currentHeading

The current heading. This property should only be used in automated tests.

throwsError

A flag that signals whether a promise should be rejected or not. This property should only be used in automated tests.

readings

The collection of compass 'readings' that have been logged. This property should only be used in automated tests.

watchIntervals

The collection of watchers that are currently active. This property should only be used in automated tests.

cordovaDialogs

dialogText

The main content in the dialog. This property should only be used in automated tests.

dialogTitle

The title of the dialog. This property should only be used in automated tests.

defaultValue

The default value to be used in a prompt. This property should only be used in automated tests.

promptResponse

Used to simulate a user's response to a prompt. This property should only be used in automated tests.

buttonLabels

An array of the text of each button in the dialog. This property should only be used in automated tests.

beepCount

The number of times a beep has occurred. This property should only be used in automated tests.

cordovaFile

throwsError

A flag that signals whether a promise should be rejected or not. This property should only be used in automated tests.

fileSystem

A fake, in-memory file system. This is incomplete at this time. This property should only be used in automated tests.

cordovaGeolocation

throwsError

A flag that signals whether a promise should be rejected or not. This property should only be used in automated tests.

watchIntervals

The collection of watchers that are currently active. This property should only be used in automated tests.

locations

The collection of 'locations' that have been logged. This property should only be used in automated tests.

currentPosition

The last location logged. This property should only be used in automated tests.

nextPosition

The position to be logged the next time that a watcher gets the location. This property should only be used in automated tests.

cordovaGlobalization

throwsError

A flag that signals whether a promise should be rejected or not. This property should only be used in automated tests.

preferredLanguage

The user's preferred language. This property should only be used in automated tests.

localeName

The name of the user's locale. This property should only be used in automated tests.

firstDayOfWeek

The first day of the week based on the user's locale. This property should only be used in automated tests.

cordovaNetwork

connectionType

They type of connection. Values should match those found at https://github.com/apache/cordova-plugin-network-information/blob/master/doc/index.md This property should only be used in automated tests.

isConnected

A flag that signals whether the app is connected to a network. This property should only be used in automated tests.

cordovaSplashscreen

isVisible

A flag that signals whether the splash screen is visible or not. This property should only be used in automated tests.

cordovaStatusbar

isStatusBarVisible

A flag that signals whether the status bar is visible or not. This property should only be used in automated tests.

canOverlayWebView

A flag that signals whether the status bar can overlay the web view. This property should only be used in automated tests.

cordovaVibration

vibrateTimer

Access to the timer associated with vibration. This property should only be used in automated tests.

isVibrating

A flag that signals whether vibration is active. This property should only be used in automated tests.

I hope you find ngCordovaMocks helpful in your daily development.


Comments

comments powered by Disqus

Chad Campbell
Chad Campbell

Chad is an independent software professional. He has been named a Microsoft MVP five times. His books have been translated into multiple languages and distributed worldwide. He holds a computer science degree from Purdue University, where he also studied psychology.

Chad has built sites, apps, frameworks, libraries, and platforms using Java, .NET, and Node. He's ran his own startups and has created software for Fortune 100 companies. In short, Chad knows how to create software. From ideation to delivery. From start-to-finish.


Follow Chad Online