KintoClient
|
KintoClient |
61 |
#constructor
|
KintoClient#constructor |
15 |
should check that remote is a string
|
- |
|
should validate remote arg value
|
- |
|
should strip any trailing slash
|
- |
|
should expose a passed events instance option
|
- |
|
should propagate its events property to child dependencies
|
- |
|
should assign version value
|
- |
|
should accept a headers option
|
- |
|
should validate protocol version
|
- |
|
should propagate the requestMode option to the child HTTP instance
|
- |
|
should keep the default timeout in the child HTTP instance
|
- |
|
should propagate the timeout option to the child HTTP instance
|
- |
|
should create an event emitter if none is provided
|
- |
|
should expose provided event emitter as a property
|
- |
|
should accept a bucket option
|
- |
|
should accept a safe option
|
- |
|
get backoff()
|
KintoClient#backoff |
2 |
should provide the remaining backoff time in ms if any
|
- |
|
should provide no remaining backoff time when none is set
|
- |
|
#bucket()
|
KintoClient#bucket |
2 |
should return a Bucket instance
|
- |
|
should propagate default req options to bucket instance
|
- |
|
#fetchServerInfo
|
KintoClient#fetchServerInfo |
3 |
should retrieve server settings on first request made
|
- |
|
should store server settings into the serverSettings property
|
- |
|
should not fetch server settings if they're cached already
|
- |
|
#fetchServerSettings()
|
KintoClient#fetchServerSettings |
1 |
should retrieve server settings
|
- |
|
#fetchServerCapabilities()
|
KintoClient#fetchServerCapabilities |
1 |
should retrieve server capabilities
|
- |
|
#fetchUser()
|
KintoClient#fetchUser |
1 |
should retrieve user information
|
- |
|
#fetchHTTPApiVersion()
|
KintoClient#fetchHTTPApiVersion |
1 |
should retrieve current API version
|
- |
|
#batch
|
KintoClient#batch |
19 |
Batch client setup
|
- |
1 |
should skip registering HTTP events
|
- |
|
server request
|
- |
7 |
should ensure server settings are fetched
|
- |
|
empty request list
|
- |
1 |
should not perform request on empty operation list
|
- |
|
non-empty request list
|
- |
4 |
should call the batch endpoint
|
- |
|
should define main batch request default headers
|
- |
|
should attach all batch request headers
|
- |
|
should batch the expected number of requests
|
- |
|
Safe mode
|
- |
1 |
should forward the safe option to resulting requests
|
- |
|
server response
|
- |
6 |
should reject on HTTP 400
|
- |
|
should reject on HTTP error status code
|
- |
|
should expose succesful subrequest responses
|
- |
|
should expose failing subrequest responses
|
- |
|
should resolve with encountered HTTP 500
|
- |
|
should expose encountered HTTP 412
|
- |
|
Chunked requests
|
- |
4 |
should chunk batch requests
|
- |
|
should not chunk batch requests if setting is falsy
|
- |
|
should map initial records to conflict objects
|
- |
|
should chunk batch requests concurrently
|
- |
|
Aggregate mode
|
- |
1 |
should resolve with an aggregated result object
|
- |
|
#listBuckets()
|
KintoClient#listBuckets |
3 |
should execute expected request
|
- |
|
should support passing custom headers
|
- |
|
should resolve with a result object
|
- |
|
#createBucket
|
KintoClient#createBucket |
5 |
should throw if bucket id is missing
|
- |
|
should execute expected request
|
- |
|
should accept a data option
|
- |
|
should accept a safe option
|
- |
|
should extend request headers with optional ones
|
- |
|
#deleteBucket()
|
KintoClient#deleteBucket |
4 |
should execute expected request
|
- |
|
should accept a bucket object
|
- |
|
should accept a safe option
|
- |
|
should extend request headers with optional ones
|
- |
|
#deleteBuckets()
|
KintoClient#deleteBuckets |
4 |
should execute expected request
|
- |
|
should accept a safe option
|
- |
|
should extend request headers with optional ones
|
- |
|
should reject if http_api_version mismatches
|
- |
|
batch module
|
- |
11 |
aggregate()
|
- |
11 |
should throw if responses length doesn't match requests one
|
- |
|
should return an object
|
- |
|
should return an object with the expected keys
|
- |
|
should expose HTTP 500 errors in the errors list
|
- |
|
should expose HTTP 200<=x<400 responses in the published list
|
- |
|
should expose HTTP 404 responses in the skipped list
|
- |
|
should expose HTTP 412 responses in the conflicts list
|
- |
|
Heterogeneous combinations
|
- |
4 |
should list errors
|
- |
|
should list published data
|
- |
|
should list conflicts
|
- |
|
should list skips
|
- |
|
Bucket
|
Bucket |
50 |
Options handling
|
- |
1 |
should accept options
|
- |
|
#getData()
|
Bucket#getData |
2 |
should execute expected request
|
- |
|
should resolve with response data
|
- |
|
#setData()
|
- |
4 |
should set the bucket data
|
- |
|
should handle the patch option
|
- |
|
should handle the safe option
|
- |
|
should resolve with json result
|
- |
|
#collection()
|
Bucket#collection |
3 |
should return a Collection instance
|
- |
|
should return a named collection
|
- |
|
should propagate bucket options
|
- |
|
#listCollections()
|
Bucket#listCollections |
3 |
should list bucket collections
|
- |
|
should merge default options
|
- |
|
should return the list of collections
|
- |
|
#createCollection()
|
Bucket#createCollection |
6 |
should accept a safe option
|
- |
|
should extend request headers with optional ones
|
- |
|
Named collection
|
- |
2 |
should create a named collection
|
- |
|
should merge default options
|
- |
|
Unnamed collection
|
- |
2 |
should create an unnamed collection
|
- |
|
should merge default options
|
- |
|
#deleteCollection
|
Bucket#deleteCollection |
4 |
should delete a collection
|
- |
|
should merge default options
|
- |
|
should accept a safe option
|
- |
|
should extend request headers with optional ones
|
- |
|
#listGroups()
|
Bucket#listGroups |
3 |
should list bucket groups
|
- |
|
should merge default options
|
- |
|
should return the list of groups
|
- |
|
#getGroup
|
Bucket#getGroup |
2 |
should extend request headers with optional ones
|
- |
|
should return the group
|
- |
|
#createGroup
|
Bucket#createGroup |
4 |
should accept a safe option
|
- |
|
should extend request headers with optional ones
|
- |
|
should create a group with empty list of members
|
- |
|
should create a group with optional data and permissions
|
- |
|
#updateGroup
|
Bucket#updateGroup |
6 |
should throw if record is not an object
|
- |
|
should throw if id is missing
|
- |
|
should accept a patch option
|
- |
|
should extend request headers with optional ones
|
- |
|
should update the group from first argument
|
- |
|
should update the group with optional data and permissions
|
- |
|
#deleteGroup
|
Bucket#updateGroup |
4 |
should delete a group
|
- |
|
should merge default options
|
- |
|
should accept a safe option
|
- |
|
should extend request headers with optional ones
|
- |
|
#getPermissions()
|
Bucket#getPermissions |
2 |
should retrieve permissions
|
- |
|
should merge default options
|
- |
|
#setPermissions()
|
Bucket#setPermissions |
4 |
should set permissions
|
- |
|
should merge default options
|
- |
|
should accept a last_modified option
|
- |
|
should resolve with response data
|
- |
|
#batch()
|
Bucket#batch |
2 |
should batch operations for this bucket
|
- |
|
should merge default options
|
- |
|
Collection
|
Collection |
39 |
#getData()
|
Collection#getData |
2 |
should execute expected request
|
- |
|
should resolve with response data
|
- |
|
#getPermissions()
|
Collection#getPermissions |
1 |
should retrieve permissions
|
- |
|
#setPermissions()
|
Collection#setPermissions |
3 |
should set permissions
|
- |
|
should handle the safe option
|
- |
|
should resolve with json result
|
- |
|
#getData()
|
Collection#getData |
1 |
should retrieve data
|
- |
|
#setData()
|
- |
3 |
should set the data
|
- |
|
should handle the safe option
|
- |
|
should resolve with json result
|
- |
|
#createRecord()
|
Collection#createRecord |
4 |
should create the expected request
|
- |
|
should accept a safe option
|
- |
|
should execute the expected request
|
- |
|
should resolve with response body
|
- |
|
#updateRecord()
|
Collection#updateRecord |
6 |
should throw if record is not an object
|
- |
|
should throw if id is missing
|
- |
|
should create the expected request
|
- |
|
should accept a safe option
|
- |
|
should accept a patch option
|
- |
|
should resolve with response body
|
- |
|
#deleteRecord()
|
Collection#deleteRecord |
4 |
should throw if id is missing
|
- |
|
should delete a record
|
- |
|
should accept a safe option
|
- |
|
should delete a record using a record object
|
- |
|
#getRecord()
|
Collection#getRecord |
2 |
should execute expected request
|
- |
|
should retrieve a record
|
- |
|
#listRecords()
|
Collection#listRecords |
12 |
No pagination
|
- |
7 |
should execute expected request
|
- |
|
should sort records
|
- |
|
should resolve with records list
|
- |
|
should resolve with a next() function
|
- |
|
should support the since option
|
- |
|
should throw if the since option is invalid
|
- |
|
should resolve with the collection last_modified cast as int value
|
- |
|
Filtering
|
- |
2 |
should generate the expected filtering query string
|
- |
|
shouldn't need an explicit sort parameter
|
- |
|
Pagination
|
- |
3 |
should issue a request with the specified limit applied
|
- |
|
should query for next page
|
- |
|
should aggregate paginated results
|
- |
|
#batch()
|
Collection#batch |
1 |
should batch operations
|
- |
|
endpoint()
|
endpoint |
6 |
should provide a root endpoint
|
- |
|
should provide a batch endpoint
|
- |
|
should provide a bucket endpoint
|
- |
|
should provide a collection endpoint
|
- |
|
should provide a records endpoint
|
- |
|
should provide a record endpoint
|
- |
|
HTTP class
|
HTTP |
20 |
#constructor
|
HTTP#constructor |
3 |
should expose a passed events instance
|
- |
|
should accept a requestMode option
|
- |
|
should complain if an events handler is not provided
|
- |
|
#request()
|
HTTP#request |
17 |
Request headers
|
- |
2 |
should set default headers
|
- |
|
should merge custom headers with default ones
|
- |
|
Request CORS mode
|
- |
2 |
should use default CORS mode
|
- |
|
should use configured custom CORS mode
|
- |
|
Succesful request
|
- |
3 |
should resolve with HTTP status
|
- |
|
should resolve with JSON body
|
- |
|
should resolve with headers
|
- |
|
Request timeout
|
- |
1 |
should timeout the request
|
- |
|
No content response
|
- |
1 |
should resolve with null JSON if Content-Length header is missing
|
- |
|
Malformed JSON response
|
- |
1 |
should reject with an appropriate message
|
- |
|
Business error responses
|
- |
1 |
should reject on status code > 400
|
- |
|
Deprecation header
|
- |
3 |
should handle deprecation header
|
- |
|
should handle deprecation header parse error
|
- |
|
should emit a deprecated event on Alert header
|
- |
|
Backoff header handling
|
- |
2 |
should emit a backoff event on set Backoff header
|
- |
|
should emit a backoff event on missing Backoff header
|
- |
|
Retry-After header handling
|
- |
1 |
should emit a retry-after event when Retry-After is set
|
- |
|
Integration tests
|
- |
91 |
Default server configuration
|
- |
21 |
new batch
|
- |
2 |
should support root batch
|
- |
|
should support bucket batch
|
- |
|
Server properties
|
- |
4 |
should retrieve server settings
|
- |
|
should retrieve server capabilities
|
- |
|
should retrieve user information
|
- |
|
should retrieve current API version
|
- |
|
#createBucket
|
- |
5 |
Default options
|
- |
4 |
should create a bucket with the passed id
|
- |
|
should create a bucket having a list of write permissions
|
- |
|
data option
|
- |
1 |
should create bucket data
|
- |
|
Safe option
|
- |
1 |
should not override existing bucket
|
- |
|
permissions option
|
- |
1 |
should create a bucket having a list of write permissions
|
- |
|
#deleteBucket()
|
- |
2 |
should delete a bucket
|
- |
|
Safe option
|
- |
1 |
should raise a conflict error when resource has changed
|
- |
|
#deleteBuckets()
|
- |
1 |
should delete all buckets
|
- |
|
#listBuckets
|
- |
1 |
should retrieve the list of buckets
|
- |
|
#batch
|
- |
6 |
No chunked requests
|
- |
1 |
should allow batching operations
|
- |
|
Chunked requests
|
- |
1 |
should allow batching by chunks
|
- |
|
aggregate option
|
- |
4 |
Succesful publication
|
- |
4 |
No chunking
|
- |
2 |
should return an aggregated result object
|
- |
|
should contain the list of succesful publications
|
- |
|
Chunked response
|
- |
2 |
should return an aggregated result object
|
- |
|
should contain the list of succesful publications
|
- |
|
Backed off server
|
- |
1 |
should appropriately populate the backoff property
|
- |
|
Deprecated protocol version
|
- |
2 |
Soft EOL
|
- |
1 |
should warn when the server sends a deprecation Alert header
|
- |
|
Hard EOL
|
- |
1 |
should reject with a 410 Gone when hard EOL is received
|
- |
|
Limited pagination
|
- |
2 |
Limited configured server pagination
|
- |
2 |
should fetch one results page
|
- |
|
should fetch all available pages
|
- |
|
Chainable API
|
- |
65 |
.bucket()
|
- |
31 |
.getData()
|
- |
2 |
should retrieve the bucket identifier
|
- |
|
should retrieve bucket last_modified value
|
- |
|
.setData()
|
- |
3 |
should post data to the bucket
|
- |
|
should patch existing data for the bucket
|
- |
|
should post data to the default bucket
|
- |
|
.listCollections()
|
- |
1 |
should list existing collections
|
- |
|
.permissions
|
- |
3 |
.getPermissions()
|
- |
1 |
should retrieve bucket permissions
|
- |
|
.setPermissions()
|
- |
2 |
should set bucket permissions
|
- |
|
Safe option
|
- |
1 |
should check for concurrency
|
- |
|
.createCollection()
|
- |
5 |
should create a named collection
|
- |
|
should create an automatically named collection
|
- |
|
Safe option
|
- |
1 |
should not override existing collection
|
- |
|
Permissions option
|
- |
1 |
should create a collection having a list of write permissions
|
- |
|
Data option
|
- |
1 |
should create a collection having the expected data attached
|
- |
|
.deleteCollection()
|
- |
2 |
should delete a collection
|
- |
|
Safe option
|
- |
1 |
should check for concurrency
|
- |
|
.createGroup()
|
- |
5 |
should create a named group
|
- |
|
should create an automatically named group
|
- |
|
Safe option
|
- |
1 |
should not override existing group
|
- |
|
Permissions option
|
- |
1 |
should create a collection having a list of write permissions
|
- |
|
Data option
|
- |
1 |
should create a collection having the expected data attached
|
- |
|
.getGroup()
|
- |
1 |
should get a group
|
- |
|
.updateGroup()
|
- |
5 |
should update a group
|
- |
|
should patch a group
|
- |
|
Safe option
|
- |
3 |
should perform concurrency checks with last_modified
|
- |
|
should create a non-existent resource when safe is true
|
- |
|
should not override existing data with no last_modified
|
- |
|
.deleteGroup()
|
- |
2 |
should delete a group
|
- |
|
Safe option
|
- |
1 |
should check for concurrency
|
- |
|
.batch()
|
- |
2 |
should allow batching operations for current bucket
|
- |
|
Safe option
|
- |
1 |
should allow batching operations for current bucket
|
- |
|
.collection()
|
- |
34 |
test/integration_test.js |
- |
34 |
.getPermissions()
|
- |
1 |
should retrieve permissions
|
- |
|
.setPermissions()
|
- |
2 |
should set typed permissions
|
- |
|
Safe option
|
- |
1 |
should perform concurrency checks
|
- |
|
.getData()
|
- |
1 |
should retrieve collection data
|
- |
|
.setData()
|
- |
2 |
should set collection data
|
- |
|
Safe option
|
- |
1 |
should perform concurrency checks
|
- |
|
.createRecord()
|
- |
3 |
No record id provided
|
- |
2 |
should create a record
|
- |
|
Safe option
|
- |
1 |
should check for existing record
|
- |
|
Record id provided
|
- |
1 |
should create a record
|
- |
|
.updateRecord()
|
- |
6 |
should update a record
|
- |
|
should patch a record
|
- |
|
should create the record if it doesn't exist yet
|
- |
|
Safe option
|
- |
3 |
should perform concurrency checks with last_modified
|
- |
|
should create a non-existent resource when safe is true
|
- |
|
should not override existing data with no last_modified
|
- |
|
.deleteRecord()
|
- |
2 |
should delete a record
|
- |
|
Safe option
|
- |
1 |
should perform concurrency checks
|
- |
|
.getRecord()
|
- |
1 |
should retrieve a record by its id
|
- |
|
.listRecords()
|
- |
15 |
should list records
|
- |
|
should order records by field
|
- |
|
Filtering
|
- |
3 |
should filter records
|
- |
|
should properly escape unicode filters
|
- |
|
should resolve with collection last_modified value
|
- |
|
Changes
|
- |
2 |
should retrieve all records modified since provided timestamp
|
- |
|
should only list changes made after the provided timestamp
|
- |
|
Pagination
|
- |
8 |
should not paginate by default
|
- |
|
should paginate by chunks
|
- |
|
should provide a next method to load next page
|
- |
|
should resolve with an empty array on exhausted pagination
|
- |
|
should retrieve all pages
|
- |
|
should retrieve specified number of pages
|
- |
|
should allow fetching next page after last page if any
|
- |
|
should should retrieve all existing pages
|
- |
|
.batch()
|
- |
1 |
should allow batching operations in the current collection
|
- |
|
requests module
|
- |
17 |
createRequest()
|
- |
5 |
should return a POST creation request
|
- |
|
should return a PUT creation request when an id is provided
|
- |
|
should accept a headers option
|
- |
|
should accept a permissions option
|
- |
|
should support a safe option
|
- |
|
deleteRequest()
|
- |
4 |
should return a deletion request
|
- |
|
should accept a headers option
|
- |
|
should raise for safe with no last_modified passed
|
- |
|
should support a safe option with a last_modified option
|
- |
|
updateRequest()
|
- |
8 |
should return a update request
|
- |
|
should accept a headers option
|
- |
|
should accept a permissions option
|
- |
|
should accept a patch option
|
- |
|
should handle data
|
- |
|
should support a safe option with no last_modified passed
|
- |
|
should support a safe option with a last_modified passed
|
- |
|
should accept a patch option
|
- |
|
Utils
|
- |
24 |
#partition
|
partition |
2 |
should chunk array
|
- |
|
should not chunk array with n<=0
|
- |
|
#pMap
|
pMap |
4 |
should map list to aggregated results
|
- |
|
should convert sync reducing function to async
|
- |
|
should preserve order of entries
|
- |
|
should ensure order of execution
|
- |
|
#omit
|
omit |
3 |
should omit provided a single key
|
- |
|
should omit multiple keys
|
- |
|
should return source if no key is specified
|
- |
|
#qsify
|
qsify |
5 |
should generate a query string from an object
|
- |
|
should strip out undefined values
|
- |
|
should join comma-separated values
|
- |
|
should map boolean as lowercase string
|
- |
|
should escaped values
|
- |
|
#checkVersion
|
- |
2 |
should accept a version within provided range
|
- |
|
should not accept a version oustide provided range
|
- |
|
@support
|
- |
5 |
should return a function
|
- |
|
should make decorated method checking the version
|
- |
|
should make decorated method resolve on version match
|
- |
|
should make decorated method rejecting on version mismatch
|
- |
|
should check for an attached client instance
|
- |
|
@nobatch
|
- |
3 |
should return a function
|
- |
|
should make decorated method pass when not in batch
|
- |
|
should make decorated method to throw if in batch
|
- |
|