BVB Source Codes

prerender Show index-spec.js Source code

Return Download prerender: download index-spec.js Source code - Download prerender Source code - Type:.js
  1. var assert = require('assert')
  2.   , sinon = require('sinon')
  3.   , prerender = require('../index')
  4.   , util = require('../lib/util')
  5.  
  6. describe ('Prerender', function(){
  7.  
  8.   describe('#util', function(){
  9.  
  10.     var sandbox;
  11.  
  12.     beforeEach(function () {
  13.       sandbox = sinon.sandbox.create();
  14.     });
  15.  
  16.     afterEach(function () {
  17.       sandbox.restore();
  18.     });
  19.  
  20.     it('should remove the / from the beginning of the URL if present', function(){
  21.       var req = { url: '/http://www.example.com/'};
  22.  
  23.       var url = util.getUrl(req);
  24.  
  25.       assert.equal(url, 'http://www.example.com/');
  26.  
  27.     });
  28.  
  29.     it('should return the correct URL for #! URLs without query strings', function(){
  30.       var req = { url: 'http://www.example.com/?_escaped_fragment_=/user/1'};
  31.  
  32.       var url = util.getUrl(req);
  33.  
  34.       assert.equal(url, 'http://www.example.com/#!/user/1');
  35.  
  36.     });
  37.  
  38.     it('should return the correct URL for #! URLs with query strings', function(){
  39.       var req = { url: 'http://www.example.com/?_escaped_fragment_=/user/1&param1=yes&param2=no'};
  40.  
  41.       var url = util.getUrl(req);
  42.  
  43.       assert.equal(url, 'http://www.example.com/?param1=yes&param2=no#!/user/1');
  44.  
  45.     });
  46.  
  47.     it('should return the correct URL for #! URLs if query string is before hash', function(){
  48.       var req = { url: 'http://www.example.com/?param1=yes&param2=no&_escaped_fragment_=/user/1'};
  49.  
  50.       var url = util.getUrl(req);
  51.  
  52.       assert.equal(url, 'http://www.example.com/?param1=yes&param2=no#!/user/1');
  53.  
  54.     });
  55.  
  56.     it('should return the correct URL for #! URLs that are encoded with another ?', function(){
  57.       var req = { url: 'http://www.example.com/?_escaped_fragment_=%2Fuser%2F1%3Fparam1%3Dyes%26param2%3Dno'};
  58.  
  59.       var url = util.getUrl(req);
  60.  
  61.       assert.equal(url, 'http://www.example.com/?param1=yes&param2=no#!/user/1');
  62.  
  63.     });
  64.  
  65.     it('should return the correct URL for html5 push state URLs', function(){
  66.       var req = { url: 'http://www.example.com/user/1?_escaped_fragment_='};
  67.  
  68.       var url = util.getUrl(req);
  69.  
  70.       assert.equal(url, 'http://www.example.com/user/1');
  71.  
  72.     });
  73.  
  74.     it('should return the correct URL for html5 push state URLs with query strings', function(){
  75.       var req = { url: 'http://www.example.com/user/1?param1=yes&param2=no&_escaped_fragment_='};
  76.  
  77.       var url = util.getUrl(req);
  78.  
  79.       assert.equal(url, 'http://www.example.com/user/1?param1=yes&param2=no');
  80.  
  81.     });
  82.  
  83.     it('should fix incorrect html5 URL that Bing accesses', function(){
  84.       var req = { url: 'http://www.example.com/?&_escaped_fragment_='};
  85.  
  86.       var url = util.getUrl(req);
  87.  
  88.       assert.equal(url, 'http://www.example.com/');
  89.  
  90.     });
  91.  
  92.  
  93.     it('should encode # correctly in URLs that do not use the #!', function(){
  94.       var req = { url: 'http://www.example.com/productNumber=123%23456?_escaped_fragment_='};
  95.  
  96.       var url = util.getUrl(req);
  97.  
  98.       assert.equal(url, 'http://www.example.com/productNumber=123%23456');
  99.  
  100.     });
  101.  
  102.     it('should not encode non-english characters', function() {
  103.       var req = { url: 'http://www.example.com/賰丕賱賷賮賵乇賳賷丕?_escaped_fragment_='};
  104.  
  105.       var url = util.getUrl(req);
  106.  
  107.       assert.equal(url, 'http://www.example.com/賰丕賱賷賮賵乇賳賷丕');
  108.     });
  109.   });
  110. });
  111.  
downloadindex-spec.js Source code - Download prerender Source code
Related Source Codes/Software:
libsodium - A modern and easy-to-use crypto library. 2017-01-09
Side-Menu.Android - Side menu with some categories to choose. ... 2017-01-09
docker-gitlab - Dockerized GitLab http://www.da... 2017-01-09
sinon - Test spies, stubs and mocks for JavaScript. ... 2017-01-09
in-view - Get notified when a DOM element enters or exits th... 2017-01-09
falcon - Falcon is a low-level, high-performance Python fra... 2017-01-09
ImageOptim - GUI image optimizer for Mac htt... 2017-01-09
node-style-guide - A guide for styling your node.js / JavaScript code... 2017-01-09
FDFullscreenPopGesture - A UINavigationController's category to enable full... 2017-01-10
Gource - oftware version control visualization ... 2017-01-10
discover-flask - Full Stack Web Development with Flask. ... 2017-01-12
spring-mvc-showcase - Demonstrates the features of the Spring MVC web fr... 2017-01-12
tushare - TuShare is a utility for crawling historical data ... 2017-01-12
raml-spec - RAML Specification http://raml.... 2017-01-12
android-stackblur - Android StackBlur is a library that can perform a ... 2017-01-12
sound-redux - A Soundcloud client built with React / Redux ... 2017-01-12
httpstat - curl statistics made simple 2017-01-12
vim - Vim configuration file and plug-ins 2017-01-12
appframework - The definitive HTML5 mobile javascript framework ... 2017-01-12
BaiduExporter - Assistant for Baidu to export download links to ar... 2017-01-11

 Back to top