chai-fireproof
Version:
Firebase and Fireproof support for the Chai assertion library.
95 lines (69 loc) • 2.81 kB
Markdown
<a name="chai"></a>
#chai
**Members**
* [chai](#chai)
* [chai.getFirebaseMessage(name)](#chai.getFirebaseMessage)
* [chai.setFirebaseAuthToken(newToken)](#chai.setFirebaseAuthToken)
* [class: chai.Assertion](#chai.Assertion)
* [Assertion.can()](#chai.Assertion.can)
* [Assertion.cannot()](#chai.Assertion.cannot)
* [Assertion.read()](#chai.Assertion.read)
* [Assertion.write([value])](#chai.Assertion.write)
* [Assertion.ref(ref)](#chai.Assertion.ref)
* [class: chai.FirebaseError](#chai.FirebaseError)
* [new chai.FirebaseError(message)](#new_chai.FirebaseError)
<a name="chai.getFirebaseMessage"></a>
##chai.getFirebaseMessage(name)
Retrieve log messages generated by Firebase.
**Params**
- name `String` - The kind of message to get: log, warning, or error.
**Returns**: `String` - message
<a name="chai.setFirebaseAuthToken"></a>
##chai.setFirebaseAuthToken(newToken)
Set the Firebase auth token to use in tests.
**Params**
- newToken `String` - The auth token to use in testing.
<a name="chai.Assertion"></a>
##class: chai.Assertion
**Members**
* [class: chai.Assertion](#chai.Assertion)
* [Assertion.can()](#chai.Assertion.can)
* [Assertion.cannot()](#chai.Assertion.cannot)
* [Assertion.read()](#chai.Assertion.read)
* [Assertion.write([value])](#chai.Assertion.write)
* [Assertion.ref(ref)](#chai.Assertion.ref)
<a name="chai.Assertion.can"></a>
###Assertion.can()
Asserts that the described operation is possible given the security rules.
<a name="chai.Assertion.cannot"></a>
###Assertion.cannot()
Asserts that the described operation is impossible given the security rules.
<a name="chai.Assertion.read"></a>
###Assertion.read()
Asserts that the supplied ```ref``` is readable by the expected user.
<a name="chai.Assertion.write"></a>
###Assertion.write([value])
Asserts that the supplied ```ref``` is writable by the expected user.
**Params**
- \[value=null\] `*` - The value to try to write.
<a name="chai.Assertion.ref"></a>
###Assertion.ref(ref)
Relates the assertion to a given Fireproof database reference. Will throw
a [FirebaseError](#chai.FirebaseError) if [setFirebaseAuthToken](#chai.setFirebaseAuthToken) has not been called.
**Params**
- ref `Fireproof` - The ref to test against.
**Returns**: `Promise`
**Example**
```js
expect(null).cannot.write({random: 'data'}).to(root.child('just').child('anywhere'));
```
<a name="chai.FirebaseError"></a>
##class: chai.FirebaseError
**Members**
* [class: chai.FirebaseError](#chai.FirebaseError)
* [new chai.FirebaseError(message)](#new_chai.FirebaseError)
<a name="new_chai.FirebaseError"></a>
###new chai.FirebaseError(message)
Thrown by chai-fireproof when something goes wrong with Firebase unexpectedly.
**Params**
- message `String` - The error message.