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

can-connect

Package Overview
Dependencies
Maintainers
11
Versions
188
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-connect - npm Package Compare versions

Comparing version 4.0.2 to 4.0.3

2

package.json
{
"name": "can-connect",
"version": "4.0.2",
"version": "4.0.3",
"description": "Data connection middleware and utilities",

@@ -5,0 +5,0 @@ "main": "can-connect.js",

@@ -15,2 +15,3 @@ var connect = require("../can-connect");

var canReflect = require("can-reflect");
var canSymbol = require("can-symbol");

@@ -653,1 +654,64 @@ QUnit.module("can-connect/real-time",{});

});
QUnit.test("Properly inserts in an empty list", function(assert){
var done = assert.async();
assert.expect(1);
var todos = [];
var connection = connect([
function(){
return {
list: function(items) {
var list = new DefineList(items.data);
var oldSplice = list[canSymbol.for("can.splice")];
list[canSymbol.for("can.splice")] = function(index){
assert.equal(index, 0, "inserted in the 0 spot, not undefined");
oldSplice.call(this, arguments);
};
// simulate the can-connet/can/map/map behaviour
// adding the list to the listStore
connection.addListReference(list, {});
return list;
},
getListData: function(){
return Promise.resolve(todos);
},
destroyData: function() {
// simulate an empty object response from server
return Promise.resolve({});
},
updateData: function(data){
return Promise.resolve(canReflect.serialize(data));
},
createData: function(data){
return Promise.resolve(canReflect.serialize({name: data.name, id: "xyz"}));
}
};
},
dataCallbacks,
realTime,
constructor,
constructorStore
], {
queryLogic: new QueryLogic({
identity: ["id"]
})
});
connection.getList({}).then(function(list){
list.on("length", function(){
assert.ok(true, "Length should change");
});
connection.save( {name: "new-item"} );
return list;
}).then(function(){
done();
}, function(err){
setTimeout(function(){
throw err;
},1);
done();
});
});

@@ -139,2 +139,3 @@ "use strict";

function updateList(list, getRecord, currentIndex, newIndex) {
if(currentIndex === -1) { // item is not in the list

@@ -144,2 +145,4 @@

canReflect.splice(list, newIndex, 0, [getRecord()]);
} else {
canReflect.splice(list, 0, 0, [getRecord()]);
}

@@ -169,2 +172,6 @@ }

function updateListWithItem(list, recordData, currentIndex, newIndex, connection, set){
// this is cleaning up a bug with QueryLogic.index where it can return undefined
if( newIndex === undefined ) {
newIndex = -1;
}
// we are inserting right where we already are.

@@ -171,0 +178,0 @@ if(currentIndex !== -1 && (newIndex === currentIndex + 1 || newIndex === currentIndex)) {

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