Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

can-fixture

Package Overview
Dependencies
Maintainers
11
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-fixture - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

297

doc/GREADME.md

@@ -35,3 +35,3 @@

## <code>__can-fixture__ function</code>
can-fixture intercepts an AJAX request and simulates the response with a file or function.
can-fixture intercepts an AJAX request and simulates the response with a file or function.

@@ -47,11 +47,11 @@

```js
fixture({method: "get", url: "/todos"},
function(request, response, headers, ajaxSettings){
return {
data: [
{id: 1, name: "dishes"},
{id: 2, name: "mow"}
]
};
})
fixture( { method: "get", url: "/todos" },
function( request, response, headers, ajaxSettings ) {
return {
data: [
{ id: 1, name: "dishes" },
{ id: 2, name: "mow" }
]
};
} );
```

@@ -66,4 +66,4 @@

Handles the request and provides a response. The next section details this function's use.
### <code>fixture(ajaxSettings, url)</code>

@@ -75,3 +75,3 @@

```js
fixture({url: "/tasks"}, "fixtures/tasks.json");
fixture( { url: "/tasks" }, "fixtures/tasks.json" );
```

@@ -82,3 +82,3 @@

```js
fixture({url: "/tasks/{id}"}, "fixtures/tasks/{id}.json");
fixture( { url: "/tasks/{id}" }, "fixtures/tasks/{id}.json" );
```

@@ -93,3 +93,3 @@

```js
fixture({url: "/tasks"}, {tasks: [{id: 1, complete: false}]});
fixture( { url: "/tasks" }, { tasks: [ { id: 1, complete: false } ] } );
```

@@ -104,3 +104,3 @@

```js
fixture({url: "/tasks"}, 2000);
fixture( { url: "/tasks" }, 2000 );
```

@@ -117,9 +117,9 @@

```js
fixture({url: "/tasks"}, "fixtures/tasks.json");
fixture( { url: "/tasks" }, "fixtures/tasks.json" );
$.get("/tasks") // requests fixtures/tasks.json
$.get( "/tasks" ); // requests fixtures/tasks.json
fixture({url: "/tasks"}, null);
fixture( { url: "/tasks" }, null );
$.get("/tasks") // requests /tasks
$.get( "/tasks" ); // requests /tasks
```

@@ -134,7 +134,7 @@

```js
fixture("GET /tasks", requestHandler );
fixture( "GET /tasks", requestHandler );
// is the same as
fixture({method: "get", url: "/tasks"}, requestHandler );
fixture( { method: "get", url: "/tasks" }, requestHandler );
```

@@ -151,7 +151,7 @@

```js
fixture("/tasks", requestHandler);
fixture( "/tasks", requestHandler );
// is the same as
fixture({url: "/tasks"}, requestHandler);
fixture( { url: "/tasks" }, requestHandler );
```

@@ -169,9 +169,9 @@

```js
fixture({
"POST /tasks": function(){
return {id: Math.random()}
},
"GET /tasks": {data: [{id: 1, name: "mow lawn"}]},
"/people": "fixtures/people.json"
});
fixture( {
"POST /tasks": function() {
return { id: Math.random() };
},
"GET /tasks": { data: [ { id: 1, name: "mow lawn" } ] },
"/people": "fixtures/people.json"
} );
```

@@ -186,9 +186,9 @@

```js
var todoAlgebra = new set.Algebra();
var todoStore = fixture.store([
{ id: 1, name: 'Do the dishes'},
{ id: 2, name: 'Walk the dog'}
], todoAlgebra);
const todoAlgebra = new set.Algebra();
const todoStore = fixture.store( [
{ id: 1, name: "Do the dishes" },
{ id: 2, name: "Walk the dog" }
], todoAlgebra );
fixture("/api/todos/{id}", todoStore);
fixture( "/api/todos/{id}", todoStore );
```

@@ -199,9 +199,9 @@

```js
fixture({
"GET /api/todos": todoStore.getListData,
"GET /api/todos/{id}": todoStore.getData,
"POST /api/todos": todosStore.createData,
"PUT /api/todos/{id}": todos.updateData,
"DELETE /api/todos/{id}": todos.destroyData
});
fixture( {
"GET /api/todos": todoStore.getListData,
"GET /api/todos/{id}": todoStore.getData,
"POST /api/todos": todosStore.createData,
"PUT /api/todos/{id}": todos.updateData,
"DELETE /api/todos/{id}": todos.destroyData
} );
```

@@ -218,14 +218,14 @@

```js
fixture({method: "get", url: "/todos"},
function(request, response, headers, ajaxSettings){
request //-> {
// method: "get",
// url: "/todos",
// data: {complete: true}
// }
fixture( { method: "get", url: "/todos" },
function( request, response, headers, ajaxSettings ) {
request; //-> {
// method: "get",
// url: "/todos",
// data: {complete: true}
// }
}
});
}
);
$.ajax({ method: "get", url: "/todos?complete=true" })
$.ajax( { method: "get", url: "/todos?complete=true" } );
```

@@ -236,13 +236,13 @@

```js
fixture({url: "/todos/{action}"},
function(request, response, headers, ajaxSettings){
request //-> {
// method: "post",
// url: "/todos",
// data: {action: delete}
// }
}
});
fixture( { url: "/todos/{action}" },
function( request, response, headers, ajaxSettings ) {
request; //-> {
// method: "post",
// url: "/todos",
// data: {action: delete}
// }
}
);
$.post("/todos/delete");
$.post( "/todos/delete" );
```

@@ -258,4 +258,4 @@

The settings object used to match this request.
##### <code>response(status, body, headers, statusText)</code>

@@ -269,13 +269,13 @@

```js
fixture({url: "/todos/{action}"},
function(request, response, headers, ajaxSettings){
response(
401,
{ message: "Unauthorized"},
{ "WWW-Authenticate": 'Basic realm="myRealm"'},
"unauthorized");
}
});
fixture( { url: "/todos/{action}" },
function( request, response, headers, ajaxSettings ) {
response(
401,
{ message: "Unauthorized" },
{ "WWW-Authenticate": "Basic realm=\"myRealm\"" },
"unauthorized" );
}
);
$.post("/todos/delete");
$.post( "/todos/delete" );
```

@@ -287,9 +287,12 @@

// Just body
response({ message: "Hello World"});
response( { message: "Hello World" } );
// status and body
response(401, { message: "Unauthorized"});
response( 401, { message: "Unauthorized" } );
// body and headers
response('{"message":"Unauthorized"}',{"WWW-Authenticate":'Basic realm="myRealm"'});
response( "{\"message\":\"Unauthorized\"}", { "WWW-Authenticate": "Basic realm=\"myRealm\"" } );
// status, body statusText
response(401, '{"message":"Unauthorized"}','unauthorized');
response( 401, "{\"message\":\"Unauthorized\"}", "unauthorized" );
```

@@ -310,4 +313,4 @@

- The status text of the response. Ex: ``"ok"`` for 200.
## <code>fixture.rand(min, max)</code>

@@ -320,4 +323,4 @@

```js
fixture.rand(1, 10) //-> Random number between 1 and 10 inclusive.
fixture.rand(10) //-> Random number between 0 and 10 inclusive.
fixture.rand( 1, 10 ); //-> Random number between 1 and 10 inclusive.
fixture.rand( 10 ); //-> Random number between 0 and 10 inclusive.
```

@@ -329,4 +332,4 @@

{Number} TODO describe
## <code>fixture.rand(choices, min, max)</code>

@@ -341,13 +344,13 @@

// pick a random number of items from an array
fixture.rand(["a","b","c"]) //-> ["c"]
fixture.rand(["a","b","c"]) //-> ["b","a"]
fixture.rand( [ "a", "b", "c" ] ); //-> ["c"]
fixture.rand( [ "a", "b", "c" ] ); //-> ["b","a"]
// pick one item from an array
fixture.rand(["a","b","c"],1) //-> ["c"]
fixture.rand( [ "a", "b", "c" ], 1 ); //-> ["c"]
// get one item from an array
fixture.rand(["a","b","c"],1)[0] //-> "b"
fixture.rand( [ "a", "b", "c" ], 1 )[ 0 ]; //-> "b"
// get 2 or 3 items from the array
fixture.rand(["a","b","c"],2,3) //-> ["c","a","b"]
fixture.rand( [ "a", "b", "c" ], 2, 3 ); //-> ["c","a","b"]
```

@@ -361,4 +364,4 @@

{Number} TODO describe
## <code>fixture.delay</code>

@@ -402,25 +405,25 @@

// Describe the services parameters:
var todoAlgebra = new set.Algebra({
set.props.id("_id"),
set.props.boolean("completed"),
set.props.rangeInclusive("start","end"),
set.props.sort("orderBy"),
});
const todoAlgebra = new set.Algebra(
set.props.id( "_id" ),
set.props.boolean( "completed" ),
set.props.rangeInclusive( "start", "end" ),
set.props.sort( "orderBy" )
);
// Create a store with initial data.
// Pass [] if you want it to be empty.
var todoStore = fixture.store([
{
_id : 1,
name : 'Do the dishes',
complete: true
}, {
_id : 2,
name : 'Walk the dog',
complete: false
}],
todoAlgebra );
const todoStore = fixture.store( [
{
_id: 1,
name: "Do the dishes",
complete: true
}, {
_id: 2,
name: "Walk the dog",
complete: false
} ],
todoAlgebra );
// Hookup urls to the store:
fixture("/todos/{_id}", todoStore);
fixture( "/todos/{_id}", todoStore );
```

@@ -432,4 +435,4 @@

{can-set.Algebra} A description of the service layer's parameters.
## <code>fixture.store(count, makeItems, algebra)</code>

@@ -443,19 +446,19 @@

// Describe the services parameters:
var todoAlgebra = new set.Algebra({ ... });
const todoAlgebra = new set.Algebra( /* ... */ );
// Create a store with initial data.
// Pass [] if you want it to be empty.
var todoStore = fixture.store(
1000,
function(i){
return {
_id : i+1,
name : 'Todo '+i,
complete: fixture.rand([true, false],1)[0]
}
},
todoAlgebra );
const todoStore = fixture.store(
1000,
function( i ) {
return {
_id: i + 1,
name: "Todo " + i,
complete: fixture.rand( [ true, false ], 1 )[ 0 ]
};
},
todoAlgebra );
// Hookup urls to the store:
fixture("/todos/{_id}", todoStore);
fixture( "/todos/{_id}", todoStore );
```

@@ -469,4 +472,4 @@

{can-set.Algebra} A description of the service layer's parameters.
## <code>Store</code>

@@ -484,3 +487,3 @@

```js
fixture("GET /api/todos", todoStore.getListData);
fixture( "GET /api/todos", todoStore.getListData );
```

@@ -492,4 +495,4 @@

TODO describe
### <code>Store.prototype.getData(request, response)</code>

@@ -501,3 +504,3 @@

```js
fixture("GET /api/todos/{_id}", todoStore.getData);
fixture( "GET /api/todos/{_id}", todoStore.getData );
```

@@ -509,4 +512,4 @@

TODO describe
### <code>Store.prototype.createData(request, response)</code>

@@ -518,3 +521,3 @@

```js
fixture("POST /api/todos", todoStore.createData);
fixture( "POST /api/todos", todoStore.createData );
```

@@ -526,4 +529,4 @@

TODO describe
### <code>Store.prototype.updateData(request, response)</code>

@@ -535,3 +538,3 @@

```js
fixture("PUT /api/todos/{_id}", todoStore.updateData);
fixture( "PUT /api/todos/{_id}", todoStore.updateData );
```

@@ -543,4 +546,4 @@

TODO describe
### <code>Store.prototype.destroyData(request, response)</code>

@@ -552,3 +555,3 @@

```js
fixture("DELETE /api/todos/{_id}", todoStore.destroyData)
fixture( "DELETE /api/todos/{_id}", todoStore.destroyData );
```

@@ -560,4 +563,4 @@

TODO describe
### <code>Store.prototype.reset([baseItems])</code>

@@ -570,16 +573,17 @@

// Creates a store with one item.
var todoStore = fixture.store(
[{id: 1, name: "dishes"}],
new set.Algebra());
fixture("/todos/{id}", todoStore)
todoStore.getList({}).length //-> 1
const todoStore = fixture.store(
[ { id: 1, name: "dishes" } ],
new set.Algebra() );
fixture( "/todos/{id}", todoStore );
todoStore.getList( {} ).length; //-> 1
// delete that item
$.ajax({url: "todos/1", method: "delete"}).then(function(){
return todoStore.getList({}).length //-> 0
}).then(function(){
// calling reset adds it back
todoStore.reset();
todoStore.getList({}).length //-> 1
});
$.ajax( { url: "todos/1", method: "delete" } ).then( function() {
return todoStore.getList( {} ).length; //-> 0
} ).then( function() {
// calling reset adds it back
todoStore.reset();
todoStore.getList( {} ).length; //-> 1
} );
```

@@ -589,4 +593,4 @@

describe
### <code>Store.prototype.get(params)</code>

@@ -598,3 +602,3 @@

```js
todoStore.get({id: 1}) //-> {id: 1, name: "dishes"}
todoStore.get( { id: 1 } ); //-> {id: 1, name: "dishes"}
```

@@ -604,4 +608,4 @@

describe
### <code>Store.prototype.getList(set)</code>

@@ -613,3 +617,3 @@

```js
todoStore.get({name: "dishes"}) //-> {data: [{id: 1, name: "dishes"}]}
todoStore.get( { name: "dishes" } ); //-> {data: [{id: 1, name: "dishes"}]}
```

@@ -619,2 +623,1 @@

TODO describe

@@ -17,11 +17,11 @@ @module {function} can-fixture

```js
fixture({method: "get", url: "/todos"},
function(request, response, headers, ajaxSettings){
return {
data: [
{id: 1, name: "dishes"},
{id: 2, name: "mow"}
]
};
})
fixture( { method: "get", url: "/todos" },
function( request, response, headers, ajaxSettings ) {
return {
data: [
{ id: 1, name: "dishes" },
{ id: 2, name: "mow" }
]
};
} );
```

@@ -39,3 +39,3 @@

```js
fixture({url: "/tasks"}, "fixtures/tasks.json");
fixture( { url: "/tasks" }, "fixtures/tasks.json" );
```

@@ -46,3 +46,3 @@

```js
fixture({url: "/tasks/{id}"}, "fixtures/tasks/{id}.json");
fixture( { url: "/tasks/{id}" }, "fixtures/tasks/{id}.json" );
```

@@ -55,3 +55,3 @@

```js
fixture({url: "/tasks"}, {tasks: [{id: 1, complete: false}]});
fixture( { url: "/tasks" }, { tasks: [ { id: 1, complete: false } ] } );
```

@@ -64,3 +64,3 @@

```js
fixture({url: "/tasks"}, 2000);
fixture( { url: "/tasks" }, 2000 );
```

@@ -75,9 +75,9 @@

```js
fixture({url: "/tasks"}, "fixtures/tasks.json");
fixture( { url: "/tasks" }, "fixtures/tasks.json" );
$.get("/tasks") // requests fixtures/tasks.json
$.get( "/tasks" ); // requests fixtures/tasks.json
fixture({url: "/tasks"}, null);
fixture( { url: "/tasks" }, null );
$.get("/tasks") // requests /tasks
$.get( "/tasks" ); // requests /tasks
```

@@ -90,7 +90,7 @@

```js
fixture("GET /tasks", requestHandler );
fixture( "GET /tasks", requestHandler );
// is the same as
fixture({method: "get", url: "/tasks"}, requestHandler );
fixture( { method: "get", url: "/tasks" }, requestHandler );
```

@@ -105,7 +105,7 @@

```js
fixture("/tasks", requestHandler);
fixture( "/tasks", requestHandler );
// is the same as
fixture({url: "/tasks"}, requestHandler);
fixture( { url: "/tasks" }, requestHandler );
```

@@ -118,9 +118,9 @@

```js
fixture({
"POST /tasks": function(){
return {id: Math.random()}
},
"GET /tasks": {data: [{id: 1, name: "mow lawn"}]},
"/people": "fixtures/people.json"
});
fixture( {
"POST /tasks": function() {
return { id: Math.random() };
},
"GET /tasks": { data: [ { id: 1, name: "mow lawn" } ] },
"/people": "fixtures/people.json"
} );
```

@@ -138,11 +138,11 @@

```js
var todoAlgebra = new set.Algebra(
set.props.id("id")
const todoAlgebra = new set.Algebra(
set.props.id( "id" )
);
var todoStore = fixture.store([
{ id: 1, name: 'Do the dishes'},
{ id: 2, name: 'Walk the dog'}
], todoAlgebra);
const todoStore = fixture.store( [
{ id: 1, name: "Do the dishes" },
{ id: 2, name: "Walk the dog" }
], todoAlgebra );
fixture("/api/todos/{id}", todoStore); // can also be written fixture("/api/todos", todoStore);
fixture( "/api/todos/{id}", todoStore ); // can also be written fixture("/api/todos", todoStore);
```

@@ -153,9 +153,9 @@

```js
fixture({
"GET /api/todos": todoStore.getListData,
"GET /api/todos/{id}": todoStore.getData,
"POST /api/todos": todoStore.createData,
"PUT /api/todos/{id}": todoStore.updateData,
"DELETE /api/todos/{id}": todoStore.destroyData
});
fixture( {
"GET /api/todos": todoStore.getListData,
"GET /api/todos/{id}": todoStore.getData,
"POST /api/todos": todoStore.createData,
"PUT /api/todos/{id}": todoStore.updateData,
"DELETE /api/todos/{id}": todoStore.destroyData
} );
```

@@ -162,0 +162,0 @@

@@ -10,4 +10,4 @@ @function can-fixture.rand rand

```js
fixture.rand(1, 10) //-> Random number between 1 and 10 inclusive.
fixture.rand(10) //-> Random number between 0 and 10 inclusive.
fixture.rand( 1, 10 ); //-> Random number between 1 and 10 inclusive.
fixture.rand( 10 ); //-> Random number between 0 and 10 inclusive.
```

@@ -25,13 +25,13 @@ @param {Number} [min] The lower limit of values that will be returned.

// pick a random number of items from an array
fixture.rand(["a","b","c"]) //-> ["c"]
fixture.rand(["a","b","c"]) //-> ["b","a"]
fixture.rand( [ "a", "b", "c" ] ); //-> ["c"]
fixture.rand( [ "a", "b", "c" ] ); //-> ["b","a"]
// pick one item from an array
fixture.rand(["a","b","c"],1) //-> ["c"]
fixture.rand( [ "a", "b", "c" ], 1 ); //-> ["c"]
// get one item from an array
fixture.rand(["a","b","c"],1)[0] //-> "b"
fixture.rand( [ "a", "b", "c" ], 1 )[ 0 ]; //-> "b"
// get 2 or 3 items from the array
fixture.rand(["a","b","c"],2,3) //-> ["c","a","b"]
fixture.rand( [ "a", "b", "c" ], 2, 3 ); //-> ["c","a","b"]
```

@@ -38,0 +38,0 @@ @param {Array} choices An array of values to chose from. The returned array will only include a value once.

@@ -11,25 +11,25 @@ @function can-fixture.store store

// Describe the services parameters:
var todoAlgebra = new set.Algebra({
set.props.id("_id"),
set.props.boolean("completed"),
set.props.rangeInclusive("start","end"),
set.props.sort("orderBy"),
});
const todoAlgebra = new set.Algebra(
set.props.id( "_id" ),
set.props.boolean( "completed" ),
set.props.rangeInclusive( "start", "end" ),
set.props.sort( "orderBy" ),
);
// Create a store with initial data.
// Pass [] if you want it to be empty.
var todoStore = fixture.store([
{
_id : 1,
name : 'Do the dishes',
complete: true
}, {
_id : 2,
name : 'Walk the dog',
complete: false
}],
todoAlgebra );
const todoStore = fixture.store( [
{
_id: 1,
name: "Do the dishes",
complete: true
}, {
_id: 2,
name: "Walk the dog",
complete: false
} ],
todoAlgebra );
// Hookup urls to the store:
fixture("/todos/{_id}", todoStore);
fixture( "/todos/{_id}", todoStore );
```

@@ -50,19 +50,19 @@ @param {Array} baseItems An array of items that will populate the store.

// Describe the services parameters:
var todoAlgebra = new set.Algebra({ ... });
const todoAlgebra = new set.Algebra( /* ... */ );
// Create a store with initial data.
// Pass [] if you want it to be empty.
var todoStore = fixture.store(
1000,
function(i){
return {
_id : i+1,
name : 'Todo '+i,
complete: fixture.rand([true, false],1)[0]
}
},
todoAlgebra );
const todoStore = fixture.store(
1000,
function( i ) {
return {
_id: i + 1,
name: "Todo " + i,
complete: fixture.rand( [ true, false ], 1 )[ 0 ]
};
},
todoAlgebra );
// Hookup urls to the store:
fixture("/todos/{_id}", todoStore);
fixture( "/todos/{_id}", todoStore );
```

@@ -69,0 +69,0 @@ @param {Number} count TODO describe

@@ -13,11 +13,11 @@ @typedef {Object} can-fixture/types/request request

```js
fixture("GET /todos/{id}", function(request, response){
request.url //-> "todos/5"
request.method //-> "get"
request.data //-> {id: "5", include: ["owner"]}
request.headers //-> {}
request.async //-> false
});
fixture( "GET /todos/{id}", function( request, response ) {
request.url; //-> "todos/5"
request.method; //-> "get"
request.data; //-> {id: "5", include: ["owner"]}
request.headers; //-> {}
request.async; //-> false
} );
$.get("/todos/5?include[]=owner");
$.get( "/todos/5?include[]=owner" );
```

@@ -24,0 +24,0 @@

@@ -9,14 +9,14 @@ @typedef {function(can-fixture/types/request,can-fixture.response,Object,Object)} can-fixture.requestHandler(request,response,requestHeaders,ajaxSettings) requestHandler

```js
fixture({method: "get", url: "/todos"},
function(request, response, headers, ajaxSettings){
request //-> {
// method: "get",
// url: "/todos",
// data: {complete: true}
// }
fixture( { method: "get", url: "/todos" },
function( request, response, headers, ajaxSettings ) {
request; //-> {
// method: "get",
// url: "/todos",
// data: {complete: true}
// }
}
});
}
);
$.ajax({ method: "get", url: "/todos?complete=true" })
$.ajax( { method: "get", url: "/todos?complete=true" } );
```

@@ -27,18 +27,18 @@

```js
fixture({url: "/todos/{action}"},
function(request, response, headers, ajaxSettings){
request //-> {
// method: "post",
// url: "/todos",
// data: {action: delete}
// }
}
});
fixture( { url: "/todos/{action}" },
function( request, response, headers, ajaxSettings ) {
request; //-> {
// method: "post",
// url: "/todos",
// data: {action: delete}
// }
}
);
$.post("/todos/delete");
$.post( "/todos/delete" );
```
@param {can-fixture/types/request} request Information about the request. The request's data property will contain data from the request's querystring or request body. Also
any templated values in the [can-fixture/types/ajaxSettings]'s `url` will be added.
any templated values in the [can-fixture/types/ajaxSettings]'s `url` will be added.
@param {can-fixture.response} response A callback function that provides response information.
@param {Object} requestHeaders Headers used to make the request.
@param {Object} ajaxSettings The settings object used to match this request.

@@ -11,13 +11,13 @@ @typedef {function} can-fixture.response response

```js
fixture({url: "/todos/{action}"},
function(request, response, headers, ajaxSettings){
response(
401,
{ message: "Unauthorized"},
{ "WWW-Authenticate": 'Basic realm="myRealm"'},
"unauthorized");
}
});
fixture( { url: "/todos/{action}" },
function( request, response, headers, ajaxSettings ) {
response(
401,
{ message: "Unauthorized" },
{ "WWW-Authenticate": "Basic realm=\"myRealm\"" },
"unauthorized" );
}
);
$.post("/todos/delete");
$.post( "/todos/delete" );
```

@@ -29,9 +29,12 @@

// Just body
response({ message: "Hello World"});
response( { message: "Hello World" } );
// status and body
response(401, { message: "Unauthorized"});
response( 401, { message: "Unauthorized" } );
// body and headers
response('{"message":"Unauthorized"}',{"WWW-Authenticate":'Basic realm="myRealm"'});
response( "{\"message\":\"Unauthorized\"}", { "WWW-Authenticate": "Basic realm=\"myRealm\"" } );
// status, body statusText
response(401, '{"message":"Unauthorized"}','unauthorized');
response( 401, "{\"message\":\"Unauthorized\"}", "unauthorized" );
```

@@ -38,0 +41,0 @@

@@ -9,3 +9,3 @@ @function can-fixture/StoreType.prototype.createData createData

```js
fixture("POST /api/todos", todoStore.createData);
fixture( "POST /api/todos", todoStore.createData );
```

@@ -9,3 +9,3 @@ @function can-fixture/StoreType.prototype.destroyData destroyData

```js
fixture("DELETE /api/todos/{_id}", todoStore.destroyData)
fixture( "DELETE /api/todos/{_id}", todoStore.destroyData );
```

@@ -9,3 +9,3 @@ @function can-fixture/StoreType.prototype.get get

```js
todoStore.get({id: 1}) //-> {id: 1, name: "dishes"}
todoStore.get( { id: 1 } ); //-> {id: 1, name: "dishes"}
```

@@ -9,3 +9,3 @@ @function can-fixture/StoreType.prototype.getData getData

```js
fixture("GET /api/todos/{_id}", todoStore.getData);
fixture( "GET /api/todos/{_id}", todoStore.getData );
```

@@ -9,3 +9,3 @@ @function can-fixture/StoreType.prototype.getList getList

```js
todoStore.get({name: "dishes"}) //-> {data: [{id: 1, name: "dishes"}]}
todoStore.get( { name: "dishes" } ); //-> {data: [{id: 1, name: "dishes"}]}
```

@@ -9,3 +9,3 @@ @function can-fixture/StoreType.prototype.getListData getListData

```js
fixture("GET /api/todos", todoStore.getListData);
fixture( "GET /api/todos", todoStore.getListData );
```

@@ -10,18 +10,19 @@ @function can-fixture/StoreType.prototype.reset reset

// Creates a store with one item.
var todoStore = fixture.store(
[{id: 1, name: "dishes"}],
new set.Algebra());
fixture("/todos/{id}", todoStore)
todoStore.getList({}).length //-> 1
const todoStore = fixture.store(
[ { id: 1, name: "dishes" } ],
new set.Algebra() );
fixture( "/todos/{id}", todoStore );
todoStore.getList( {} ).length; //-> 1
// delete that item
$.ajax({url: "todos/1", method: "delete"}).then(function(){
return todoStore.getList({}).length //-> 0
}).then(function(){
// calling reset adds it back
todoStore.reset();
todoStore.getList({}).length //-> 1
});
$.ajax( { url: "todos/1", method: "delete" } ).then( function() {
return todoStore.getList( {} ).length; //-> 0
} ).then( function() {
// calling reset adds it back
todoStore.reset();
todoStore.getList( {} ).length; //-> 1
} );
```
@param {Array} baseItems If provided, adds these items to the store.
This can be useful for setting up particular testing scenarios.

@@ -9,3 +9,3 @@ @function can-fixture/StoreType.prototype.updateData updateData

```js
fixture("PUT /api/todos/{_id}", todoStore.updateData);
fixture( "PUT /api/todos/{_id}", todoStore.updateData );
```
{
"name": "can-fixture",
"version": "2.0.2",
"version": "2.0.3",
"description": "Intercept AJAX requests and simulate responses.",

@@ -5,0 +5,0 @@ "main": "fixture.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc