mirror of
https://github.com/devbridge/jQuery-Autocomplete.git
synced 2024-11-09 14:50:57 +00:00
Update Jasmine to version 2.0.
This commit is contained in:
parent
3cb2fc6203
commit
3f71c720a3
9190
scripts/jquery-2.1.1.js
vendored
Normal file
9190
scripts/jquery-2.1.1.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
/*!
|
||||
* MockJax - jQuery Plugin to Mock Ajax requests
|
||||
*
|
||||
* Version: 1.5.1
|
||||
* Version: 1.5.3
|
||||
* Released:
|
||||
* Home: http://github.com/appendto/jquery-mockjax
|
||||
* Author: Jonathan Sharp (http://jdsharp.com)
|
||||
@ -14,13 +14,14 @@
|
||||
(function($) {
|
||||
var _ajax = $.ajax,
|
||||
mockHandlers = [],
|
||||
CALLBACK_REGEX = /=\?(&|$)/,
|
||||
mockedAjaxCalls = [],
|
||||
CALLBACK_REGEX = /=\?(&|$)/,
|
||||
jsc = (new Date()).getTime();
|
||||
|
||||
|
||||
// Parse the given XML string.
|
||||
|
||||
// Parse the given XML string.
|
||||
function parseXML(xml) {
|
||||
if ( window['DOMParser'] == undefined && window.ActiveXObject ) {
|
||||
if ( window.DOMParser == undefined && window.ActiveXObject ) {
|
||||
DOMParser = function() { };
|
||||
DOMParser.prototype.parseFromString = function( xmlString ) {
|
||||
var doc = new ActiveXObject('Microsoft.XMLDOM');
|
||||
@ -31,7 +32,7 @@
|
||||
}
|
||||
|
||||
try {
|
||||
var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' );
|
||||
var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' );
|
||||
if ( $.isXMLDoc( xmlDoc ) ) {
|
||||
var err = $('parsererror', xmlDoc);
|
||||
if ( err.length == 1 ) {
|
||||
@ -40,12 +41,12 @@
|
||||
} else {
|
||||
throw('Unable to parse XML');
|
||||
}
|
||||
return xmlDoc;
|
||||
} catch( e ) {
|
||||
var msg = ( e.name == undefined ? e : e.name + ': ' + e.message );
|
||||
$(document).trigger('xmlParseError', [ msg ]);
|
||||
return undefined;
|
||||
}
|
||||
return xmlDoc;
|
||||
}
|
||||
|
||||
// Trigger a jQuery event
|
||||
@ -53,31 +54,32 @@
|
||||
(s.context ? $(s.context) : $.event).trigger(type, args);
|
||||
}
|
||||
|
||||
// Check if the data field on the mock handler and the request match. This
|
||||
// Check if the data field on the mock handler and the request match. This
|
||||
// can be used to restrict a mock handler to being used only when a certain
|
||||
// set of data is passed to it.
|
||||
function isMockDataEqual( mock, live ) {
|
||||
var identical = false;
|
||||
var identical = true;
|
||||
// Test for situations where the data is a querystring (not an object)
|
||||
if (typeof live === 'string') {
|
||||
// Querystring may be a regex
|
||||
return $.isFunction( mock.test ) ? mock.test(live) : mock == live;
|
||||
}
|
||||
$.each(mock, function(k, v) {
|
||||
$.each(mock, function(k) {
|
||||
if ( live[k] === undefined ) {
|
||||
identical = false;
|
||||
return identical;
|
||||
} else {
|
||||
identical = true;
|
||||
if ( typeof live[k] == 'object' ) {
|
||||
return isMockDataEqual(mock[k], live[k]);
|
||||
} else {
|
||||
if ( $.isFunction( mock[k].test ) ) {
|
||||
identical = mock[k].test(live[k]);
|
||||
} else {
|
||||
identical = ( mock[k] == live[k] );
|
||||
if ( typeof live[k] === 'object' && live[k] !== null ) {
|
||||
if ( identical && $.isArray( live[k] ) ) {
|
||||
identical = $.isArray( mock[k] ) && live[k].length === mock[k].length;
|
||||
}
|
||||
identical = identical && isMockDataEqual(mock[k], live[k]);
|
||||
} else {
|
||||
if ( mock[k] && $.isFunction( mock[k].test ) ) {
|
||||
identical = identical && mock[k].test(live[k]);
|
||||
} else {
|
||||
identical = identical && ( mock[k] == live[k] );
|
||||
}
|
||||
return identical;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -85,6 +87,11 @@
|
||||
return identical;
|
||||
}
|
||||
|
||||
// See if a mock handler property matches the default settings
|
||||
function isDefaultSetting(handler, property) {
|
||||
return handler[property] === $.mockjaxSettings[property];
|
||||
}
|
||||
|
||||
// Check the given handler should mock the given request
|
||||
function getMockForRequest( handler, requestSettings ) {
|
||||
// If the mock was registered with a function, let the function decide if we
|
||||
@ -103,22 +110,22 @@
|
||||
} else {
|
||||
// Look for a simple wildcard '*' or a direct URL match
|
||||
var star = handler.url.indexOf('*');
|
||||
if (handler.url !== requestSettings.url && star === -1 ||
|
||||
!new RegExp(handler.url.replace(/[-[\]{}()+?.,\\^$|#\s]/g, "\\$&").replace('*', '.+')).test(requestSettings.url)) {
|
||||
if (handler.url !== requestSettings.url && star === -1 ||
|
||||
!new RegExp(handler.url.replace(/[-[\]{}()+?.,\\^$|#\s]/g, "\\$&").replace(/\*/g, '.+')).test(requestSettings.url)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Inspect the data submitted in the request (either POST body or GET query string)
|
||||
if ( handler.data && requestSettings.data ) {
|
||||
if ( !isMockDataEqual(handler.data, requestSettings.data) ) {
|
||||
if ( handler.data ) {
|
||||
if ( ! requestSettings.data || !isMockDataEqual(handler.data, requestSettings.data) ) {
|
||||
// They're not identical, do not mock this request
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// Inspect the request type
|
||||
if ( handler && handler.type &&
|
||||
handler.type.toLowerCase() != requestSettings.type.toLowerCase() ) {
|
||||
if ( handler && handler.type &&
|
||||
handler.type.toLowerCase() != requestSettings.type.toLowerCase() ) {
|
||||
// The request type doesn't match (GET vs. POST)
|
||||
return null;
|
||||
}
|
||||
@ -126,14 +133,6 @@
|
||||
return handler;
|
||||
}
|
||||
|
||||
// If logging is enabled, log the mock to the console
|
||||
function logMock( mockHandler, requestSettings ) {
|
||||
var c = $.extend({}, $.mockjaxSettings, mockHandler);
|
||||
if ( c.log && $.isFunction(c.log) ) {
|
||||
c.log('MOCK ' + requestSettings.type.toUpperCase() + ': ' + requestSettings.url, $.extend({}, requestSettings));
|
||||
}
|
||||
}
|
||||
|
||||
// Process the xhr objects send operation
|
||||
function _xhrSend(mockHandler, requestSettings, origSettings) {
|
||||
|
||||
@ -141,10 +140,12 @@
|
||||
var process = (function(that) {
|
||||
return function() {
|
||||
return (function() {
|
||||
var onReady;
|
||||
|
||||
// The request has returned
|
||||
this.status = mockHandler.status;
|
||||
this.statusText = mockHandler.statusText;
|
||||
this.readyState = 4;
|
||||
this.status = mockHandler.status;
|
||||
this.statusText = mockHandler.statusText;
|
||||
this.readyState = 4;
|
||||
|
||||
// We have an executable function, call it to give
|
||||
// the mock handler a chance to update it's data
|
||||
@ -158,6 +159,8 @@
|
||||
} else if ( requestSettings.dataType == 'xml' ) {
|
||||
if ( typeof mockHandler.responseXML == 'string' ) {
|
||||
this.responseXML = parseXML(mockHandler.responseXML);
|
||||
//in jQuery 1.9.1+, responseXML is processed differently and relies on responseText
|
||||
this.responseText = mockHandler.responseXML;
|
||||
} else {
|
||||
this.responseXML = mockHandler.responseXML;
|
||||
}
|
||||
@ -170,12 +173,15 @@
|
||||
if( typeof mockHandler.statusText === "string") {
|
||||
this.statusText = mockHandler.statusText;
|
||||
}
|
||||
// jQuery 2.0 renamed onreadystatechange to onload
|
||||
onReady = this.onreadystatechange || this.onload;
|
||||
|
||||
// jQuery < 1.4 doesn't have onreadystate change for xhr
|
||||
if ( $.isFunction(this.onreadystatechange) ) {
|
||||
if ( $.isFunction( onReady ) ) {
|
||||
if( mockHandler.isTimeout) {
|
||||
this.status = -1;
|
||||
}
|
||||
this.onreadystatechange( mockHandler.isTimeout ? 'timeout' : undefined );
|
||||
onReady.call( this, mockHandler.isTimeout ? 'timeout' : undefined );
|
||||
} else if ( mockHandler.isTimeout ) {
|
||||
// Fix for 1.3.2 timeout to keep success from firing.
|
||||
this.status = -1;
|
||||
@ -192,11 +198,17 @@
|
||||
type: mockHandler.proxyType,
|
||||
data: mockHandler.data,
|
||||
dataType: requestSettings.dataType === "script" ? "text/plain" : requestSettings.dataType,
|
||||
complete: function(xhr, txt) {
|
||||
complete: function(xhr) {
|
||||
mockHandler.responseXML = xhr.responseXML;
|
||||
mockHandler.responseText = xhr.responseText;
|
||||
mockHandler.status = xhr.status;
|
||||
mockHandler.statusText = xhr.statusText;
|
||||
// Don't override the handler status/statusText if it's specified by the config
|
||||
if (isDefaultSetting(mockHandler, 'status')) {
|
||||
mockHandler.status = xhr.status;
|
||||
}
|
||||
if (isDefaultSetting(mockHandler, 'statusText')) {
|
||||
mockHandler.statusText = xhr.statusText;
|
||||
}
|
||||
|
||||
this.responseTimer = setTimeout(process, mockHandler.responseTime || 0);
|
||||
}
|
||||
});
|
||||
@ -270,7 +282,7 @@
|
||||
|
||||
requestSettings.dataType = "json";
|
||||
if(requestSettings.data && CALLBACK_REGEX.test(requestSettings.data) || CALLBACK_REGEX.test(requestSettings.url)) {
|
||||
createJsonpCallback(requestSettings, mockHandler);
|
||||
createJsonpCallback(requestSettings, mockHandler, origSettings);
|
||||
|
||||
// We need to make sure
|
||||
// that a JSONP style response is executed properly
|
||||
@ -283,7 +295,7 @@
|
||||
if(requestSettings.type.toUpperCase() === "GET" && remote ) {
|
||||
var newMockReturn = processJsonpRequest( requestSettings, mockHandler, origSettings );
|
||||
|
||||
// Check if we are supposed to return a Deferred back to the mock call, or just
|
||||
// Check if we are supposed to return a Deferred back to the mock call, or just
|
||||
// signal success
|
||||
if(newMockReturn) {
|
||||
return newMockReturn;
|
||||
@ -299,14 +311,14 @@
|
||||
function processJsonpUrl( requestSettings ) {
|
||||
if ( requestSettings.type.toUpperCase() === "GET" ) {
|
||||
if ( !CALLBACK_REGEX.test( requestSettings.url ) ) {
|
||||
requestSettings.url += (/\?/.test( requestSettings.url ) ? "&" : "?") +
|
||||
requestSettings.url += (/\?/.test( requestSettings.url ) ? "&" : "?") +
|
||||
(requestSettings.jsonp || "callback") + "=?";
|
||||
}
|
||||
} else if ( !requestSettings.data || !CALLBACK_REGEX.test(requestSettings.data) ) {
|
||||
requestSettings.data = (requestSettings.data ? requestSettings.data + "&" : "") + (requestSettings.jsonp || "callback") + "=?";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Process a JSONP request by evaluating the mocked response text
|
||||
function processJsonpRequest( requestSettings, mockHandler, origSettings ) {
|
||||
// Synthesize the mock request for adding a script tag
|
||||
@ -328,8 +340,8 @@
|
||||
}
|
||||
|
||||
// Successful response
|
||||
jsonpSuccess( requestSettings, mockHandler );
|
||||
jsonpComplete( requestSettings, mockHandler );
|
||||
jsonpSuccess( requestSettings, callbackContext, mockHandler );
|
||||
jsonpComplete( requestSettings, callbackContext, mockHandler );
|
||||
|
||||
// If we are running under jQuery 1.5+, return a deferred object
|
||||
if($.Deferred){
|
||||
@ -346,8 +358,9 @@
|
||||
|
||||
|
||||
// Create the required JSONP callback function for the request
|
||||
function createJsonpCallback( requestSettings, mockHandler ) {
|
||||
jsonp = requestSettings.jsonpCallback || ("jsonp" + jsc++);
|
||||
function createJsonpCallback( requestSettings, mockHandler, origSettings ) {
|
||||
var callbackContext = origSettings && origSettings.context || requestSettings;
|
||||
var jsonp = requestSettings.jsonpCallback || ("jsonp" + jsc++);
|
||||
|
||||
// Replace the =? sequence both in the query string and the data
|
||||
if ( requestSettings.data ) {
|
||||
@ -360,8 +373,8 @@
|
||||
// Handle JSONP-style loading
|
||||
window[ jsonp ] = window[ jsonp ] || function( tmp ) {
|
||||
data = tmp;
|
||||
jsonpSuccess( requestSettings, mockHandler );
|
||||
jsonpComplete( requestSettings, mockHandler );
|
||||
jsonpSuccess( requestSettings, callbackContext, mockHandler );
|
||||
jsonpComplete( requestSettings, callbackContext, mockHandler );
|
||||
// Garbage collect
|
||||
window[ jsonp ] = undefined;
|
||||
|
||||
@ -376,10 +389,10 @@
|
||||
}
|
||||
|
||||
// The JSONP request was successful
|
||||
function jsonpSuccess(requestSettings, mockHandler) {
|
||||
function jsonpSuccess(requestSettings, callbackContext, mockHandler) {
|
||||
// If a local callback was specified, fire it and pass it the data
|
||||
if ( requestSettings.success ) {
|
||||
requestSettings.success.call( callbackContext, ( mockHandler.response ? mockHandler.response.toString() : mockHandler.responseText || ''), status, {} );
|
||||
requestSettings.success.call( callbackContext, mockHandler.responseText || "", status, {} );
|
||||
}
|
||||
|
||||
// Fire the global callback
|
||||
@ -389,7 +402,7 @@
|
||||
}
|
||||
|
||||
// The JSONP request was completed
|
||||
function jsonpComplete(requestSettings, mockHandler) {
|
||||
function jsonpComplete(requestSettings, callbackContext) {
|
||||
// Process result
|
||||
if ( requestSettings.complete ) {
|
||||
requestSettings.complete.call( callbackContext, {} , status );
|
||||
@ -407,7 +420,7 @@
|
||||
}
|
||||
|
||||
|
||||
// The core $.ajax replacement.
|
||||
// The core $.ajax replacement.
|
||||
function handleAjax( url, origSettings ) {
|
||||
var mockRequest, requestSettings, mockHandler;
|
||||
|
||||
@ -417,9 +430,10 @@
|
||||
url = undefined;
|
||||
} else {
|
||||
// work around to support 1.5 signature
|
||||
origSettings = origSettings || {};
|
||||
origSettings.url = url;
|
||||
}
|
||||
|
||||
|
||||
// Extend the original settings for the request
|
||||
requestSettings = $.extend(true, {}, $.ajaxSettings, origSettings);
|
||||
|
||||
@ -429,18 +443,20 @@
|
||||
if ( !mockHandlers[k] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
mockHandler = getMockForRequest( mockHandlers[k], requestSettings );
|
||||
if(!mockHandler) {
|
||||
// No valid mock found for this request
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle console logging
|
||||
logMock( mockHandler, requestSettings );
|
||||
mockedAjaxCalls.push(requestSettings);
|
||||
|
||||
// If logging is enabled, log the mock to the console
|
||||
$.mockjaxSettings.log( mockHandler, requestSettings );
|
||||
|
||||
|
||||
if ( requestSettings.dataType === "jsonp" ) {
|
||||
if ( requestSettings.dataType && requestSettings.dataType.toUpperCase() === 'JSONP' ) {
|
||||
if ((mockRequest = processJsonpMock( requestSettings, mockHandler, origSettings ))) {
|
||||
// This mock will handle the JSONP request
|
||||
return mockRequest;
|
||||
@ -455,55 +471,60 @@
|
||||
mockHandler.timeout = requestSettings.timeout;
|
||||
mockHandler.global = requestSettings.global;
|
||||
|
||||
copyUrlParameters(mockHandler, origSettings);
|
||||
copyUrlParameters(mockHandler, origSettings);
|
||||
|
||||
(function(mockHandler, requestSettings, origSettings, origHandler) {
|
||||
mockRequest = _ajax.call($, $.extend(true, {}, origSettings, {
|
||||
// Mock the XHR object
|
||||
xhr: function() { return xhr( mockHandler, requestSettings, origSettings, origHandler ) }
|
||||
xhr: function() { return xhr( mockHandler, requestSettings, origSettings, origHandler ); }
|
||||
}));
|
||||
})(mockHandler, requestSettings, origSettings, mockHandlers[k]);
|
||||
|
||||
return mockRequest;
|
||||
}
|
||||
|
||||
// We don't have a mock request, trigger a normal request
|
||||
return _ajax.apply($, [origSettings]);
|
||||
// We don't have a mock request
|
||||
if($.mockjaxSettings.throwUnmocked === true) {
|
||||
throw('AJAX not mocked: ' + origSettings.url);
|
||||
}
|
||||
else { // trigger a normal request
|
||||
return _ajax.apply($, [origSettings]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies URL parameter values if they were captured by a regular expression
|
||||
* @param {Object} mockHandler
|
||||
* @param {Object} origSettings
|
||||
*/
|
||||
function copyUrlParameters(mockHandler, origSettings) {
|
||||
//parameters aren't captured if the URL isn't a RegExp
|
||||
if (!mockHandler.url instanceof RegExp) {
|
||||
return;
|
||||
}
|
||||
//if no URL params were defined on the handler, don't attempt a capture
|
||||
if (!mockHandler.hasOwnProperty('urlParams')) {
|
||||
return;
|
||||
}
|
||||
var captures = mockHandler.url.exec(origSettings.url);
|
||||
//the whole RegExp match is always the first value in the capture results
|
||||
if (captures.length === 1) {
|
||||
return;
|
||||
}
|
||||
captures.shift();
|
||||
//use handler params as keys and capture resuts as values
|
||||
var i = 0,
|
||||
capturesLength = captures.length,
|
||||
paramsLength = mockHandler.urlParams.length,
|
||||
//in case the number of params specified is less than actual captures
|
||||
maxIterations = Math.min(capturesLength, paramsLength),
|
||||
paramValues = {};
|
||||
for (i; i < maxIterations; i++) {
|
||||
var key = mockHandler.urlParams[i];
|
||||
paramValues[key] = captures[i];
|
||||
}
|
||||
origSettings.urlParams = paramValues;
|
||||
}
|
||||
/**
|
||||
* Copies URL parameter values if they were captured by a regular expression
|
||||
* @param {Object} mockHandler
|
||||
* @param {Object} origSettings
|
||||
*/
|
||||
function copyUrlParameters(mockHandler, origSettings) {
|
||||
//parameters aren't captured if the URL isn't a RegExp
|
||||
if (!(mockHandler.url instanceof RegExp)) {
|
||||
return;
|
||||
}
|
||||
//if no URL params were defined on the handler, don't attempt a capture
|
||||
if (!mockHandler.hasOwnProperty('urlParams')) {
|
||||
return;
|
||||
}
|
||||
var captures = mockHandler.url.exec(origSettings.url);
|
||||
//the whole RegExp match is always the first value in the capture results
|
||||
if (captures.length === 1) {
|
||||
return;
|
||||
}
|
||||
captures.shift();
|
||||
//use handler params as keys and capture resuts as values
|
||||
var i = 0,
|
||||
capturesLength = captures.length,
|
||||
paramsLength = mockHandler.urlParams.length,
|
||||
//in case the number of params specified is less than actual captures
|
||||
maxIterations = Math.min(capturesLength, paramsLength),
|
||||
paramValues = {};
|
||||
for (i; i < maxIterations; i++) {
|
||||
var key = mockHandler.urlParams[i];
|
||||
paramValues[key] = captures[i];
|
||||
}
|
||||
origSettings.urlParams = paramValues;
|
||||
}
|
||||
|
||||
|
||||
// Public
|
||||
@ -515,29 +536,41 @@
|
||||
$.mockjaxSettings = {
|
||||
//url: null,
|
||||
//type: 'GET',
|
||||
log: function( msg ) {
|
||||
if (window['console'] && window.console.log) {
|
||||
if (!Function.prototype.bind) {
|
||||
console.log(Array.prototype.slice.call(arguments).join(', '));
|
||||
return;
|
||||
log: function( mockHandler, requestSettings ) {
|
||||
if ( mockHandler.logging === false ||
|
||||
( typeof mockHandler.logging === 'undefined' && $.mockjaxSettings.logging === false ) ) {
|
||||
return;
|
||||
}
|
||||
if ( window.console && console.log ) {
|
||||
var message = 'MOCK ' + requestSettings.type.toUpperCase() + ': ' + requestSettings.url;
|
||||
var request = $.extend({}, requestSettings);
|
||||
|
||||
if (typeof console.log === 'function') {
|
||||
console.log(message, request);
|
||||
} else {
|
||||
try {
|
||||
console.log( message + ' ' + JSON.stringify(request) );
|
||||
} catch (e) {
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
var log = Function.prototype.bind.call(console.log, console);
|
||||
log.apply(console, arguments);
|
||||
}
|
||||
},
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
responseTime: 500,
|
||||
isTimeout: false,
|
||||
contentType: 'text/plain',
|
||||
response: '',
|
||||
responseText: '',
|
||||
responseXML: '',
|
||||
proxy: '',
|
||||
proxyType: 'GET',
|
||||
logging: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
responseTime: 500,
|
||||
isTimeout: false,
|
||||
throwUnmocked: false,
|
||||
contentType: 'text/plain',
|
||||
response: '',
|
||||
responseText: '',
|
||||
responseXML: '',
|
||||
proxy: '',
|
||||
proxyType: 'GET',
|
||||
|
||||
lastModified: null,
|
||||
etag: '',
|
||||
lastModified: null,
|
||||
etag: '',
|
||||
headers: {
|
||||
etag: 'IJF@H#@923uf8023hFO@I#H#',
|
||||
'content-type' : 'text/plain'
|
||||
@ -555,10 +588,14 @@
|
||||
} else {
|
||||
mockHandlers = [];
|
||||
}
|
||||
mockedAjaxCalls = [];
|
||||
};
|
||||
$.mockjax.handler = function(i) {
|
||||
if ( arguments.length == 1 ) {
|
||||
if ( arguments.length == 1 ) {
|
||||
return mockHandlers[i];
|
||||
}
|
||||
};
|
||||
$.mockjax.mockedAjaxCalls = function() {
|
||||
return mockedAjaxCalls;
|
||||
};
|
||||
})(jQuery);
|
@ -1,6 +1,46 @@
|
||||
/*jslint vars: true*/
|
||||
/*global describe, it, expect, waits, waitsFor, runs, afterEach, spyOn, $*/
|
||||
|
||||
describe('Async Tests', function(){
|
||||
|
||||
var input = document.createElement('input'),
|
||||
startQuery,
|
||||
ajaxExecuted = false,
|
||||
autocomplete = new $.Autocomplete(input, {
|
||||
serviceUrl: '/test',
|
||||
onSearchStart: function (params) {
|
||||
startQuery = params.query;
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(function (done){
|
||||
$.mockjax({
|
||||
url: '/test',
|
||||
responseTime: 50,
|
||||
response: function (settings) {
|
||||
ajaxExecuted = true;
|
||||
var query = settings.data.query,
|
||||
response = {
|
||||
query: query,
|
||||
suggestions: []
|
||||
};
|
||||
this.responseText = JSON.stringify(response);
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
input.value = 'A';
|
||||
autocomplete.onValueChange();
|
||||
});
|
||||
|
||||
console.debug('BEFOREEACH', beforeEach);
|
||||
|
||||
it('Should execute onSearchStart', function () {
|
||||
expect(ajaxExecuted).toBe(true);
|
||||
expect(startQuery).toBe('A');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Autocomplete', function () {
|
||||
'use strict';
|
||||
|
||||
@ -95,44 +135,6 @@ describe('Autocomplete', function () {
|
||||
expect(autocomplete.options.lookup[1].value).toBe('B');
|
||||
});
|
||||
|
||||
it('Should execute onSearchStart', function () {
|
||||
var input = document.createElement('input'),
|
||||
startQuery,
|
||||
ajaxExecuted = false,
|
||||
autocomplete = new $.Autocomplete(input, {
|
||||
serviceUrl: '/test',
|
||||
onSearchStart: function (params) {
|
||||
startQuery = params.query;
|
||||
}
|
||||
});
|
||||
|
||||
$.mockjax({
|
||||
url: '/test',
|
||||
responseTime: 50,
|
||||
response: function (settings) {
|
||||
ajaxExecuted = true;
|
||||
var query = settings.data.query,
|
||||
response = {
|
||||
query: query,
|
||||
suggestions: []
|
||||
};
|
||||
this.responseText = JSON.stringify(response);
|
||||
}
|
||||
});
|
||||
|
||||
input.value = 'A';
|
||||
autocomplete.onValueChange();
|
||||
|
||||
waitsFor(function () {
|
||||
return ajaxExecuted;
|
||||
}, 'Ajax call never completed.', 100);
|
||||
|
||||
runs(function () {
|
||||
expect(ajaxExecuted).toBe(true);
|
||||
expect(startQuery).toBe('A');
|
||||
});
|
||||
});
|
||||
|
||||
it('Should execute onSearchComplete', function () {
|
||||
var input = document.createElement('input'),
|
||||
completeQuery,
|
||||
|
181
spec/lib/jasmine-2.0.1/boot.js
Normal file
181
spec/lib/jasmine-2.0.1/boot.js
Normal file
@ -0,0 +1,181 @@
|
||||
/**
|
||||
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
|
||||
|
||||
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
|
||||
|
||||
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
|
||||
|
||||
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
/**
|
||||
* ## Require & Instantiate
|
||||
*
|
||||
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
||||
*/
|
||||
window.jasmine = jasmineRequire.core(jasmineRequire);
|
||||
|
||||
/**
|
||||
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
|
||||
*/
|
||||
jasmineRequire.html(jasmine);
|
||||
|
||||
/**
|
||||
* Create the Jasmine environment. This is used to run all specs in a project.
|
||||
*/
|
||||
var env = jasmine.getEnv();
|
||||
|
||||
/**
|
||||
* ## The Global Interface
|
||||
*
|
||||
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
|
||||
*/
|
||||
var jasmineInterface = {
|
||||
describe: function(description, specDefinitions) {
|
||||
return env.describe(description, specDefinitions);
|
||||
},
|
||||
|
||||
xdescribe: function(description, specDefinitions) {
|
||||
return env.xdescribe(description, specDefinitions);
|
||||
},
|
||||
|
||||
it: function(desc, func) {
|
||||
return env.it(desc, func);
|
||||
},
|
||||
|
||||
xit: function(desc, func) {
|
||||
return env.xit(desc, func);
|
||||
},
|
||||
|
||||
beforeEach: function(beforeEachFunction) {
|
||||
return env.beforeEach(beforeEachFunction);
|
||||
},
|
||||
|
||||
afterEach: function(afterEachFunction) {
|
||||
return env.afterEach(afterEachFunction);
|
||||
},
|
||||
|
||||
expect: function(actual) {
|
||||
return env.expect(actual);
|
||||
},
|
||||
|
||||
pending: function() {
|
||||
return env.pending();
|
||||
},
|
||||
|
||||
spyOn: function(obj, methodName) {
|
||||
return env.spyOn(obj, methodName);
|
||||
},
|
||||
|
||||
jsApiReporter: new jasmine.JsApiReporter({
|
||||
timer: new jasmine.Timer()
|
||||
})
|
||||
};
|
||||
|
||||
/**
|
||||
* Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
|
||||
*/
|
||||
if (typeof window == "undefined" && typeof exports == "object") {
|
||||
extend(exports, jasmineInterface);
|
||||
} else {
|
||||
extend(window, jasmineInterface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose the interface for adding custom equality testers.
|
||||
*/
|
||||
jasmine.addCustomEqualityTester = function(tester) {
|
||||
env.addCustomEqualityTester(tester);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose the interface for adding custom expectation matchers
|
||||
*/
|
||||
jasmine.addMatchers = function(matchers) {
|
||||
return env.addMatchers(matchers);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose the mock interface for the JavaScript timeout functions
|
||||
*/
|
||||
jasmine.clock = function() {
|
||||
return env.clock;
|
||||
};
|
||||
|
||||
/**
|
||||
* ## Runner Parameters
|
||||
*
|
||||
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
|
||||
*/
|
||||
|
||||
var queryString = new jasmine.QueryString({
|
||||
getWindowLocation: function() { return window.location; }
|
||||
});
|
||||
|
||||
var catchingExceptions = queryString.getParam("catch");
|
||||
env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
|
||||
|
||||
/**
|
||||
* ## Reporters
|
||||
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
||||
*/
|
||||
var htmlReporter = new jasmine.HtmlReporter({
|
||||
env: env,
|
||||
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
|
||||
getContainer: function() { return document.body; },
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
||||
timer: new jasmine.Timer()
|
||||
});
|
||||
|
||||
/**
|
||||
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
|
||||
*/
|
||||
env.addReporter(jasmineInterface.jsApiReporter);
|
||||
env.addReporter(htmlReporter);
|
||||
|
||||
/**
|
||||
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
|
||||
*/
|
||||
var specFilter = new jasmine.HtmlSpecFilter({
|
||||
filterString: function() { return queryString.getParam("spec"); }
|
||||
});
|
||||
|
||||
env.specFilter = function(spec) {
|
||||
return specFilter.matches(spec.getFullName());
|
||||
};
|
||||
|
||||
/**
|
||||
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
|
||||
*/
|
||||
window.setTimeout = window.setTimeout;
|
||||
window.setInterval = window.setInterval;
|
||||
window.clearTimeout = window.clearTimeout;
|
||||
window.clearInterval = window.clearInterval;
|
||||
|
||||
/**
|
||||
* ## Execution
|
||||
*
|
||||
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
|
||||
*/
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
htmlReporter.initialize();
|
||||
env.execute();
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function for readability above.
|
||||
*/
|
||||
function extend(destination, source) {
|
||||
for (var property in source) destination[property] = source[property];
|
||||
return destination;
|
||||
}
|
||||
|
||||
}());
|
165
spec/lib/jasmine-2.0.1/console.js
Normal file
165
spec/lib/jasmine-2.0.1/console.js
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
Copyright (c) 2008-2014 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
function getJasmineRequireObj() {
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
return exports;
|
||||
} else {
|
||||
window.jasmineRequire = window.jasmineRequire || {};
|
||||
return window.jasmineRequire;
|
||||
}
|
||||
}
|
||||
|
||||
getJasmineRequireObj().console = function(jRequire, j$) {
|
||||
j$.ConsoleReporter = jRequire.ConsoleReporter();
|
||||
};
|
||||
|
||||
getJasmineRequireObj().ConsoleReporter = function() {
|
||||
|
||||
var noopTimer = {
|
||||
start: function(){},
|
||||
elapsed: function(){ return 0; }
|
||||
};
|
||||
|
||||
function ConsoleReporter(options) {
|
||||
var print = options.print,
|
||||
showColors = options.showColors || false,
|
||||
onComplete = options.onComplete || function() {},
|
||||
timer = options.timer || noopTimer,
|
||||
specCount,
|
||||
failureCount,
|
||||
failedSpecs = [],
|
||||
pendingCount,
|
||||
ansi = {
|
||||
green: '\x1B[32m',
|
||||
red: '\x1B[31m',
|
||||
yellow: '\x1B[33m',
|
||||
none: '\x1B[0m'
|
||||
};
|
||||
|
||||
this.jasmineStarted = function() {
|
||||
specCount = 0;
|
||||
failureCount = 0;
|
||||
pendingCount = 0;
|
||||
print('Started');
|
||||
printNewline();
|
||||
timer.start();
|
||||
};
|
||||
|
||||
this.jasmineDone = function() {
|
||||
printNewline();
|
||||
for (var i = 0; i < failedSpecs.length; i++) {
|
||||
specFailureDetails(failedSpecs[i]);
|
||||
}
|
||||
|
||||
if(specCount > 0) {
|
||||
printNewline();
|
||||
|
||||
var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' +
|
||||
failureCount + ' ' + plural('failure', failureCount);
|
||||
|
||||
if (pendingCount) {
|
||||
specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount);
|
||||
}
|
||||
|
||||
print(specCounts);
|
||||
} else {
|
||||
print('No specs found');
|
||||
}
|
||||
|
||||
printNewline();
|
||||
var seconds = timer.elapsed() / 1000;
|
||||
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
||||
|
||||
printNewline();
|
||||
|
||||
onComplete(failureCount === 0);
|
||||
};
|
||||
|
||||
this.specDone = function(result) {
|
||||
specCount++;
|
||||
|
||||
if (result.status == 'pending') {
|
||||
pendingCount++;
|
||||
print(colored('yellow', '*'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.status == 'passed') {
|
||||
print(colored('green', '.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.status == 'failed') {
|
||||
failureCount++;
|
||||
failedSpecs.push(result);
|
||||
print(colored('red', 'F'));
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function printNewline() {
|
||||
print('\n');
|
||||
}
|
||||
|
||||
function colored(color, str) {
|
||||
return showColors ? (ansi[color] + str + ansi.none) : str;
|
||||
}
|
||||
|
||||
function plural(str, count) {
|
||||
return count == 1 ? str : str + 's';
|
||||
}
|
||||
|
||||
function repeat(thing, times) {
|
||||
var arr = [];
|
||||
for (var i = 0; i < times; i++) {
|
||||
arr.push(thing);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function indent(str, spaces) {
|
||||
var lines = (str || '').split('\n');
|
||||
var newArr = [];
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
newArr.push(repeat(' ', spaces).join('') + lines[i]);
|
||||
}
|
||||
return newArr.join('\n');
|
||||
}
|
||||
|
||||
function specFailureDetails(result) {
|
||||
printNewline();
|
||||
print(result.fullName);
|
||||
|
||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||
var failedExpectation = result.failedExpectations[i];
|
||||
printNewline();
|
||||
print(indent(failedExpectation.stack, 2));
|
||||
}
|
||||
|
||||
printNewline();
|
||||
}
|
||||
}
|
||||
|
||||
return ConsoleReporter;
|
||||
};
|
390
spec/lib/jasmine-2.0.1/jasmine-html.js
Normal file
390
spec/lib/jasmine-2.0.1/jasmine-html.js
Normal file
@ -0,0 +1,390 @@
|
||||
/*
|
||||
Copyright (c) 2008-2014 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
jasmineRequire.html = function(j$) {
|
||||
j$.ResultsNode = jasmineRequire.ResultsNode();
|
||||
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
||||
j$.QueryString = jasmineRequire.QueryString();
|
||||
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
||||
};
|
||||
|
||||
jasmineRequire.HtmlReporter = function(j$) {
|
||||
|
||||
var noopTimer = {
|
||||
start: function() {},
|
||||
elapsed: function() { return 0; }
|
||||
};
|
||||
|
||||
function HtmlReporter(options) {
|
||||
var env = options.env || {},
|
||||
getContainer = options.getContainer,
|
||||
createElement = options.createElement,
|
||||
createTextNode = options.createTextNode,
|
||||
onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
|
||||
timer = options.timer || noopTimer,
|
||||
results = [],
|
||||
specsExecuted = 0,
|
||||
failureCount = 0,
|
||||
pendingSpecCount = 0,
|
||||
htmlReporterMain,
|
||||
symbols;
|
||||
|
||||
this.initialize = function() {
|
||||
clearPrior();
|
||||
htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
|
||||
createDom('div', {className: 'banner'},
|
||||
createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}),
|
||||
createDom('span', {className: 'version'}, j$.version)
|
||||
),
|
||||
createDom('ul', {className: 'symbol-summary'}),
|
||||
createDom('div', {className: 'alert'}),
|
||||
createDom('div', {className: 'results'},
|
||||
createDom('div', {className: 'failures'})
|
||||
)
|
||||
);
|
||||
getContainer().appendChild(htmlReporterMain);
|
||||
|
||||
symbols = find('.symbol-summary');
|
||||
};
|
||||
|
||||
var totalSpecsDefined;
|
||||
this.jasmineStarted = function(options) {
|
||||
totalSpecsDefined = options.totalSpecsDefined || 0;
|
||||
timer.start();
|
||||
};
|
||||
|
||||
var summary = createDom('div', {className: 'summary'});
|
||||
|
||||
var topResults = new j$.ResultsNode({}, '', null),
|
||||
currentParent = topResults;
|
||||
|
||||
this.suiteStarted = function(result) {
|
||||
currentParent.addChild(result, 'suite');
|
||||
currentParent = currentParent.last();
|
||||
};
|
||||
|
||||
this.suiteDone = function(result) {
|
||||
if (currentParent == topResults) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentParent = currentParent.parent;
|
||||
};
|
||||
|
||||
this.specStarted = function(result) {
|
||||
currentParent.addChild(result, 'spec');
|
||||
};
|
||||
|
||||
var failures = [];
|
||||
this.specDone = function(result) {
|
||||
if(noExpectations(result) && console && console.error) {
|
||||
console.error('Spec \'' + result.fullName + '\' has no expectations.');
|
||||
}
|
||||
|
||||
if (result.status != 'disabled') {
|
||||
specsExecuted++;
|
||||
}
|
||||
|
||||
symbols.appendChild(createDom('li', {
|
||||
className: noExpectations(result) ? 'empty' : result.status,
|
||||
id: 'spec_' + result.id,
|
||||
title: result.fullName
|
||||
}
|
||||
));
|
||||
|
||||
if (result.status == 'failed') {
|
||||
failureCount++;
|
||||
|
||||
var failure =
|
||||
createDom('div', {className: 'spec-detail failed'},
|
||||
createDom('div', {className: 'description'},
|
||||
createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
|
||||
),
|
||||
createDom('div', {className: 'messages'})
|
||||
);
|
||||
var messages = failure.childNodes[1];
|
||||
|
||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||
var expectation = result.failedExpectations[i];
|
||||
messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message));
|
||||
messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack));
|
||||
}
|
||||
|
||||
failures.push(failure);
|
||||
}
|
||||
|
||||
if (result.status == 'pending') {
|
||||
pendingSpecCount++;
|
||||
}
|
||||
};
|
||||
|
||||
this.jasmineDone = function() {
|
||||
var banner = find('.banner');
|
||||
banner.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
|
||||
|
||||
var alert = find('.alert');
|
||||
|
||||
alert.appendChild(createDom('span', { className: 'exceptions' },
|
||||
createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions'),
|
||||
createDom('input', {
|
||||
className: 'raise',
|
||||
id: 'raise-exceptions',
|
||||
type: 'checkbox'
|
||||
})
|
||||
));
|
||||
var checkbox = find('#raise-exceptions');
|
||||
|
||||
checkbox.checked = !env.catchingExceptions();
|
||||
checkbox.onclick = onRaiseExceptionsClick;
|
||||
|
||||
if (specsExecuted < totalSpecsDefined) {
|
||||
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'bar skipped'},
|
||||
createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage)
|
||||
)
|
||||
);
|
||||
}
|
||||
var statusBarMessage = '';
|
||||
var statusBarClassName = 'bar ';
|
||||
|
||||
if (totalSpecsDefined > 0) {
|
||||
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
|
||||
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
|
||||
statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
|
||||
} else {
|
||||
statusBarClassName += 'skipped';
|
||||
statusBarMessage += 'No specs found';
|
||||
}
|
||||
|
||||
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
|
||||
|
||||
var results = find('.results');
|
||||
results.appendChild(summary);
|
||||
|
||||
summaryList(topResults, summary);
|
||||
|
||||
function summaryList(resultsTree, domParent) {
|
||||
var specListNode;
|
||||
for (var i = 0; i < resultsTree.children.length; i++) {
|
||||
var resultNode = resultsTree.children[i];
|
||||
if (resultNode.type == 'suite') {
|
||||
var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id},
|
||||
createDom('li', {className: 'suite-detail'},
|
||||
createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
|
||||
)
|
||||
);
|
||||
|
||||
summaryList(resultNode, suiteListNode);
|
||||
domParent.appendChild(suiteListNode);
|
||||
}
|
||||
if (resultNode.type == 'spec') {
|
||||
if (domParent.getAttribute('class') != 'specs') {
|
||||
specListNode = createDom('ul', {className: 'specs'});
|
||||
domParent.appendChild(specListNode);
|
||||
}
|
||||
var specDescription = resultNode.result.description;
|
||||
if(noExpectations(resultNode.result)) {
|
||||
specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
|
||||
}
|
||||
specListNode.appendChild(
|
||||
createDom('li', {
|
||||
className: resultNode.result.status,
|
||||
id: 'spec-' + resultNode.result.id
|
||||
},
|
||||
createDom('a', {href: specHref(resultNode.result)}, specDescription)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (failures.length) {
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'menu bar spec-list'},
|
||||
createDom('span', {}, 'Spec List | '),
|
||||
createDom('a', {className: 'failures-menu', href: '#'}, 'Failures')));
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'menu bar failure-list'},
|
||||
createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'),
|
||||
createDom('span', {}, ' | Failures ')));
|
||||
|
||||
find('.failures-menu').onclick = function() {
|
||||
setMenuModeTo('failure-list');
|
||||
};
|
||||
find('.spec-list-menu').onclick = function() {
|
||||
setMenuModeTo('spec-list');
|
||||
};
|
||||
|
||||
setMenuModeTo('failure-list');
|
||||
|
||||
var failureNode = find('.failures');
|
||||
for (var i = 0; i < failures.length; i++) {
|
||||
failureNode.appendChild(failures[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function find(selector) {
|
||||
return getContainer().querySelector('.jasmine_html-reporter ' + selector);
|
||||
}
|
||||
|
||||
function clearPrior() {
|
||||
// return the reporter
|
||||
var oldReporter = find('');
|
||||
|
||||
if(oldReporter) {
|
||||
getContainer().removeChild(oldReporter);
|
||||
}
|
||||
}
|
||||
|
||||
function createDom(type, attrs, childrenVarArgs) {
|
||||
var el = createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(createTextNode(child));
|
||||
} else {
|
||||
if (child) {
|
||||
el.appendChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == 'className') {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
function pluralize(singular, count) {
|
||||
var word = (count == 1 ? singular : singular + 's');
|
||||
|
||||
return '' + count + ' ' + word;
|
||||
}
|
||||
|
||||
function specHref(result) {
|
||||
return '?spec=' + encodeURIComponent(result.fullName);
|
||||
}
|
||||
|
||||
function setMenuModeTo(mode) {
|
||||
htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
|
||||
}
|
||||
|
||||
function noExpectations(result) {
|
||||
return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
|
||||
result.status === 'passed';
|
||||
}
|
||||
}
|
||||
|
||||
return HtmlReporter;
|
||||
};
|
||||
|
||||
jasmineRequire.HtmlSpecFilter = function() {
|
||||
function HtmlSpecFilter(options) {
|
||||
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
var filterPattern = new RegExp(filterString);
|
||||
|
||||
this.matches = function(specName) {
|
||||
return filterPattern.test(specName);
|
||||
};
|
||||
}
|
||||
|
||||
return HtmlSpecFilter;
|
||||
};
|
||||
|
||||
jasmineRequire.ResultsNode = function() {
|
||||
function ResultsNode(result, type, parent) {
|
||||
this.result = result;
|
||||
this.type = type;
|
||||
this.parent = parent;
|
||||
|
||||
this.children = [];
|
||||
|
||||
this.addChild = function(result, type) {
|
||||
this.children.push(new ResultsNode(result, type, this));
|
||||
};
|
||||
|
||||
this.last = function() {
|
||||
return this.children[this.children.length - 1];
|
||||
};
|
||||
}
|
||||
|
||||
return ResultsNode;
|
||||
};
|
||||
|
||||
jasmineRequire.QueryString = function() {
|
||||
function QueryString(options) {
|
||||
|
||||
this.setParam = function(key, value) {
|
||||
var paramMap = queryStringToParamMap();
|
||||
paramMap[key] = value;
|
||||
options.getWindowLocation().search = toQueryString(paramMap);
|
||||
};
|
||||
|
||||
this.getParam = function(key) {
|
||||
return queryStringToParamMap()[key];
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function toQueryString(paramMap) {
|
||||
var qStrPairs = [];
|
||||
for (var prop in paramMap) {
|
||||
qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop]));
|
||||
}
|
||||
return '?' + qStrPairs.join('&');
|
||||
}
|
||||
|
||||
function queryStringToParamMap() {
|
||||
var paramStr = options.getWindowLocation().search.substring(1),
|
||||
params = [],
|
||||
paramMap = {};
|
||||
|
||||
if (paramStr.length > 0) {
|
||||
params = paramStr.split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
var value = decodeURIComponent(p[1]);
|
||||
if (value === 'true' || value === 'false') {
|
||||
value = JSON.parse(value);
|
||||
}
|
||||
paramMap[decodeURIComponent(p[0])] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return QueryString;
|
||||
};
|
59
spec/lib/jasmine-2.0.1/jasmine.css
Normal file
59
spec/lib/jasmine-2.0.1/jasmine.css
Normal file
File diff suppressed because one or more lines are too long
2516
spec/lib/jasmine-2.0.1/jasmine.js
Normal file
2516
spec/lib/jasmine-2.0.1/jasmine.js
Normal file
File diff suppressed because it is too large
Load Diff
BIN
spec/lib/jasmine-2.0.1/jasmine_favicon.png
Normal file
BIN
spec/lib/jasmine-2.0.1/jasmine_favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@ -3,12 +3,13 @@
|
||||
<head>
|
||||
<title>Autocomplete Spec</title>
|
||||
<!-- jasmine -->
|
||||
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css" />
|
||||
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="lib/jasmine-2.0.1/jasmine.css">
|
||||
<script type="text/javascript" src="lib/jasmine-2.0.1/jasmine.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-2.0.1/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-2.0.1/boot.js"></script>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="../scripts/jquery-1.8.2.min.js"></script>
|
||||
<script src="../scripts/jquery-2.1.1.js"></script>
|
||||
<script src="../scripts/jquery.mockjax.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.JSON || document.write('<scr' + 'ipt src="//cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.min.js"><\/scr' + 'ipt>');
|
||||
@ -20,17 +21,6 @@
|
||||
<script type="text/javascript" src="autocompleteBehavior.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
/*jslint vars: true; */
|
||||
(function () {
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 500;
|
||||
|
||||
var htmlReporter = new jasmine.HtmlReporter();
|
||||
jasmineEnv.addReporter(htmlReporter);
|
||||
jasmineEnv.specFilter = htmlReporter.specFilter;
|
||||
jasmineEnv.execute();
|
||||
}());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user