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

can-route

Package Overview
Dependencies
Maintainers
13
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-route - npm Package Compare versions

Comparing version 4.3.10 to 4.3.11

test/route-define-iframe-test.js

2

package.json
{
"name": "can-route",
"version": "4.3.10",
"version": "4.3.11",
"description": "Observable front-end application routing for CanJS.",

@@ -5,0 +5,0 @@ "homepage": "https://canjs.com/doc/can-route.html",

/* jshint asi:true */
/* jshint -W079 */
require("./route-define-iframe-test");
var canRoute = require('can-route');

@@ -21,3 +22,3 @@ var QUnit = require('steal-qunit');

}
})
});

@@ -27,76 +28,4 @@ if (("onhashchange" in window)) {

var teardownRouteTest;
var setupRouteTest = function(callback){
var testarea = document.getElementById('qunit-fixture');
var iframe = document.createElement('iframe');
stop();
window.routeTestReady = function(){
var args = canReflect.toArray(arguments)
args.unshift(iframe);
callback.apply(null, args);
};
iframe.src = __dirname + "/define-testing.html?"+Math.random();
testarea.appendChild(iframe);
teardownRouteTest = function(){
setTimeout(function(){
testarea.removeChild(iframe);
setTimeout(function(){
start();
},10);
},1);
};
};
if (typeof steal !== 'undefined') {
test("listening to hashchange (#216, #124)", function () {
setupRouteTest(function (iframe, iCanRoute) {
ok(!iCanRoute.data.bla, 'Value not set yet');
iCanRoute.bind('bla', function(){
equal(iCanRoute.data.get("bla"), 'blu', 'Got route change event and value is as expected');
teardownRouteTest();
})
iCanRoute._onStartComplete = function () {
iframe.src = iframe.src + '#!bla=blu';
};
iCanRoute.start();
});
});
test("removing things from the hash", function () {
setupRouteTest(function (iframe, iCanRoute, loc, win) {
iCanRoute.serializedCompute.bind('change', function outerChange() {
equal(iCanRoute.attr('foo'), 'bar', 'expected value for foo');
iCanRoute.serializedCompute.unbind('change');
iCanRoute.serializedCompute.bind('change', function innerChange(){
equal(iCanRoute.attr('personId'), '3', 'personId');
equal(iCanRoute.attr('foo'), undefined, 'unexpected value');
iCanRoute.unbind('change');
teardownRouteTest();
});
setTimeout(function () {
iframe.contentWindow.location.hash = '#!personId=3';
}, 100);
});
iCanRoute._onStartComplete = function () {
iframe.contentWindow.location.hash = '#!foo=bar';
};
iCanRoute.start();
});
});
QUnit.asyncTest("canRoute.map: conflicting route values, hash should win (canjs/canjs#979)", function(){

@@ -125,3 +54,3 @@ mockRoute.start();

test("canRoute.map: route is initialized from URL first, then URL params are added from canRoute.data (canjs/canjs#979)", function(){
QUnit.test("canRoute.map: route is initialized from URL first, then URL params are added from canRoute.data (canjs/canjs#979)", function(){
QUnit.stop();

@@ -151,21 +80,2 @@ mockRoute.start();

test("updating the hash", function () {
setupRouteTest(function (iframe, iCanRoute, loc) {
iCanRoute._onStartComplete = function () {
var after = loc.href.substr(loc.href.indexOf("#"));
equal(after, "#!bar/" + encodeURIComponent("\/"));
teardownRouteTest();
};
iCanRoute.start();
iCanRoute.register("{type}/{id}");
iCanRoute.attr({
type: "bar",
id: "\/"
});
});
});
test("sticky enough routes (canjs#36)", function () {

@@ -192,37 +102,2 @@

test("unsticky routes", function () {
setupRouteTest(function (iframe, iCanRoute, loc) {
iCanRoute.start();
iCanRoute.register("{type}");
iCanRoute.register("{type}/{id}");
iCanRoute.attr({
type: "bar"
});
setTimeout(function () {
var after = loc.href.substr(loc.href.indexOf("#"));
equal(after, "#!bar");
iCanRoute.attr({
type: "bar",
id: "\/"
});
// check for 1 second
var time = new Date();
setTimeout(function innerTimer() {
var after = loc.href.substr(loc.href.indexOf("#"));
var isMatch = after === "#!bar/" + encodeURIComponent("\/");
var isWaitingTooLong = new Date() - time > 2000;
if (isMatch || isWaitingTooLong) {
equal(after, "#!bar/" + encodeURIComponent("\/"), "should go to type/id "+ (new Date() - time));
teardownRouteTest();
} else {
setTimeout(innerTimer, 30);
}
}, 100);
}, 100);
});
});
QUnit.asyncTest("canRoute.current is live-bindable (#1156)", function () {

@@ -321,26 +196,2 @@ mockRoute.start();

test("updating unserialized prop on bound DefineMap causes single update without a coerced string value", function() {
expect(1);
setupRouteTest(function (iframe, route) {
var appVM = new (DefineMap.extend({
action: {serialize: false, type: "*"}
}))();
route.data = appVM;
route.start();
appVM.bind('action', function(ev, newVal) {
equal(typeof newVal, 'function');
});
appVM.set('action', function() {});
// check after 30ms to see that we only have a single call
setTimeout(function() {
teardownRouteTest();
}, 5);
});
});
test("hash doesn't update to itself with a !", function() {

@@ -617,1 +468,27 @@ stop();

});
QUnit.asyncTest("updating unserialized prop on bound DefineMap causes single update without a coerced string value", function() {
expect(1);
canRoute.routes = {};
mockRoute.start();
var appVM = new (DefineMap.extend({
action: {serialize: false, type: "*"}
}))();
canRoute.data = appVM;
canRoute.start();
appVM.bind('action', function(ev, newVal) {
equal(typeof newVal, 'function');
});
appVM.set('action', function() {});
// check after 30ms to see that we only have a single call
setTimeout(function() {
mockRoute.stop();
QUnit.start();
}, 5);
});
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