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

can-simple-map

Package Overview
Dependencies
Maintainers
13
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-simple-map - npm Package Compare versions

Comparing version 4.3.1 to 4.3.2

90

can-simple-map_test.js

@@ -16,8 +16,9 @@ var QUnit = require('steal-qunit');

QUnit.test("instantiates and gets events", 2, function() {
QUnit.test("instantiates and gets events", function(assert) {
assert.expect(2);
var map = new SimpleMap({ age: 29 });
map.on('age', function(ev, newVal, oldVal) {
QUnit.equal(oldVal, 29);
QUnit.equal(newVal, 30);
assert.equal(oldVal, 29);
assert.equal(newVal, 30);
});

@@ -28,3 +29,3 @@

QUnit.test("trying to read constructor from refs scope is ok", function(){
QUnit.test("trying to read constructor from refs scope is ok", function(assert) {
var map = new SimpleMap();

@@ -37,16 +38,16 @@ var construct = new Observation(function(){

equal(canReflect.getValue(construct), SimpleMap);
assert.equal(canReflect.getValue(construct), SimpleMap);
});
QUnit.test("get set and serialize", function(){
QUnit.test("get set and serialize", function(assert) {
var map = new SimpleMap();
map.set("foo","bar");
QUnit.equal(map.get("foo"), "bar");
QUnit.deepEqual(map.get(), {foo: "bar"});
assert.equal(map.get("foo"), "bar");
assert.deepEqual(map.get(), {foo: "bar"});
map.set({zed: "ted"});
QUnit.deepEqual(map.get(), {foo: "bar", zed: "ted"});
assert.deepEqual(map.get(), {foo: "bar", zed: "ted"});
QUnit.deepEqual(map.serialize(), {foo: "bar", zed: "ted"});
assert.deepEqual(map.serialize(), {foo: "bar", zed: "ted"});

@@ -58,6 +59,7 @@ var deepMap = new SimpleMap({a: "b"});

QUnit.deepEqual(map.serialize(), {foo: "bar", zed: "ted", deep: {a: "b"}});
assert.deepEqual(map.serialize(), {foo: "bar", zed: "ted", deep: {a: "b"}});
});
QUnit.test("serialize and get are observable",2, function(){
QUnit.test("serialize and get are observable", function(assert) {
assert.expect(2);

@@ -73,7 +75,7 @@ var map = new SimpleMap();

canReflect.onValue(c1, function(newValue){
QUnit.deepEqual(newValue, {foo:"bar"}, "updated serialize");
assert.deepEqual(newValue, {foo:"bar"}, "updated serialize");
});
canReflect.onValue(c2, function(newValue){
QUnit.deepEqual(newValue, {foo:"bar"}, "updated get");
assert.deepEqual(newValue, {foo:"bar"}, "updated get");
});

@@ -85,3 +87,4 @@

test("works with can-reflect", 8, function(){
QUnit.test("works with can-reflect", function(assert) {
assert.expect(8);
var b = new SimpleMap({ "foo": "bar" });

@@ -94,6 +97,6 @@ // var c = new (SimpleMap.extend({

QUnit.equal( canReflect.getKeyValue(b, "foo"), "bar", "get value");
assert.equal( canReflect.getKeyValue(b, "foo"), "bar", "get value");
var handler = function(newValue){
QUnit.equal(newValue, "quux", "observed new value");
assert.equal(newValue, "quux", "observed new value");

@@ -103,7 +106,7 @@ // Turn off the "foo" handler but "thud" should still be bound.

};
QUnit.ok(!canReflect.isValueLike(b), "isValueLike is false");
QUnit.ok(canReflect.isMapLike(b), "isMapLike is true");
QUnit.ok(!canReflect.isListLike(b), "isListLike is false");
assert.ok(!canReflect.isValueLike(b), "isValueLike is false");
assert.ok(canReflect.isMapLike(b), "isMapLike is true");
assert.ok(!canReflect.isListLike(b), "isListLike is false");
QUnit.ok( !canReflect.keyHasDependencies(b, "foo"), "keyHasDependencies -- false");
assert.ok( !canReflect.keyHasDependencies(b, "foo"), "keyHasDependencies -- false");

@@ -116,3 +119,3 @@ canReflect.onKeyValue(b, "foo", handler);

QUnit.equal( canReflect.getKeyValue(b, "foo"), "quux", "bound value");
assert.equal( canReflect.getKeyValue(b, "foo"), "quux", "bound value");
// sanity checks to ensure that handler doesn't get called again.

@@ -124,27 +127,27 @@ b.attr("foo", "thud");

QUnit.test("can-reflect setKeyValue", function(){
QUnit.test("can-reflect setKeyValue", function(assert) {
var a = new SimpleMap({ "a": "b" });
canReflect.setKeyValue(a, "a", "c");
QUnit.equal(a.attr("a"), "c", "setKeyValue");
assert.equal(a.attr("a"), "c", "setKeyValue");
});
QUnit.test("can-reflect getKeyDependencies", function() {
QUnit.test("can-reflect getKeyDependencies", function(assert) {
var a = new SimpleMap({ "a": "a" });
ok(!canReflect.getKeyDependencies(a, "a"), "No dependencies before binding");
assert.ok(!canReflect.getKeyDependencies(a, "a"), "No dependencies before binding");
});
QUnit.test("registered symbols", function() {
QUnit.test("registered symbols", function(assert) {
var a = new SimpleMap({ "a": "a" });
ok(a[canSymbol.for("can.isMapLike")], "can.isMapLike");
equal(a[canSymbol.for("can.getKeyValue")]("a"), "a", "can.getKeyValue");
assert.ok(a[canSymbol.for("can.isMapLike")], "can.isMapLike");
assert.equal(a[canSymbol.for("can.getKeyValue")]("a"), "a", "can.getKeyValue");
a[canSymbol.for("can.setKeyValue")]("a", "b");
equal(a.attr("a"), "b", "can.setKeyValue");
assert.equal(a.attr("a"), "b", "can.setKeyValue");
function handler(val) {
equal(this, a);
equal(val, "c", "can.onKeyValue");
assert.equal(this, a);
assert.equal(val, "c", "can.onKeyValue");
}

@@ -159,3 +162,3 @@

QUnit.test("initialization does not cause Observation.add", function(){
QUnit.test("initialization does not cause Observation.add", function(assert) {
ObservationRecorder.start();

@@ -166,4 +169,4 @@ var m = new SimpleMap();

QUnit.equal(observationRecord.keyDependencies.size , 0, "no key deps");
QUnit.equal(observationRecord.valueDependencies.size , 0, "no value deps");
assert.equal(observationRecord.keyDependencies.size , 0, "no key deps");
assert.equal(observationRecord.valueDependencies.size , 0, "no value deps");
});

@@ -247,7 +250,8 @@

QUnit.test("don't dispatch events for sets that don't change", 2, function(){
QUnit.test("don't dispatch events for sets that don't change", function(assert) {
assert.expect(2);
var map = new SimpleMap({foo: "bar"});
canReflect.onKeyValue(map, "foo", function(newVal, oldVal){
QUnit.equal(newVal, "BAR");
QUnit.equal(oldVal,"bar");
assert.equal(newVal, "BAR");
assert.equal(oldVal,"bar");
});

@@ -258,9 +262,9 @@ map.attr("foo","bar");

QUnit.test("Reflect.hasOwnKey", function(){
QUnit.test("Reflect.hasOwnKey", function(assert) {
var map = new SimpleMap({a: undefined, b: null, c: ""});
QUnit.ok( canReflect.hasOwnKey(map,"a"), "undefined is a key");
QUnit.ok( canReflect.hasOwnKey(map,"b"), "null is a key");
QUnit.ok( canReflect.hasOwnKey(map,"c"), "empty string is a key");
QUnit.ok( !canReflect.hasOwnKey(map,"d"), "no prop is not a key");
assert.ok( canReflect.hasOwnKey(map,"a"), "undefined is a key");
assert.ok( canReflect.hasOwnKey(map,"b"), "null is a key");
assert.ok( canReflect.hasOwnKey(map,"c"), "empty string is a key");
assert.ok( !canReflect.hasOwnKey(map,"d"), "no prop is not a key");
});

@@ -267,0 +271,0 @@

{
"name": "can-simple-map",
"version": "4.3.1",
"version": "4.3.2",
"description": "A performant live-bound map",

@@ -59,3 +59,3 @@ "homepage": "https://canjs.com/doc/can-simple-map.html",

"steal": "^1.2.9",
"steal-qunit": "^1.0.1",
"steal-qunit": "^2.0.0",
"steal-tools": "^1.1.2",

@@ -62,0 +62,0 @@ "testee": "^0.9.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