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

can-fixture

Package Overview
Dependencies
Maintainers
5
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 0.4.0-pre.12 to 0.4.0-pre.14

13

core.js

@@ -21,9 +21,12 @@ // Adds

store = fixture,
idProp = store.idProp;
idProp = store.idProp,
itemRegex = new RegExp('\\/\\{' + idProp+"\\}.*" ),
rootIsItemUrl = itemRegex.test(root),
getListUrl = rootIsItemUrl ? root.replace(itemRegex, "") : root,
getItemUrl = rootIsItemUrl ? root : (root.trim() + "/{" + idProp + "}");
fixture = undefined;
settings = {};
settings["GET "+root] = store.getData;
settings["DELETE "+root] = store.destroyData;
settings["PUT "+root] = store.updateData;
var getListUrl = root.replace( new RegExp('\\/\\{' + idProp+"\\}.*" ),"");
settings["GET "+getItemUrl] = store.getData;
settings["DELETE "+getItemUrl] = store.destroyData;
settings["PUT "+getItemUrl] = store.updateData;
settings["GET "+getListUrl] = store.getListData;

@@ -30,0 +33,0 @@ settings["POST "+getListUrl] = store.createData;

@@ -135,3 +135,3 @@ @module {function} can-fixture

fixture("/api/todos/{id}", todoStore);
fixture("/api/todos/{id}", todoStore); // can also be written fixture("/api/todos", todoStore);
```

@@ -151,3 +151,3 @@

@param {String} restfulUrl The `instance` url that should include a template for the place of the ID prop. The `list` url is assumed to be `restfulUrl` with the `/{ID_PROP}` part removed.
@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].
{
"name": "can-fixture",
"version": "0.4.0-pre.12",
"version": "0.4.0-pre.14",
"description": "Intercept AJAX requests and simulate responses.",

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

"dependencies": {
"can-connect": "^0.6.0-pre.15",
"can-set": "^0.6.0-pre.8",
"can-util": "^3.0.0-pre.12"
"can-connect": "^0.6.0-pre.20",
"can-set": "^0.6.0-pre.9",
"can-util": "^3.0.0-pre.50"
},

@@ -25,0 +25,0 @@ "devDependencies": {

@@ -1217,67 +1217,72 @@ var QUnit = require('steal-qunit');

test("set.Algebra CRUD works with easy hookup (#12)", 5, function(){
function makeAlgebraTest(fixtureUrl){
return function() {
var algebra = new set.Algebra(
new set.Translate("where","where"),
set.props.id("_id"),
set.props.sort('orderBy'),
set.props.enum("type", ["used","new","certified"]),
set.props.rangeInclusive("start","end")
);
var algebra = new set.Algebra(
new set.Translate("where","where"),
set.props.id("_id"),
set.props.sort('orderBy'),
set.props.enum("type", ["used","new","certified"]),
set.props.rangeInclusive("start","end")
);
var store = fixture.store([
{_id: 1, modelId: 1, year: 2013, name: "2013 Mustang", type: "used"},
{_id: 2, modelId: 1, year: 2014, name: "2014 Mustang", type: "new"},
{_id: 3, modelId: 2, year: 2013, name: "2013 Focus", type: "used"},
{_id: 4, modelId: 2, year: 2014, name: "2014 Focus", type: "certified"},
{_id: 5, modelId: 3, year: 2013, name: "2013 Altima", type: "used"},
{_id: 6, modelId: 3, year: 2014, name: "2014 Altima", type: "certified"},
{_id: 7, modelId: 4, year: 2013, name: "2013 Leaf", type: "used"},
{_id: 8, modelId: 4, year: 2014, name: "2014 Leaf", type: "used"}
], algebra);
var store = fixture.store([
{_id: 1, modelId: 1, year: 2013, name: "2013 Mustang", type: "used"},
{_id: 2, modelId: 1, year: 2014, name: "2014 Mustang", type: "new"},
{_id: 3, modelId: 2, year: 2013, name: "2013 Focus", type: "used"},
{_id: 4, modelId: 2, year: 2014, name: "2014 Focus", type: "certified"},
{_id: 5, modelId: 3, year: 2013, name: "2013 Altima", type: "used"},
{_id: 6, modelId: 3, year: 2014, name: "2014 Altima", type: "certified"},
{_id: 7, modelId: 4, year: 2013, name: "2013 Leaf", type: "used"},
{_id: 8, modelId: 4, year: 2014, name: "2014 Leaf", type: "used"}
], algebra);
fixture('/cars/{_id}', store);
fixture(fixtureUrl, store);
var findAll = function(){
return $.ajax({ url: "/cars", dataType: "json" });
};
var findAll = function(){
return $.ajax({ url: "/cars", dataType: "json" });
};
stop();
stop();
findAll().then(function(carsData) {
equal(carsData.data.length, 8, 'Got all cars');
return $.ajax({ url: "/cars/"+carsData.data[1]._id, method: "DELETE", dataType: "json" });
}).then(function() {
return findAll();
}).then(function(carsData) {
equal(carsData.data.length, 7, 'One car less');
equal(carsData.data[1].name, '2013 Focus', 'Car actually deleted');
}).then(function() {
findAll().then(function(carsData) {
equal(carsData.data.length, 8, 'Got all cars');
return $.ajax({ url: "/cars/"+carsData.data[1]._id, method: "DELETE", dataType: "json" });
}).then(function() {
return findAll();
}).then(function(carsData) {
equal(carsData.data.length, 7, 'One car less');
equal(carsData.data[1].name, '2013 Focus', 'Car actually deleted');
}).then(function() {
return $.ajax({ url: "/cars", method: "post", dataType: "json", data: {
modelId: 3,
year: 2015,
name: "2015 Altima",
type: "new"
} });
}).then(function(saved) {
return $.ajax({ url: "/cars", method: "post", dataType: "json", data: {
modelId: 3,
year: 2015,
name: "2015 Altima",
type: "new"
} });
}).then(function(saved) {
return $.ajax({ url: "/cars/"+saved._id, method: "put", dataType: "json", data: {
modelId: 3,
year: 2015,
name: '2015 Nissan Altima'
} });
}).then(function(updated) {
return findAll();
}).then(function (cars) {
equal(cars.data.length, 8, 'New car created');
return $.ajax({ url: "/cars/5", method: "get", dataType: "json" });
return $.ajax({ url: "/cars/"+saved._id, method: "put", dataType: "json", data: {
modelId: 3,
year: 2015,
name: '2015 Nissan Altima'
} });
}).then(function(updated) {
return findAll();
}).then(function (cars) {
equal(cars.data.length, 8, 'New car created');
return $.ajax({ url: "/cars/5", method: "get", dataType: "json" });
}).then(function(car){
equal(car.name, "2013 Altima", "get a single car works");
start();
});
});
}).then(function(car){
equal(car.name, "2013 Altima", "get a single car works");
start();
});
}
}
test("set.Algebra CRUD works with easy hookup (#12)", 5, makeAlgebraTest('/cars/{_id}'));
test("set.Algebra CRUD works with easy hookup and list-style url (#52)", 5, makeAlgebraTest('/cars'));
test("store.getList and store.get", function(){

@@ -1284,0 +1289,0 @@

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