From eb6ed4befc32d88f0881167ce704aec1adb88fdb Mon Sep 17 00:00:00 2001 From: jlukic Date: Mon, 14 Oct 2013 01:13:28 -0400 Subject: [PATCH] Add proper console output for jasmine tests and proper include. Creates new test for running with continuous integration or for local watch --- .travis.yml | 2 +- Gruntfile.js | 144 ++-- package.json | 71 +- .../PhantomJS 1.9.2 (Linux)/index.html | 320 ++++++++ .../PhantomJS 1.9.2 (Linux)/prettify.css | 1 + .../PhantomJS 1.9.2 (Linux)/prettify.js | 1 + ...antomJS 1.9.2 (Linux)-20131014_005413.json | 1 + test/helpers/jasmine-jquery.js | 705 ++++++++++++++++++ test/karma.conf.js | 32 +- test/modules/modal.js | 7 +- 10 files changed, 1167 insertions(+), 117 deletions(-) create mode 100644 test/coverage/PhantomJS 1.9.2 (Linux)/index.html create mode 100644 test/coverage/PhantomJS 1.9.2 (Linux)/prettify.css create mode 100644 test/coverage/PhantomJS 1.9.2 (Linux)/prettify.js create mode 100644 test/coverage/coverage-PhantomJS 1.9.2 (Linux)-20131014_005413.json create mode 100755 test/helpers/jasmine-jquery.js diff --git a/.travis.yml b/.travis.yml index 09971e240..3004579db 100755 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ node_js: - "0.10" before_script: - npm install -g grunt-cli - - grunt test \ No newline at end of file + - grunt test --verbose \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 0613b5ef8..658fd4ce8 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -15,13 +15,16 @@ module.exports = function(grunt) { 'copy:srcToDocs', // copies examples over to docs - 'copy:examplesToDocs', + 'copy:examplesToDocs' ], testTasks = [ + // compiles less to docs so phantomjs can read + 'less:buildTestCSS', + // test components - 'karma:test:run' + 'karma:travis' ], buildTasks = [ @@ -85,7 +88,7 @@ module.exports = function(grunt) { setWatchFiles = function(action, filePath) { var - buildPath = filePath.replace('src/', 'docs/build/').replace('less', 'css') + buildPath = filePath.replace('../src/', '../docs/build/').replace('less', 'css') ; if(filePath.search('.less') !== -1) { grunt.config('less.buildDocsCSS.src', filePath); @@ -120,15 +123,15 @@ module.exports = function(grunt) { }, scripts: { files: [ - 'src/**/*.js' + '../src/**/*.js' ], - tasks : testTasks + tasks : ['karma:test:run'] }, src: { files: [ - 'build/examples/**/*', - 'src/**/*.less', - 'src/**/*.js' + '../build/examples/**/*', + '../src/**/*.less', + '../src/**/*.js' ], tasks : watchTasks } @@ -143,6 +146,10 @@ module.exports = function(grunt) { configFile : 'test/karma.conf.js', background : true, reporters: 'dots' + }, + travis: { + configFile : 'test/karma.conf.js', + singleRun : true } }, @@ -155,28 +162,28 @@ module.exports = function(grunt) { force: true }, build : [ - 'build/less', - 'build/minified', - 'build/packaged', - 'build/uncompressed' + '../build/less', + '../build/minified', + '../build/packaged', + '../build/uncompressed' ], release : [ - 'docs/build', - 'docs', - 'rtl' + '../docs/build', + '../docs', + '../rtl' ] }, docco: { generate: { options: { - css : 'spec/assets/docco.css', - output : 'spec/docs/' + css : '../spec/assets/docco.css', + output : '../spec/docs/' }, files: [ { expand : true, - cwd : 'spec/', + cwd : '../spec/', src : [ '**.commented.js' ] @@ -188,37 +195,47 @@ module.exports = function(grunt) { cssjanus: { rtl: { expand : true, - cwd : 'build/', + cwd : '../build/', src : [ '**/*.less', '**/*.css', ], - dest : 'rtl' + dest : '../rtl' }, }, less: { options: { - paths : ['src'], + paths : ['../src'], compress : false, optimization : 2 }, // optimized for watch, src is built on watch task using callbacks buildDocsCSS: { - src : 'src', - dest : 'docs/build/uncompressed/', + src : '../src', + dest : '../docs/build/uncompressed/', rename : preserveFileExtensions }, + buildTestCSS: { + expand : true, + cwd : '../src', + src : [ + '**/*.less' + ], + dest : '../docs/build/uncompressed/', + rename: preserveFileExtensions + }, + buildCSS: { expand : true, - cwd : 'src', + cwd : '../src', src : [ '**/*.less' ], - dest : 'build/uncompressed/', + dest : '../build/uncompressed/', rename: preserveFileExtensions } }, @@ -231,44 +248,44 @@ module.exports = function(grunt) { // exact copy for less { expand : true, - cwd : 'src/**/*.less', + cwd : '../src/**/*.less', src : [ '**/*' ], - dest : 'docs/build/less' + dest : '../docs/build/less' }, // copy everything but less files for uncompressed release { expand : true, - cwd : 'src/', + cwd : '../src/', src : [ '**/*.js', 'images/*', 'fonts/*' ], - dest : 'docs/build/uncompressed' + dest : '../docs/build/uncompressed' }, // copy everything but less for minified release { expand : true, - cwd : 'src/', + cwd : '../src/', src : [ '**/*.js', 'images/*', 'fonts/*' ], - dest : 'docs/build/minified' + dest : '../docs/build/minified' }, // copy assets only for packaged version { expand : true, - cwd : 'src/', + cwd : '../src/', src : [ 'images/*', 'fonts/*' ], - dest : 'docs/build/packaged' + dest : '../docs/build/packaged' } ] }, @@ -279,44 +296,44 @@ module.exports = function(grunt) { // exact copy for less { expand : true, - cwd : 'src/', + cwd : '../src/', src : [ '**/*' ], - dest : 'build/less' + dest : '../build/less' }, // copy everything but less files for uncompressed release { expand : true, - cwd : 'src/', + cwd : '../src/', src : [ '**/*.js', 'images/*', 'fonts/*' ], - dest : 'build/uncompressed' + dest : '../build/uncompressed' }, // copy everything but less for minified release { expand : true, - cwd : 'src/', + cwd : '../src/', src : [ '**/*.js', 'images/*', 'fonts/*' ], - dest : 'build/minified' + dest : '../build/minified' }, // copy assets only for packaged version { expand : true, - cwd : 'src/', + cwd : '../src/', src : [ 'images/*', 'fonts/*' ], - dest : 'build/packaged' + dest : '../build/packaged' } ] }, @@ -326,11 +343,11 @@ module.exports = function(grunt) { files: [ { expand : true, - cwd : 'build/', + cwd : '../build/', src : [ '**' ], - dest : 'rtl' + dest : '../rtl' } ] }, @@ -340,11 +357,11 @@ module.exports = function(grunt) { files: [ { expand : true, - cwd : 'build/', + cwd : '../build/', src : [ '**' ], - dest : 'docs/build/' + dest : '../docs/build/' } ] }, @@ -354,11 +371,11 @@ module.exports = function(grunt) { files: [ { expand : true, - cwd : 'spec', + cwd : '../spec', src : [ '**' ], - dest : 'docs/spec/' + dest : '../docs/spec/' } ] }, @@ -368,11 +385,11 @@ module.exports = function(grunt) { files: [ { expand : true, - cwd : 'build/examples', + cwd : '../build/examples', src : [ '**' ], - dest : 'docs/examples/' + dest : '../docs/examples/' } ] } @@ -382,13 +399,13 @@ module.exports = function(grunt) { compress: { options: { - archive: 'docs/build/semantic.zip' + archive: '../docs/build/semantic.zip' }, everything: { files: [ { expand : true, - cwd : 'build/', + cwd : '../build/', src : [ '**' ] @@ -401,12 +418,12 @@ module.exports = function(grunt) { options: { }, concatenateCSS: { - src: ["build/uncompressed/**/*.css"], - dest: "build/packaged/css/semantic.css" + src: ["../build/uncompressed/**/*.css"], + dest: "../build/packaged/css/semantic.css" }, concatenateJS: { - src: ["build/uncompressed/**/*.js"], - dest: "build/packaged/javascript/semantic.js" + src: ["../build/uncompressed/**/*.js"], + dest: "../build/packaged/javascript/semantic.js" }, }, @@ -415,11 +432,11 @@ module.exports = function(grunt) { // copy minified css to minified release minifyCSS: { expand : true, - cwd : 'build/uncompressed', + cwd : '../build/uncompressed', src : [ '**/*.css' ], - dest : 'build/minified', + dest : '../build/minified', ext : '.min.css' }, @@ -441,8 +458,8 @@ module.exports = function(grunt) { '*/\n' }, files: { - 'build/packaged/css/semantic.min.css': [ - 'build/uncompressed/**/*.css' + '../build/packaged/css/semantic.min.css': [ + '../build/uncompressed/**/*.css' ] } } @@ -452,11 +469,11 @@ module.exports = function(grunt) { minifyJS: { expand : true, - cwd : 'build/uncompressed', + cwd : '../build/uncompressed', src : [ '**/*.js' ], - dest : 'build/minified', + dest : '../build/minified', ext : '.min.js', banner : '' + '/*' + @@ -492,8 +509,8 @@ module.exports = function(grunt) { '*/\n' }, files: { - 'build/packaged/javascript/semantic.min.js': [ - 'build/uncompressed/**/*.js' + '../build/packaged/javascript/semantic.min.js': [ + '../build/uncompressed/**/*.js' ] } } @@ -515,7 +532,6 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-karma'); grunt.initConfig(config); - grunt.registerTask('default', defaultTasks); grunt.registerTask('build', buildTasks); grunt.registerTask('test', testTasks); diff --git a/package.json b/package.json index ba62f73fa..d144f1574 100755 --- a/package.json +++ b/package.json @@ -1,41 +1,42 @@ { - "name" : "semantic", - "title" : "Semantic UI", - "description" : "Semantic empowers designers and developers by creating a shared vocabulary for UI.", - "homepage" : "http://www.semantic-ui.com", - "author" : "Jack Lukic ", + "name": "semantic", + "title": "Semantic UI", + "description": "Semantic empowers designers and developers by creating a shared vocabulary for UI.", + "homepage": "http://www.semantic-ui.com", + "author": "Jack Lukic ", "license": "MIT", - - "dependencies" : { - "docpad" : "~6.53.4", - "docpad-plugin-eco" : "~2.0.2", - "docpad-plugin-ghpages" : "~2.4.0", - "docpad-plugin-partials" : "~2.8.0" + "dependencies": { + "docpad": "~6.53.4", + "docpad-plugin-eco": "~2.0.2", + "docpad-plugin-ghpages": "~2.4.0", + "docpad-plugin-partials": "~2.8.0" }, "devDependencies": { - "grunt" : "~0.4.1", - "grunt-contrib-watch" : "~0.5.3", - "grunt-contrib-clean" : "~0.5.0", - "grunt-contrib-uglify" : "~0.2.2", - "grunt-contrib-cssmin" : "~0.6.1", - "grunt-contrib-less" : "~0.7.0", - "grunt-contrib-copy" : "~0.4.1", - "grunt-docco" : "~0.2.0", - "grunt-bower-task" : "~0.3.1", - "grunt-css" : "~0.5.4", - "grunt-contrib-compress" : "~0.5.2", - "grunt-contrib-concat" : "~0.3.0", - "grunt-docco-multi" : "0.0.2", - "grunt-cssjanus" : "~0.1.1", - "karma-script-launcher" : "~0.1.0", - "karma-chrome-launcher" : "~0.1.0", - "karma-firefox-launcher" : "~0.1.0", - "karma-html2js-preprocessor" : "~0.1.0", - "karma-jasmine" : "~0.1.3", - "karma-requirejs" : "~0.1.0", - "karma-coffee-preprocessor" : "~0.1.0", - "karma-phantomjs-launcher" : "~0.1.0", - "karma" : "~0.10.2", - "grunt-karma" : "~0.6.2" + "grunt": "~0.4.1", + "grunt-contrib-watch": "~0.5.3", + "grunt-contrib-clean": "~0.5.0", + "grunt-contrib-uglify": "~0.2.2", + "grunt-contrib-cssmin": "~0.6.1", + "grunt-contrib-less": "~0.7.0", + "grunt-contrib-copy": "~0.4.1", + "grunt-docco": "~0.2.0", + "grunt-bower-task": "~0.3.1", + "grunt-css": "~0.5.4", + "grunt-contrib-compress": "~0.5.2", + "grunt-contrib-concat": "~0.3.0", + "grunt-docco-multi": "0.0.2", + "grunt-cssjanus": "~0.1.1", + "karma-script-launcher": "~0.1.0", + "karma-chrome-launcher": "~0.1.0", + "karma-firefox-launcher": "~0.1.0", + "karma-html2js-preprocessor": "~0.1.0", + "karma-jasmine": "~0.1.3", + "karma-requirejs": "~0.1.0", + "karma-coffee-preprocessor": "~0.1.0", + "karma-phantomjs-launcher": "~0.1.0", + "karma": "~0.10.2", + "grunt-karma": "~0.6.2", + "karma-coverage": "~0.1.0", + "karma-spec-reporter": "0.0.5" } } diff --git a/test/coverage/PhantomJS 1.9.2 (Linux)/index.html b/test/coverage/PhantomJS 1.9.2 (Linux)/index.html new file mode 100644 index 000000000..08e87ae8e --- /dev/null +++ b/test/coverage/PhantomJS 1.9.2 (Linux)/index.html @@ -0,0 +1,320 @@ + + + + Code coverage report for All files + + + + + + + +
+

Code coverage report for All files

+

+ + Statements: 100% (0 / 0)      + + + Branches: 100% (0 / 0)      + + + Functions: 100% (0 / 0)      + + + Lines: 100% (0 / 0)      + +

+
+
+
+
+ + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
+
+
+ + + + + + + + diff --git a/test/coverage/PhantomJS 1.9.2 (Linux)/prettify.css b/test/coverage/PhantomJS 1.9.2 (Linux)/prettify.css new file mode 100644 index 000000000..b317a7cda --- /dev/null +++ b/test/coverage/PhantomJS 1.9.2 (Linux)/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/test/coverage/PhantomJS 1.9.2 (Linux)/prettify.js b/test/coverage/PhantomJS 1.9.2 (Linux)/prettify.js new file mode 100644 index 000000000..ef51e0386 --- /dev/null +++ b/test/coverage/PhantomJS 1.9.2 (Linux)/prettify.js @@ -0,0 +1 @@ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/test/coverage/coverage-PhantomJS 1.9.2 (Linux)-20131014_005413.json b/test/coverage/coverage-PhantomJS 1.9.2 (Linux)-20131014_005413.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/test/coverage/coverage-PhantomJS 1.9.2 (Linux)-20131014_005413.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/helpers/jasmine-jquery.js b/test/helpers/jasmine-jquery.js new file mode 100755 index 000000000..14539ea4d --- /dev/null +++ b/test/helpers/jasmine-jquery.js @@ -0,0 +1,705 @@ +/*! +Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. + +Version 1.5.91 + +https://github.com/velesin/jasmine-jquery + +Copyright (c) 2010-2013 Wojciech Zawistowski, Travis Jeffery + +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 (jasmine, $) { "use strict"; + + jasmine.spiedEventsKey = function (selector, eventName) { + return [$(selector).selector, eventName].toString() + } + + jasmine.getFixtures = function () { + return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures() + } + + jasmine.getStyleFixtures = function () { + return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures() + } + + jasmine.Fixtures = function () { + this.containerId = 'jasmine-fixtures' + this.fixturesCache_ = {} + this.fixturesPath = 'spec/javascripts/fixtures' + } + + jasmine.Fixtures.prototype.set = function (html) { + this.cleanUp() + return this.createContainer_(html) + } + + jasmine.Fixtures.prototype.appendSet= function (html) { + this.addToContainer_(html) + } + + jasmine.Fixtures.prototype.preload = function () { + this.read.apply(this, arguments) + } + + jasmine.Fixtures.prototype.load = function () { + this.cleanUp() + this.createContainer_(this.read.apply(this, arguments)) + } + + jasmine.Fixtures.prototype.appendLoad = function () { + this.addToContainer_(this.read.apply(this, arguments)) + } + + jasmine.Fixtures.prototype.read = function () { + var htmlChunks = [] + , fixtureUrls = arguments + + for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { + htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex])) + } + + return htmlChunks.join('') + } + + jasmine.Fixtures.prototype.clearCache = function () { + this.fixturesCache_ = {} + } + + jasmine.Fixtures.prototype.cleanUp = function () { + $('#' + this.containerId).remove() + } + + jasmine.Fixtures.prototype.sandbox = function (attributes) { + var attributesToSet = attributes || {} + return $('
').attr(attributesToSet) + } + + jasmine.Fixtures.prototype.createContainer_ = function (html) { + var container = $('
') + .attr('id', this.containerId) + .html(html) + + $(document.body).append(container) + return container + } + + jasmine.Fixtures.prototype.addToContainer_ = function (html){ + var container = $(document.body).find('#'+this.containerId).append(html) + if(!container.length){ + this.createContainer_(html) + } + } + + jasmine.Fixtures.prototype.getFixtureHtml_ = function (url) { + if (typeof this.fixturesCache_[url] === 'undefined') { + this.loadFixtureIntoCache_(url) + } + return this.fixturesCache_[url] + } + + jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { + var self = this + , url = this.makeFixtureUrl_(relativeUrl) + , request = $.ajax({ + async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded + cache: false, + url: url, + success: function (data, status, $xhr) { + self.fixturesCache_[relativeUrl] = $xhr.responseText + }, + error: function (jqXHR, status, errorThrown) { + throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')') + } + }) + } + + jasmine.Fixtures.prototype.makeFixtureUrl_ = function (relativeUrl){ + return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl + } + + jasmine.Fixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) { + return this[methodName].apply(this, passedArguments) + } + + + jasmine.StyleFixtures = function () { + this.fixturesCache_ = {} + this.fixturesNodes_ = [] + this.fixturesPath = 'spec/javascripts/fixtures' + } + + jasmine.StyleFixtures.prototype.set = function (css) { + this.cleanUp() + this.createStyle_(css) + } + + jasmine.StyleFixtures.prototype.appendSet = function (css) { + this.createStyle_(css) + } + + jasmine.StyleFixtures.prototype.preload = function () { + this.read_.apply(this, arguments) + } + + jasmine.StyleFixtures.prototype.load = function () { + this.cleanUp() + this.createStyle_(this.read_.apply(this, arguments)) + } + + jasmine.StyleFixtures.prototype.appendLoad = function () { + this.createStyle_(this.read_.apply(this, arguments)) + } + + jasmine.StyleFixtures.prototype.cleanUp = function () { + while(this.fixturesNodes_.length) { + this.fixturesNodes_.pop().remove() + } + } + + jasmine.StyleFixtures.prototype.createStyle_ = function (html) { + var styleText = $('
').html(html).text() + , style = $('') + + this.fixturesNodes_.push(style) + $('head').append(style) + } + + jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache + jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read + jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_ + jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_ + jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_ + jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_ + + jasmine.getJSONFixtures = function () { + return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures() + } + + jasmine.JSONFixtures = function () { + this.fixturesCache_ = {} + this.fixturesPath = 'spec/javascripts/fixtures/json' + } + + jasmine.JSONFixtures.prototype.load = function () { + this.read.apply(this, arguments) + return this.fixturesCache_ + } + + jasmine.JSONFixtures.prototype.read = function () { + var fixtureUrls = arguments + + for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { + this.getFixtureData_(fixtureUrls[urlIndex]) + } + + return this.fixturesCache_ + } + + jasmine.JSONFixtures.prototype.clearCache = function () { + this.fixturesCache_ = {} + } + + jasmine.JSONFixtures.prototype.getFixtureData_ = function (url) { + if (!this.fixturesCache_[url]) this.loadFixtureIntoCache_(url) + return this.fixturesCache_[url] + } + + jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { + var self = this + , url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl + + $.ajax({ + async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded + cache: false, + dataType: 'json', + url: url, + success: function (data) { + self.fixturesCache_[relativeUrl] = data + }, + error: function (jqXHR, status, errorThrown) { + throw new Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')') + } + }) + } + + jasmine.JSONFixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) { + return this[methodName].apply(this, passedArguments) + } + + jasmine.JQuery = function () {} + + jasmine.JQuery.browserTagCaseIndependentHtml = function (html) { + return $('
').append(html).html() + } + + jasmine.JQuery.elementToString = function (element) { + var domEl = $(element).get(0) + + if (domEl === undefined || domEl.cloneNode) + return $('
').append($(element).clone()).html() + else + return element.toString() + } + + jasmine.JQuery.matchersClass = {} + + !function (namespace) { + var data = { + spiedEvents: {} + , handlers: [] + } + + namespace.events = { + spyOn: function (selector, eventName) { + var handler = function (e) { + data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments) + } + + $(selector).on(eventName, handler) + data.handlers.push(handler) + + return { + selector: selector, + eventName: eventName, + handler: handler, + reset: function (){ + delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] + } + } + }, + + args: function (selector, eventName) { + var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] + + if (!actualArgs) { + throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent." + } + + return actualArgs + }, + + wasTriggered: function (selector, eventName) { + return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]) + }, + + wasTriggeredWith: function (selector, eventName, expectedArgs, env) { + var actualArgs = jasmine.JQuery.events.args(selector, eventName).slice(1) + if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') { + actualArgs = actualArgs[0] + } + return env.equals_(expectedArgs, actualArgs) + }, + + wasPrevented: function (selector, eventName) { + var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] + , e = args ? args[0] : undefined + + return e && e.isDefaultPrevented() + }, + + wasStopped: function (selector, eventName) { + var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] + , e = args ? args[0] : undefined + return e && e.isPropagationStopped() + }, + + cleanUp: function () { + data.spiedEvents = {} + data.handlers = [] + } + } + }(jasmine.JQuery) + + !function (){ + var jQueryMatchers = { + toHaveClass: function (className) { + return this.actual.hasClass(className) + }, + + toHaveCss: function (css){ + for (var prop in css){ + var value = css[prop] + // see issue #147 on gh + ;if (value === 'auto' && this.actual.get(0).style[prop] === 'auto') continue + if (this.actual.css(prop) !== value) return false + } + return true + }, + + toBeVisible: function () { + return this.actual.is(':visible') + }, + + toBeHidden: function () { + return this.actual.is(':hidden') + }, + + toBeSelected: function () { + return this.actual.is(':selected') + }, + + toBeChecked: function () { + return this.actual.is(':checked') + }, + + toBeEmpty: function () { + return this.actual.is(':empty') + }, + + toExist: function () { + return this.actual.length + }, + + toHaveLength: function (length) { + return this.actual.length === length + }, + + toHaveAttr: function (attributeName, expectedAttributeValue) { + return hasProperty(this.actual.attr(attributeName), expectedAttributeValue) + }, + + toHaveProp: function (propertyName, expectedPropertyValue) { + return hasProperty(this.actual.prop(propertyName), expectedPropertyValue) + }, + + toHaveId: function (id) { + return this.actual.attr('id') == id + }, + + toHaveHtml: function (html) { + return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html) + }, + + toContainHtml: function (html){ + var actualHtml = this.actual.html() + , expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html) + + return (actualHtml.indexOf(expectedHtml) >= 0) + }, + + toHaveText: function (text) { + var trimmedText = $.trim(this.actual.text()) + + if (text && $.isFunction(text.test)) { + return text.test(trimmedText) + } else { + return trimmedText == text + } + }, + + toContainText: function (text) { + var trimmedText = $.trim(this.actual.text()) + + if (text && $.isFunction(text.test)) { + return text.test(trimmedText) + } else { + return trimmedText.indexOf(text) != -1 + } + }, + + toHaveValue: function (value) { + return this.actual.val() === value + }, + + toHaveData: function (key, expectedValue) { + return hasProperty(this.actual.data(key), expectedValue) + }, + + toBe: function (selector) { + return this.actual.is(selector) + }, + + toContain: function (selector) { + return this.actual.find(selector).length + }, + + toBeMatchedBy: function (selector) { + return this.actual.filter(selector).length + }, + + toBeDisabled: function (selector){ + return this.actual.is(':disabled') + }, + + toBeFocused: function (selector) { + return this.actual[0] === this.actual[0].ownerDocument.activeElement + }, + + toHandle: function (event) { + var events = $._data(this.actual.get(0), "events") + + if(!events || !event || typeof event !== "string") { + return false + } + + var namespaces = event.split(".") + , eventType = namespaces.shift() + , sortedNamespaces = namespaces.slice(0).sort() + , namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") + + if(events[eventType] && namespaces.length) { + for(var i = 0; i < events[eventType].length; i++) { + var namespace = events[eventType][i].namespace + + if(namespaceRegExp.test(namespace)) { + return true + } + } + } else { + return events[eventType] && events[eventType].length > 0 + } + }, + + toHandleWith: function (eventName, eventHandler) { + var normalizedEventName = eventName.split('.')[0] + , stack = $._data(this.actual.get(0), "events")[normalizedEventName] + + for (var i = 0; i < stack.length; i++) { + if (stack[i].handler == eventHandler) return true + } + + return false + } + } + + var hasProperty = function (actualValue, expectedValue) { + if (expectedValue === undefined) return actualValue !== undefined + + return actualValue == expectedValue + } + + var bindMatcher = function (methodName) { + var builtInMatcher = jasmine.Matchers.prototype[methodName] + + jasmine.JQuery.matchersClass[methodName] = function () { + if (this.actual + && (this.actual instanceof $ + || jasmine.isDomNode(this.actual))) { + this.actual = $(this.actual) + var result = jQueryMatchers[methodName].apply(this, arguments) + , element + + if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML") + this.actual = jasmine.JQuery.elementToString(this.actual) + + return result + } + + if (builtInMatcher) { + return builtInMatcher.apply(this, arguments) + } + + return false + } + } + + for(var methodName in jQueryMatchers) { + bindMatcher(methodName) + } + }() + + beforeEach(function () { + this.addMatchers(jasmine.JQuery.matchersClass) + this.addMatchers({ + toHaveBeenTriggeredOn: function (selector) { + this.message = function () { + return [ + "Expected event " + this.actual + " to have been triggered on " + selector, + "Expected event " + this.actual + " not to have been triggered on " + selector + ] + } + return jasmine.JQuery.events.wasTriggered(selector, this.actual) + } + }) + this.addMatchers({ + toHaveBeenTriggered: function (){ + var eventName = this.actual.eventName + , selector = this.actual.selector + + this.message = function () { + return [ + "Expected event " + eventName + " to have been triggered on " + selector, + "Expected event " + eventName + " not to have been triggered on " + selector + ] + } + + return jasmine.JQuery.events.wasTriggered(selector, eventName) + } + }) + this.addMatchers({ + toHaveBeenTriggeredOnAndWith: function () { + var selector = arguments[0] + , expectedArgs = arguments[1] + , wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual) + + this.message = function () { + if (wasTriggered) { + var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1] + return [ + "Expected event " + this.actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs), + "Expected event " + this.actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) + ] + } else { + return [ + "Expected event " + this.actual + " to have been triggered on " + selector, + "Expected event " + this.actual + " not to have been triggered on " + selector + ] + } + } + + return wasTriggered && jasmine.JQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env) + } + }) + this.addMatchers({ + toHaveBeenPreventedOn: function (selector) { + this.message = function () { + return [ + "Expected event " + this.actual + " to have been prevented on " + selector, + "Expected event " + this.actual + " not to have been prevented on " + selector + ] + } + + return jasmine.JQuery.events.wasPrevented(selector, this.actual) + } + }) + this.addMatchers({ + toHaveBeenPrevented: function () { + var eventName = this.actual.eventName + , selector = this.actual.selector + this.message = function () { + return [ + "Expected event " + eventName + " to have been prevented on " + selector, + "Expected event " + eventName + " not to have been prevented on " + selector + ] + } + + return jasmine.JQuery.events.wasPrevented(selector, eventName) + } + }) + this.addMatchers({ + toHaveBeenStoppedOn: function (selector) { + this.message = function () { + return [ + "Expected event " + this.actual + " to have been stopped on " + selector, + "Expected event " + this.actual + " not to have been stopped on " + selector + ] + } + + return jasmine.JQuery.events.wasStopped(selector, this.actual) + } + }) + this.addMatchers({ + toHaveBeenStopped: function () { + var eventName = this.actual.eventName + , selector = this.actual.selector + this.message = function () { + return [ + "Expected event " + eventName + " to have been stopped on " + selector, + "Expected event " + eventName + " not to have been stopped on " + selector + ] + } + return jasmine.JQuery.events.wasStopped(selector, eventName) + } + }) + jasmine.getEnv().addEqualityTester(function (a, b) { + if(a instanceof jQuery && b instanceof jQuery) { + if(a.size() != b.size()) { + return jasmine.undefined + } + else if(a.is(b)) { + return true + } + } + + return jasmine.undefined + }) + }) + + afterEach(function () { + jasmine.getFixtures().cleanUp() + jasmine.getStyleFixtures().cleanUp() + jasmine.JQuery.events.cleanUp() + }) +}(window.jasmine, window.jQuery) + ++function (jasmine, global) { "use strict"; + + global.readFixtures = function () { + return jasmine.getFixtures().proxyCallTo_('read', arguments) + } + + global.preloadFixtures = function () { + jasmine.getFixtures().proxyCallTo_('preload', arguments) + } + + global.loadFixtures = function () { + jasmine.getFixtures().proxyCallTo_('load', arguments) + } + + global.appendLoadFixtures = function () { + jasmine.getFixtures().proxyCallTo_('appendLoad', arguments) + } + + global.setFixtures = function (html) { + return jasmine.getFixtures().proxyCallTo_('set', arguments) + } + + global.appendSetFixtures = function () { + jasmine.getFixtures().proxyCallTo_('appendSet', arguments) + } + + global.sandbox = function (attributes) { + return jasmine.getFixtures().sandbox(attributes) + } + + global.spyOnEvent = function (selector, eventName) { + return jasmine.JQuery.events.spyOn(selector, eventName) + } + + global.preloadStyleFixtures = function () { + jasmine.getStyleFixtures().proxyCallTo_('preload', arguments) + } + + global.loadStyleFixtures = function () { + jasmine.getStyleFixtures().proxyCallTo_('load', arguments) + } + + global.appendLoadStyleFixtures = function () { + jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments) + } + + global.setStyleFixtures = function (html) { + jasmine.getStyleFixtures().proxyCallTo_('set', arguments) + } + + global.appendSetStyleFixtures = function (html) { + jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments) + } + + global.loadJSONFixtures = function () { + return jasmine.getJSONFixtures().proxyCallTo_('load', arguments) + } + + global.getJSONFixture = function (url) { + return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url] + } +}(jasmine, window); \ No newline at end of file diff --git a/test/karma.conf.js b/test/karma.conf.js index a369343cf..28dd8188d 100755 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -1,52 +1,53 @@ // Karma configuration -// Generated on Sun Oct 13 2013 15:14:38 GMT-0400 (EDT) - module.exports = function(config) { config.set({ // base path, that will be used to resolve files and exclude basePath: '', - // frameworks to use - frameworks: ['jasmine'], - + frameworks: [ + 'jasmine' + ], // list of files / patterns to load in the browser files: [ - '**/*.js' + // require jquery + '../server/files/javascript/library/jquery.js', + // read css from compiled css + '../docs/build/**/*.css', + // read js from src js + '../src/**/*.js', + // require helpers + 'helpers/*.js', + // require tests + 'modules/*.js' ], - // list of files to exclude exclude: [ '**/*.swp', 'karma.conf.js' ], - // test results reporter to use // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' - reporters: ['progress'], - + reporters: ['spec', 'coverage'], + preprocessors: { '*.js': ['coverage'] }, // web server port - port: 9876, - + port: 9999, // enable / disable colors in the output (reporters and logs) colors: true, - // level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG logLevel: config.LOG_INFO, - // enable / disable watching file and executing tests whenever any file changes autoWatch: true, - // Start these browsers, currently available: // - Chrome // - ChromeCanary @@ -61,7 +62,6 @@ module.exports = function(config) { // If browser does not capture in given timeout [ms], kill it captureTimeout: 60000, - // Continuous Integration mode // if true, it capture browsers, run tests and exit singleRun: false diff --git a/test/modules/modal.js b/test/modules/modal.js index 522ed9119..65609bf30 100755 --- a/test/modules/modal.js +++ b/test/modules/modal.js @@ -1,5 +1,10 @@ -describe("A suite", function() { +describe("UI Modal", function() { it("contains spec with an expectation", function() { expect(true).toBe(true); }); + + it("contains another spec with another expectation", function() { + expect(true).toBe(true); + }); + }); \ No newline at end of file