Skip to content

Commit

Permalink
#34 added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
therealraw committed Aug 13, 2018
1 parent 2a9e8e9 commit f42ea49
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion docs/can-fixture.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ When adding a fixture, it will remove any identical fixtures from the list of fi
@param {can-fixture/types/ajaxSettings} ajaxSettings An object that is used to match values on an XHR object, namely the url and method. url can be templated like /todos/{_id}.
@param {can-fixture.requestHandler} requestHandler Handles the request and provides a response. The next section details this function's use.

@return {Array<can-fixture/types/ajaxSettings>} Returns an array of any fixtures that are replaced by the fixture that is added.

@signature `fixture(ajaxSettings, url)`

Redirects the request to another url. This can be useful for simulating a response with a file.
Expand All @@ -44,6 +46,8 @@ Placeholders available in the `ajaxSettings` url will be available in the redire
fixture( { url: "/tasks/{id}" }, "fixtures/tasks/{id}.json" );
```

@return {Array<can-fixture/types/ajaxSettings>} Returns an array of any fixtures that are replaced by the fixture that is added.

@signature `fixture(ajaxSettings, data)`

Responds with the `JSON.stringify` result of `data`.
Expand All @@ -52,6 +56,8 @@ Responds with the `JSON.stringify` result of `data`.
fixture( { url: "/tasks" }, { tasks: [ { id: 1, complete: false } ] } );
```

@return {Array<can-fixture/types/ajaxSettings>} Returns an array of any fixtures that are replaced by the fixture that is added.

@signature `fixture(ajaxSettings, delay)`

Delays the ajax request from being made for `delay` milliseconds.
Expand All @@ -62,6 +68,8 @@ fixture( { url: "/tasks" }, 2000 );

This doesn't simulate a response, but is useful for simulating slow connections.

@return {Array<can-fixture/types/ajaxSettings>} Returns an array of any fixtures that are replaced by the fixture that is added.

@signature `fixture(ajaxSettings, null)`

Removes the matching fixture from the list of fixtures.
Expand All @@ -76,6 +84,8 @@ fixture( { url: "/tasks" }, null );
$.get( "/tasks" ); // requests /tasks
```

@return {Array<can-fixture/types/ajaxSettings>} Returns an array of any fixtures that are replaced by the fixture that is added.

@signature `fixture(methodAndUrl, url|data|requestHandler)`

A short hand for creating an [can-fixture/types/ajaxSettings] with a `method` and `url`.
Expand All @@ -90,6 +100,8 @@ fixture( { method: "get", url: "/tasks" }, requestHandler );

The format is `METHOD URL`.

@return {Array<can-fixture/types/ajaxSettings>} Returns an array of any fixtures that are replaced by the fixture that is added.

@signature `fixture(url, url|data|requestHandler)`

A short hand for creating an [can-fixture/types/ajaxSettings] with just a `url`.
Expand All @@ -102,6 +114,8 @@ fixture( "/tasks", requestHandler );
fixture( { url: "/tasks" }, requestHandler );
```

@return {Array<can-fixture/types/ajaxSettings>} Returns an array of any fixtures that are replaced by the fixture that is added.

@signature `fixture(fixtures)`

Create multiple fixtures at once.
Expand All @@ -119,7 +133,7 @@ fixture( {
@param {Object<methodAndUrl,String|Object|can-fixture.requestHandler|can-fixture/StoreType>} fixtures A mapping of methodAndUrl to
some response argument type.


@return {Array<can-fixture/types/ajaxSettings>} Returns an array of any fixtures that are replaced by the fixture that is added.

@signature `fixture(restfulUrl, store)`

Expand Down Expand Up @@ -151,3 +165,13 @@ fixture( {

@param {String} restfulUrl The url that may include a template for the place of the ID prop. The `list` url is assumed to be `restfulUrl` with the `/{ID_PROP}` part removed, if provided; otherwise the `item` url is assumed to have the `/{ID_PROP}` part appended to the end.
@param {can-fixture/StoreType} store A store produced by [can-fixture.store].

@return {Array<can-fixture/types/ajaxSettings>} Returns an array of any fixtures that are replaced by the fixtures that are added.

@signature `fixture(ajaxSettingsArray)`

Add fixtures that have been previously removed with another call to fixture.

@param {Array<can-fixture/types/ajaxSettings>} An array of AJAX settings objects

@return {Array<can-fixture/types/ajaxSettings>} Returns an array of any fixtures that are replaced by the fixtures that are added.

0 comments on commit f42ea49

Please sign in to comment.