Browse Source

Merge branch 'test' of github.com:jlukic/Semantic-UI

Conflicts:
	test/fixtures/modal.html
	test/modules/modal.spec.js
pull/258/head
jlukic 11 years ago
parent
commit
c351a5b6f7
47 changed files with 5298 additions and 90 deletions
  1. 38
      Gruntfile.js
  2. 24
      karma.conf.js
  3. 4
      package.json
  4. 42
      spec/module.commented.js
  5. 3
      src/modules/accordion.js
  6. 14
      src/modules/dimmer.js
  7. 37
      src/modules/dropdown.js
  8. 27
      src/modules/modal.js
  9. 7
      src/modules/popup.js
  10. 15
      src/modules/rating.js
  11. 2
      src/modules/sidebar.js
  12. 3
      src/modules/tab.js
  13. 2
      src/modules/transition.js
  14. 10
      src/modules/video.js
  15. 320
      test/coverage/PhantomJS 1.9.2 (Linux)/index.html
  16. 1
      test/coverage/PhantomJS 1.9.2 (Linux)/prettify.css
  17. 1
      test/coverage/PhantomJS 1.9.2 (Linux)/prettify.js
  18. 1
      test/coverage/coverage-PhantomJS 1.9.2 (Linux)-20131014_012621.json
  19. 1
      test/coverage/coverage-PhantomJS 1.9.2 (Linux)-20131014_012811.json
  20. 24
      test/fixtures/accordion.html
  21. 46
      test/fixtures/checkbox.html
  22. 9
      test/fixtures/dropdown.html
  23. 2
      test/fixtures/modal.html
  24. 8
      test/fixtures/popup.html
  25. 7
      test/fixtures/rating.html
  26. 7
      test/fixtures/shape.html
  27. 25
      test/fixtures/sidebar.html
  28. 8
      test/fixtures/tab.html
  29. 1
      test/fixtures/transition.html
  30. 5
      test/fixtures/video.html
  31. 17
      test/helpers/jasmine-clog.js
  32. 43
      test/helpers/jasmine-sinon.js
  33. 28
      test/helpers/jquery-events.js
  34. 4290
      test/helpers/sinon.js
  35. 10
      test/modules/accordion.spec.js
  36. 8
      test/modules/checkbox.spec.js
  37. 8
      test/modules/dropdown.spec.js
  38. 11
      test/modules/modal.js
  39. 7
      test/modules/modal.spec.js
  40. 215
      test/modules/module.spec.js
  41. 8
      test/modules/popup.spec.js
  42. 8
      test/modules/search.spec.js
  43. 8
      test/modules/shape.spec.js
  44. 8
      test/modules/sidebar.spec.js
  45. 9
      test/modules/tab.spec.js
  46. 8
      test/modules/transition.spec.js
  47. 8
      test/modules/video.spec.js

38
Gruntfile.js

@ -16,7 +16,11 @@ module.exports = function(grunt) {
// copies examples over to docs // copies examples over to docs
'copy:examplesToDocs' 'copy:examplesToDocs'
],
testWatchTasks = [
'clear',
'karma:watch:run'
], ],
testTasks = [ testTasks = [
@ -86,6 +90,24 @@ module.exports = function(grunt) {
'copy:buildToDocs' 'copy:buildToDocs'
], ],
setWatchTests = function(action, filePath) {
var
karmaFiles = grunt.config('karma.watch.files'),
isJavascript = (filePath.search('.js') !== -1),
isModule = (filePath.search('modules/') !== -1),
isSpec = (filePath.search('.spec') !== -1),
specFile = (isSpec)
? filePath
: filePath
.replace('src/', 'test/')
.replace('.js', '.spec.js')
;
if(isJavascript && (isSpec || isModule) ) {
karmaFiles.pop();
karmaFiles.push(specFile);
}
},
setWatchFiles = function(action, filePath) { setWatchFiles = function(action, filePath) {
var var
buildPath = filePath.replace('src/', 'docs/build/').replace('less', 'css') buildPath = filePath.replace('src/', 'docs/build/').replace('less', 'css')
@ -123,9 +145,10 @@ module.exports = function(grunt) {
}, },
scripts: { scripts: {
files: [ files: [
'test/**/*.js',
'src/**/*.js' 'src/**/*.js'
], ],
tasks : ['karma:test:run']
tasks : testWatchTasks
}, },
src: { src: {
files: [ files: [
@ -141,13 +164,19 @@ module.exports = function(grunt) {
Test Test
*******************************/ *******************************/
clear: {
terminal: {
}
},
karma: { karma: {
test: {
configFile : 'test/karma.conf.js',
watch: {
configFile : 'karma.conf.js',
background : true background : true
}, },
travis: { travis: {
configFile : 'test/karma.conf.js',
configFile : 'karma.conf.js',
singleRun : true singleRun : true
} }
}, },
@ -528,6 +557,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-docco-multi'); grunt.loadNpmTasks('grunt-docco-multi');
grunt.loadNpmTasks('grunt-cssjanus'); grunt.loadNpmTasks('grunt-cssjanus');
grunt.loadNpmTasks('grunt-clear');
grunt.loadNpmTasks('grunt-karma'); grunt.loadNpmTasks('grunt-karma');
grunt.initConfig(config); grunt.initConfig(config);

test/karma.conf.js → karma.conf.js

@ -7,21 +7,29 @@ module.exports = function(config) {
// frameworks to use // frameworks to use
frameworks: [ frameworks: [
'jasmine'
'jasmine'
], ],
// list of files / patterns to load in the browser // list of files / patterns to load in the browser
files: [ files: [
// require jquery // require jquery
'../server/files/javascript/library/jquery.js',
'server/files/javascript/library/jquery.js',
// read css from compiled css // read css from compiled css
'../docs/build/**/*.css',
'docs/build/uncompressed/**/*.css',
// read js from src js // read js from src js
'../src/**/*.js',
'src/**/*.js',
// require helpers // require helpers
'helpers/*.js',
'test/helpers/*.js',
// require fixtures
{
pattern : 'test/fixtures/*.html',
included : false,
served : true
},
// require spec
'test/modules/module.spec.js',
// require tests // require tests
'modules/*.js'
'test/modules/*.js'
], ],
// list of files to exclude // list of files to exclude
@ -30,6 +38,10 @@ module.exports = function(config) {
'karma.conf.js' 'karma.conf.js'
], ],
preprocessors: {
'**/*.html': []
},
// test results reporter to use // test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['spec'], reporters: ['spec'],

4
package.json

@ -40,7 +40,7 @@
"karma-phantomjs-launcher": "~0.1.0", "karma-phantomjs-launcher": "~0.1.0",
"karma": "~0.10.2", "karma": "~0.10.2",
"grunt-karma": "~0.6.2", "grunt-karma": "~0.6.2",
"karma-coverage": "~0.1.0",
"karma-spec-reporter": "0.0.5"
"karma-spec-reporter": "0.0.5",
"grunt-clear": "~0.2.1"
} }
} }

42
spec/module.commented.js

@ -25,23 +25,6 @@ $.fn.example = function(parameters) {
// Store a reference to the module group, this can be useful to refer to other modules inside each module // Store a reference to the module group, this can be useful to refer to other modules inside each module
$allModules = $(this), $allModules = $(this),
// Extend settings to merge run-time settings with defaults
settings = ( $.isPlainObject(parameters) )
? $.extend(true, {}, $.fn.example.settings, parameters)
: $.fn.example.settings,
// Alias settings object for convenience and performance
namespace = settings.namespace,
error = settings.error,
className = settings.className,
// You may also find it useful to alias your own settings
text = settings.text,
// Define namespaces for storing module instance and binding events
eventNamespace = '.' + namespace,
moduleNamespace = 'module-' + namespace,
// Preserve selector from outside each scope and mark current time for performance tracking // Preserve selector from outside each scope and mark current time for performance tracking
moduleSelector = $allModules.selector || '', moduleSelector = $allModules.selector || '',
time = new Date().getTime(), time = new Date().getTime(),
@ -59,6 +42,28 @@ $.fn.example = function(parameters) {
$allModules $allModules
.each(function() { .each(function() {
var var
// Extend settings to merge run-time settings with defaults
settings = ( $.isPlainObject(parameters) )
? $.extend(true, {}, $.fn.example.settings, parameters)
: $.extend({}, $.fn.example.settings),
// Alias settings object for convenience and performance
namespace = settings.namespace,
error = settings.error,
className = settings.className,
// You may also find it useful to alias your own settings
text = settings.text,
// Define namespaces for storing module instance and binding events
eventNamespace = '.' + namespace,
moduleNamespace = 'module-' + namespace,
// Instance is stored and retreived in namespaced DOM metadata
instance = $(this).data(moduleNamespace),
element = this,
// Cache selectors using selector settings object for access inside instance of module // Cache selectors using selector settings object for access inside instance of module
$module = $(this), $module = $(this),
$text = $module.find(settings.selector.text), $text = $module.find(settings.selector.text),
@ -66,9 +71,6 @@ $.fn.example = function(parameters) {
// Define private variables which can be used to maintain internal state, these cannot be changed from outside the module closure so use conservatively. Default values are set using `a || b` syntax // Define private variables which can be used to maintain internal state, these cannot be changed from outside the module closure so use conservatively. Default values are set using `a || b` syntax
foo = false, foo = false,
// Instance is stored and retreived in namespaced DOM metadata
instance = $module.data(moduleNamespace),
element = this,
module module
; ;

3
src/modules/accordion.js

@ -28,7 +28,7 @@ $.fn.accordion = function(parameters) {
var var
settings = ( $.isPlainObject(parameters) ) settings = ( $.isPlainObject(parameters) )
? $.extend(true, {}, $.fn.accordion.settings, parameters) ? $.extend(true, {}, $.fn.accordion.settings, parameters)
: $.fn.accordion.settings,
: $.extend({}, $.fn.accordion.settings),
className = settings.className, className = settings.className,
namespace = settings.namespace, namespace = settings.namespace,
@ -60,6 +60,7 @@ $.fn.accordion = function(parameters) {
}, },
instantiate: function() { instantiate: function() {
instance = module;
$module $module
.data(moduleNamespace, module) .data(moduleNamespace, module)
; ;

14
src/modules/dimmer.js

@ -30,7 +30,7 @@ $.fn.dimmer = function(parameters) {
var var
settings = ( $.isPlainObject(parameters) ) settings = ( $.isPlainObject(parameters) )
? $.extend(true, {}, $.fn.dimmer.settings, parameters) ? $.extend(true, {}, $.fn.dimmer.settings, parameters)
: $.fn.dimmer.settings,
: $.extend({}, $.fn.dimmer.settings),
selector = settings.selector, selector = settings.selector,
namespace = settings.namespace, namespace = settings.namespace,
@ -45,12 +45,12 @@ $.fn.dimmer = function(parameters) {
? 'touchstart' ? 'touchstart'
: 'click', : 'click',
$module = $(this),
$module = $(this),
$dimmer, $dimmer,
$dimmable, $dimmable,
element = this,
instance = $module.data(moduleNamespace),
element = this,
instance = $module.data(moduleNamespace),
module module
; ;
@ -111,10 +111,14 @@ $.fn.dimmer = function(parameters) {
destroy: function() { destroy: function() {
module.verbose('Destroying previous module', $dimmer); module.verbose('Destroying previous module', $dimmer);
$module
.removeData(moduleNamespace)
;
$dimmable $dimmable
.off(eventNamespace) .off(eventNamespace)
; ;
$dimmer $dimmer
.remove()
.off(eventNamespace) .off(eventNamespace)
; ;
}, },
@ -515,8 +519,8 @@ $.fn.dimmer.settings = {
name : 'Dimmer', name : 'Dimmer',
namespace : 'dimmer', namespace : 'dimmer',
verbose : true,
debug : true, debug : true,
verbose : true,
performance : true, performance : true,
transition : 'fade', transition : 'fade',

37
src/modules/dropdown.js

@ -31,28 +31,28 @@ $.fn.dropdown = function(parameters) {
var var
settings = ( $.isPlainObject(parameters) ) settings = ( $.isPlainObject(parameters) )
? $.extend(true, {}, $.fn.dropdown.settings, parameters) ? $.extend(true, {}, $.fn.dropdown.settings, parameters)
: $.fn.dropdown.settings,
: $.extend({}, $.fn.dropdown.settings),
className = settings.className,
metadata = settings.metadata,
namespace = settings.namespace,
selector = settings.selector,
error = settings.error,
className = settings.className,
metadata = settings.metadata,
namespace = settings.namespace,
selector = settings.selector,
error = settings.error,
eventNamespace = '.' + namespace,
dropdownNamespace = 'module-' + namespace,
isTouchDevice = ('ontouchstart' in document.documentElement),
eventNamespace = '.' + namespace,
moduleNamespace = 'module-' + namespace,
isTouchDevice = ('ontouchstart' in document.documentElement),
$module = $(this),
$item = $module.find(selector.item),
$text = $module.find(selector.text),
$input = $module.find(selector.input),
$module = $(this),
$item = $module.find(selector.item),
$text = $module.find(selector.text),
$input = $module.find(selector.input),
$menu = $module.children(selector.menu),
$menu = $module.children(selector.menu),
element = this,
instance = $module.data(dropdownNamespace),
element = this,
instance = $module.data(moduleNamespace),
module module
; ;
@ -94,8 +94,9 @@ $.fn.dropdown = function(parameters) {
instantiate: function() { instantiate: function() {
module.verbose('Storing instance of dropdown', module); module.verbose('Storing instance of dropdown', module);
instance = module;
$module $module
.data(dropdownNamespace, module)
.data(moduleNamespace, module)
; ;
}, },
@ -106,7 +107,7 @@ $.fn.dropdown = function(parameters) {
; ;
$module $module
.off(eventNamespace) .off(eventNamespace)
.removeData(dropdownNamespace)
.removeData(moduleNamespace)
; ;
}, },

27
src/modules/modal.js

@ -27,13 +27,12 @@ $.fn.modal = function(parameters) {
invokedResponse invokedResponse
; ;
$allModules $allModules
.each(function() {
.each(function(index) {
var var
settings = ( $.isPlainObject(parameters) ) settings = ( $.isPlainObject(parameters) )
? $.extend(true, {}, $.fn.modal.settings, parameters) ? $.extend(true, {}, $.fn.modal.settings, parameters)
: $.fn.modal.settings,
: $.extend(true, {}, $.fn.modal.settings),
selector = settings.selector, selector = settings.selector,
className = settings.className, className = settings.className,
@ -44,17 +43,17 @@ $.fn.modal = function(parameters) {
moduleNamespace = 'module-' + namespace, moduleNamespace = 'module-' + namespace,
moduleSelector = $allModules.selector || '', moduleSelector = $allModules.selector || '',
$module = $(this),
$context = $(settings.context),
$otherModals = $allModules.not($module),
$close = $module.find(selector.close),
$module = $(this),
$context = $(settings.context),
$otherModals = $allModules.not($module),
$close = $module.find(selector.close),
$focusedElement, $focusedElement,
$dimmable, $dimmable,
$dimmer, $dimmer,
element = this,
instance = $module.data(moduleNamespace),
element = this,
instance = $module.data(moduleNamespace),
module module
; ;
@ -64,6 +63,7 @@ $.fn.modal = function(parameters) {
module.verbose('Initializing dimmer', $context); module.verbose('Initializing dimmer', $context);
$dimmable = $context $dimmable = $context
.dimmer()
.dimmer('add content', $module) .dimmer('add content', $module)
; ;
$dimmer = $context $dimmer = $context
@ -94,7 +94,16 @@ $.fn.modal = function(parameters) {
module.verbose('Destroying previous modal'); module.verbose('Destroying previous modal');
$module $module
.off(eventNamespace) .off(eventNamespace)
.removeData(moduleNamespace)
;
$close
.off(eventNamespace)
; ;
if($dimmable) {
$dimmable
.dimmer('destroy')
;
}
}, },
refresh: function() { refresh: function() {

7
src/modules/popup.js

@ -32,7 +32,7 @@ $.fn.popup = function(parameters) {
var var
settings = ( $.isPlainObject(parameters) ) settings = ( $.isPlainObject(parameters) )
? $.extend(true, {}, $.fn.popup.settings, parameters) ? $.extend(true, {}, $.fn.popup.settings, parameters)
: $.fn.popup.settings,
: $.extend({}, $.fn.popup.settings),
selector = settings.selector, selector = settings.selector,
className = settings.className, className = settings.className,
@ -41,7 +41,7 @@ $.fn.popup = function(parameters) {
namespace = settings.namespace, namespace = settings.namespace,
eventNamespace = '.' + settings.namespace, eventNamespace = '.' + settings.namespace,
moduleNamespace = settings.namespace + '-module',
moduleNamespace = 'module-' + namespace,
$module = $(this), $module = $(this),
@ -98,6 +98,9 @@ $.fn.popup = function(parameters) {
destroy: function() { destroy: function() {
module.debug('Destroying previous module'); module.debug('Destroying previous module');
$window
.off(eventNamespace)
;
$module $module
.off(eventNamespace) .off(eventNamespace)
.removeData(moduleNamespace) .removeData(moduleNamespace)

15
src/modules/rating.js

@ -27,7 +27,9 @@ $.fn.rating = function(parameters) {
$allModules $allModules
.each(function() { .each(function() {
var var
settings = $.extend(true, {}, $.fn.rating.settings, parameters),
settings = ( $.isPlainObject(parameters) )
? $.extend(true, {}, $.fn.rating.settings, parameters)
: $.extend({}, $.fn.rating.settings),
namespace = settings.namespace, namespace = settings.namespace,
className = settings.className, className = settings.className,
@ -38,11 +40,12 @@ $.fn.rating = function(parameters) {
eventNamespace = '.' + namespace, eventNamespace = '.' + namespace,
moduleNamespace = 'module-' + namespace, moduleNamespace = 'module-' + namespace,
element = this,
instance = $(this).data(moduleNamespace),
$module = $(this), $module = $(this),
$icon = $module.find(selector.icon), $icon = $module.find(selector.icon),
element = this,
instance = $module.data(moduleNamespace),
module module
; ;
@ -71,12 +74,14 @@ $.fn.rating = function(parameters) {
instantiate: function() { instantiate: function() {
module.verbose('Instantiating module', settings); module.verbose('Instantiating module', settings);
instance = module;
$module $module
.data(moduleNamespace, module) .data(moduleNamespace, module)
; ;
}, },
destroy: function() { destroy: function() {
module.verbose('Destroying previous instance', instance);
$module $module
.removeData(moduleNamespace) .removeData(moduleNamespace)
; ;
@ -274,6 +279,9 @@ $.fn.rating = function(parameters) {
if(moduleSelector) { if(moduleSelector) {
title += ' \'' + moduleSelector + '\''; title += ' \'' + moduleSelector + '\'';
} }
if($allModules.size() > 1) {
title += ' ' + '(' + $allModules.size() + ')';
}
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
console.groupCollapsed(title); console.groupCollapsed(title);
if(console.table) { if(console.table) {
@ -343,7 +351,6 @@ $.fn.rating = function(parameters) {
return found; return found;
} }
}; };
if(methodInvoked) { if(methodInvoked) {
if(instance === undefined) { if(instance === undefined) {
module.initialize(); module.initialize();

2
src/modules/sidebar.js

@ -30,7 +30,7 @@ $.fn.sidebar = function(parameters) {
var var
settings = ( $.isPlainObject(parameters) ) settings = ( $.isPlainObject(parameters) )
? $.extend(true, {}, $.fn.sidebar.settings, parameters) ? $.extend(true, {}, $.fn.sidebar.settings, parameters)
: $.fn.sidebar.settings,
: $.extend({}, $.fn.sidebar.settings),
selector = settings.selector, selector = settings.selector,
className = settings.className, className = settings.className,

3
src/modules/tab.js

@ -38,7 +38,7 @@
error = settings.error, error = settings.error,
eventNamespace = '.' + settings.namespace, eventNamespace = '.' + settings.namespace,
moduleNamespace = settings.namespace + '-module',
moduleNamespace = 'module-' + settings.namespace,
instance = $module.data(moduleNamespace), instance = $module.data(moduleNamespace),
@ -103,6 +103,7 @@
destroy: function() { destroy: function() {
module.debug('Destroying tabs', $module); module.debug('Destroying tabs', $module);
$module $module
.removeData(moduleNamespace)
.off(eventNamespace) .off(eventNamespace)
; ;
}, },

2
src/modules/transition.js

@ -314,7 +314,7 @@ $.fn.transition = function() {
animation : animation animation : animation
}); });
} }
return $.fn.transition.settings;
return $.extend({}, $.fn.transition.settings);
}, },
animationName: function() { animationName: function() {

10
src/modules/video.js

@ -32,7 +32,7 @@ $.fn.video = function(parameters) {
var var
settings = ( $.isPlainObject(parameters) ) settings = ( $.isPlainObject(parameters) )
? $.extend(true, {}, $.fn.video.settings, parameters) ? $.extend(true, {}, $.fn.video.settings, parameters)
: $.fn.video.settings,
: $.extend({}, $.fn.video.settings),
selector = settings.selector, selector = settings.selector,
className = settings.className, className = settings.className,
@ -41,7 +41,7 @@ $.fn.video = function(parameters) {
namespace = settings.namespace, namespace = settings.namespace,
eventNamespace = '.' + namespace, eventNamespace = '.' + namespace,
moduleNamespace = namespace + '-module',
moduleNamespace = 'module-' + namespace,
$module = $(this), $module = $(this),
$placeholder = $module.find(selector.placeholder), $placeholder = $module.find(selector.placeholder),
@ -80,6 +80,12 @@ $.fn.video = function(parameters) {
.removeData(moduleNamespace) .removeData(moduleNamespace)
.off(eventNamespace) .off(eventNamespace)
; ;
$placeholder
.off(eventNamespace)
;
$playButton
.off(eventNamespace)
;
}, },
// sets new video // sets new video

320
test/coverage/PhantomJS 1.9.2 (Linux)/index.html

@ -0,0 +1,320 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for All files</title>
<meta charset="utf-8">
<link rel="stylesheet" href="prettify.css">
<style>
body, html {
margin:0; padding: 0;
}
body {
font-family: Helvetica Neue, Helvetica,Arial;
font-size: 10pt;
}
div.header, div.footer {
background: #eee;
padding: 1em;
}
div.header {
z-index: 100;
position: fixed;
top: 0;
border-bottom: 1px solid #666;
width: 100%;
}
div.footer {
border-top: 1px solid #666;
}
div.body {
margin-top: 10em;
}
div.meta {
font-size: 90%;
text-align: center;
}
h1, h2, h3 {
font-weight: normal;
}
h1 {
font-size: 12pt;
}
h2 {
font-size: 10pt;
}
pre {
font-family: Consolas, Menlo, Monaco, monospace;
margin: 0;
padding: 0;
line-height: 14px;
font-size: 14px;
-moz-tab-size: 2;
-o-tab-size: 2;
tab-size: 2;
}
div.path { font-size: 110%; }
div.path a:link, div.path a:visited { color: #000; }
table.coverage { border-collapse: collapse; margin:0; padding: 0 }
table.coverage td {
margin: 0;
padding: 0;
color: #111;
vertical-align: top;
}
table.coverage td.line-count {
width: 50px;
text-align: right;
padding-right: 5px;
}
table.coverage td.line-coverage {
color: #777 !important;
text-align: right;
border-left: 1px solid #666;
border-right: 1px solid #666;
}
table.coverage td.text {
}
table.coverage td span.cline-any {
display: inline-block;
padding: 0 5px;
width: 40px;
}
table.coverage td span.cline-neutral {
background: #eee;
}
table.coverage td span.cline-yes {
background: #b5d592;
color: #999;
}
table.coverage td span.cline-no {
background: #fc8c84;
}
.cstat-yes { color: #111; }
.cstat-no { background: #fc8c84; color: #111; }
.fstat-no { background: #ffc520; color: #111 !important; }
.cbranch-no { background: yellow !important; color: #111; }
.missing-if-branch {
display: inline-block;
margin-right: 10px;
position: relative;
padding: 0 4px;
background: black;
color: yellow;
xtext-decoration: line-through;
}
.missing-if-branch .typ {
color: inherit !important;
}
.entity, .metric { font-weight: bold; }
.metric { display: inline-block; border: 1px solid #333; padding: 0.3em; background: white; }
.metric small { font-size: 80%; font-weight: normal; color: #666; }
div.coverage-summary table { border-collapse: collapse; margin: 3em; font-size: 110%; }
div.coverage-summary td, div.coverage-summary table th { margin: 0; padding: 0.25em 1em; border-top: 1px solid #666; border-bottom: 1px solid #666; }
div.coverage-summary th { text-align: left; border: 1px solid #666; background: #eee; font-weight: normal; }
div.coverage-summary th.file { border-right: none !important; }
div.coverage-summary th.pic { border-left: none !important; text-align: right; }
div.coverage-summary th.pct { border-right: none !important; }
div.coverage-summary th.abs { border-left: none !important; text-align: right; }
div.coverage-summary td.pct { text-align: right; border-left: 1px solid #666; }
div.coverage-summary td.abs { text-align: right; font-size: 90%; color: #444; border-right: 1px solid #666; }
div.coverage-summary td.file { text-align: right; border-left: 1px solid #666; white-space: nowrap; }
div.coverage-summary td.pic { min-width: 120px !important; }
div.coverage-summary a:link { text-decoration: none; color: #000; }
div.coverage-summary a:visited { text-decoration: none; color: #333; }
div.coverage-summary a:hover { text-decoration: underline; }
div.coverage-summary tfoot td { border-top: 1px solid #666; }
div.coverage-summary .yui3-datatable-sort-indicator, div.coverage-summary .dummy-sort-indicator {
height: 10px;
width: 7px;
display: inline-block;
margin-left: 0.5em;
}
div.coverage-summary .yui3-datatable-sort-indicator {
background: url("http://yui.yahooapis.com/3.6.0/build/datatable-sort/assets/skins/sam/sort-arrow-sprite.png") no-repeat scroll 0 0 transparent;
}
div.coverage-summary .yui3-datatable-sorted .yui3-datatable-sort-indicator {
background-position: 0 -20px;
}
div.coverage-summary .yui3-datatable-sorted-desc .yui3-datatable-sort-indicator {
background-position: 0 -10px;
}
.high { background: #b5d592 !important; }
.medium { background: #ffe87c !important; }
.low { background: #fc8c84 !important; }
span.cover-fill, span.cover-empty {
display:inline-block;
border:1px solid #444;
background: white;
height: 12px;
}
span.cover-fill {
background: #ccc;
border-right: 1px solid #444;
}
span.cover-empty {
background: white;
border-left: none;
}
span.cover-full {
border-right: none !important;
}
pre.prettyprint {
border: none !important;
padding: 0 !important;
margin: 0 !important;
}
.com { color: #999 !important; }
</style>
</head>
<body>
<div class="header high">
<h1>Code coverage report for <span class="entity">All files</span></h1>
<h2>
Statements: <span class="metric">100% <small>(0 / 0)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
Branches: <span class="metric">100% <small>(0 / 0)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
Functions: <span class="metric">100% <small>(0 / 0)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
Lines: <span class="metric">100% <small>(0 / 0)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
</h2>
<div class="path"></div>
</div>
<div class="body">
<div class="coverage-summary">
<table>
<thead>
<tr>
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="footer">
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Oct 14 2013 01:28:11 GMT-0400 (EDT)</div>
</div>
<script src="prettify.js"></script>
<script src="http://yui.yahooapis.com/3.6.0/build/yui/yui-min.js"></script>
<script>
YUI().use('datatable', function (Y) {
var formatters = {
pct: function (o) {
o.className += o.record.get('classes')[o.column.key];
try {
return o.value.toFixed(2) + '%';
} catch (ex) { return o.value + '%'; }
},
html: function (o) {
o.className += o.record.get('classes')[o.column.key];
return o.record.get(o.column.key + '_html');
}
},
defaultFormatter = function (o) {
o.className += o.record.get('classes')[o.column.key];
return o.value;
};
function getColumns(theadNode) {
var colNodes = theadNode.all('tr th'),
cols = [],
col;
colNodes.each(function (colNode) {
col = {
key: colNode.getAttribute('data-col'),
label: colNode.get('innerHTML') || ' ',
sortable: !colNode.getAttribute('data-nosort'),
className: colNode.getAttribute('class'),
type: colNode.getAttribute('data-type'),
allowHTML: colNode.getAttribute('data-html') === 'true' || colNode.getAttribute('data-fmt') === 'html'
};
col.formatter = formatters[colNode.getAttribute('data-fmt')] || defaultFormatter;
cols.push(col);
});
return cols;
}
function getRowData(trNode, cols) {
var tdNodes = trNode.all('td'),
i,
row = { classes: {} },
node,
name;
for (i = 0; i < cols.length; i += 1) {
name = cols[i].key;
node = tdNodes.item(i);
row[name] = node.getAttribute('data-value') || node.get('innerHTML');
row[name + '_html'] = node.get('innerHTML');
row.classes[name] = node.getAttribute('class');
//Y.log('Name: ' + name + '; Value: ' + row[name]);
if (cols[i].type === 'number') { row[name] = row[name] * 1; }
}
//Y.log(row);
return row;
}
function getData(tbodyNode, cols) {
var data = [];
tbodyNode.all('tr').each(function (trNode) {
data.push(getRowData(trNode, cols));
});
return data;
}
function replaceTable(node) {
if (!node) { return; }
var cols = getColumns(node.one('thead')),
data = getData(node.one('tbody'), cols),
table,
parent = node.get('parentNode');
table = new Y.DataTable({
columns: cols,
data: data,
sortBy: 'file'
});
parent.set('innerHTML', '');
table.render(parent);
}
Y.on('domready', function () {
replaceTable(Y.one('div.coverage-summary table'));
if (typeof prettyPrint === 'function') {
prettyPrint();
}
});
});
</script>
</body>
</html>

1
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}

1
test/coverage/PhantomJS 1.9.2 (Linux)/prettify.js
File diff suppressed because it is too large
View File

1
test/coverage/coverage-PhantomJS 1.9.2 (Linux)-20131014_012621.json

@ -0,0 +1 @@
{}

1
test/coverage/coverage-PhantomJS 1.9.2 (Linux)-20131014_012811.json

@ -0,0 +1 @@
{}

24
test/fixtures/accordion.html

@ -0,0 +1,24 @@
<div class="ui accordion">
<div class="active title">
<i class="dropdown icon"></i>
What is a dog?
</div>
<div class="active content">
<p>A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.</p>
</div>
<div class="title">
<i class="dropdown icon"></i>
What kinds of dogs are there?
</div>
<div class="content">
<p>There are many breeds of dogs. Each breed varies in size and temperament. Owners often select a breed of dog that they find to be compatible with their own lifestyle and desires from a companion.</p>
</div>
<div class="title">
<i class="dropdown icon"></i>
How do you acquire a dog?
</div>
<div class="content">
<p>Three common ways for a prospective owner to acquire a dog is from pet shops, private owners, or shelters.</p>
<p>A pet shop may be the most convenient way to buy a dog. Buying a dog from a private owner allows you to assess the pedigree and upbringing of your dog before choosing to take it home. Lastly, finding your dog from a shelter, helps give a good home to a dog who may not find one so readily.</p>
</div>
</div>

46
test/fixtures/checkbox.html

@ -0,0 +1,46 @@
<div class="ui form">
<div class="grouped inline fields">
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" checked="checked" />
<label>Apples</label>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" />
<label>Oranges</label>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" />
<label>Pears</label>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" />
<label>Grapefruit</label>
</div>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input type="checkbox">
<label>Poodle</label>
</div>
</div>
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" name="pet" />
<label>Allow other people to pet my dog</label>
</div>
</div>
<div class="field">
<div class="ui slider checkbox">
<input type="checkbox" name="pet" />
<label>Allow other people to pet my dog</label>
</div>
</div>
</div>

9
test/fixtures/dropdown.html

@ -0,0 +1,9 @@
<div class="ui selection dropdown">
<input type="hidden" name="gender">
<i class="dropdown icon"></i>
<div class="default text">Gender</div>
<div class="menu">
<div class="item" data-value="male">Male</div>
<div class="item" data-value="female">Female</div>
</div>
</div>

2
test/fixtures/modal.html

@ -5,7 +5,7 @@
</div> </div>
<div class="content"> <div class="content">
<div class="left"> <div class="left">
<img class="ui fluid image" src="/images/demo/avatar2.jpg">
<img class="ui fluid image">
</div> </div>
<div class="right"> <div class="right">
<div class="ui header">Are you sure you want to upload that?</div> <div class="ui header">Are you sure you want to upload that?</div>

8
test/fixtures/popup.html

@ -0,0 +1,8 @@
<i class="circular heart icon link" data-content="Top Left" data-position="top left"></i>
<i class="circular heart icon link" data-content="Top Center" data-position="top center"></i>
<i class="circular heart icon link" data-content="Top Right" data-position="top right"></i>
<i class="circular heart icon link" data-content="Left Center" data-position="left center"></i>
<i class="circular heart icon link" data-content="Right Center" data-position="right center"></i>
<i class="circular heart icon link" data-content="Bottom Left" data-position="bottom left"></i>
<i class="circular heart icon link" data-content="Bottom Center" data-position="bottom center"></i>
<i class="circular heart icon link" data-content="Bottom Right" data-position="bottom right"></i>

7
test/fixtures/rating.html

@ -0,0 +1,7 @@
<div class="ui star rating">
<i class="icon"></i>
<i class="icon"></i>
<i class="icon"></i>
<i class="icon"></i>
<i class="icon"></i>
</div>

7
test/fixtures/shape.html

@ -0,0 +1,7 @@
<div class="ui shape">
<div class="sides">
<div class="active side">This side is visible.</div>
<div class="side">This side is not visible.</div>
<div class="side">This side is not visible.</div>
</div>
</div>

25
test/fixtures/sidebar.html

@ -0,0 +1,25 @@
<div class="ui red vertical demo sidebar menu">
<a class="item">
<i class="home icon"></i>
Home
</a>
<a class="active item">
<i class="heart icon"></i>
Current Section
</a>
<a class="item">
<i class="facebook icon"></i>
Like us on Facebook
</a>
<div class="item">
<b>More</b>
<div class="menu">
<a class="item">About</a>
<a class="item">Contact Us</a>
</div>
</div>
</div>
<div class="ui disabled teal toggle button">
<i class="left arrow icon"></i>
Trigger Sidebar
</div>

8
test/fixtures/tab.html

@ -0,0 +1,8 @@
<div class="ui menu">
<a class="active item" data-tab="first">First</a>
<a class="item" data-tab="second">Second</a>
<a class="item" data-tab="third">Third</a>
</div>
<div class="ui active tab segment" data-tab="first">First</div>
<div class="ui tab segment" data-tab="second">Second</div>
<div class="ui tab segment" data-tab="third">Third</div>

1
test/fixtures/transition.html

@ -0,0 +1 @@
<div class="ui image"></div>

5
test/fixtures/video.html

@ -0,0 +1,5 @@
<div class="ui video">
<div class="play"></div>
<div class="placeholder"></div>
<div class="embed"></div>
</div>

17
test/helpers/jasmine-clog.js

@ -0,0 +1,17 @@
// Allow for console.log to not break IE
if (typeof window.console == "undefined" || typeof window.console.log == "undefined") {
window.console = {
log : function() {},
info : function(){},
warn : function(){}
};
}
if(typeof window.console.group == 'undefined' || typeof window.console.groupEnd == 'undefined' || typeof window.console.groupCollapsed == 'undefined') {
window.console.group = function(){};
window.console.groupEnd = function(){};
window.console.groupCollapsed = function(){};
}
if(typeof window.console.markTimeline == 'undefined') {
window.console.markTimeline = function(){};
}
window.console.clear = function(){};

43
test/helpers/jasmine-sinon.js

@ -0,0 +1,43 @@
/* global jasmine */
'use strict';
(function(jasmine, beforeEach) {
var spyMatchers = 'called calledOnce calledTwice calledThrice calledBefore calledAfter calledOn alwaysCalledOn calledWith alwaysCalledWith calledWithExactly alwaysCalledWithExactly calledWithMatch alwaysCalledWithMatch'.split(' '),
i = spyMatchers.length,
spyMatcherHash = {},
unusualMatchers = {
"returned": "toHaveReturned",
"alwaysReturned": "toHaveAlwaysReturned",
"threw": "toHaveThrown",
"alwaysThrew": "toHaveAlwaysThrown"
},
getMatcherFunction = function(sinonName, matcherName) {
var original = jasmine.Matchers.prototype[matcherName];
return function () {
if (jasmine.isSpy(this.actual) && original) {
return original.apply(this, arguments);
}
var sinonProperty = this.actual[sinonName];
return (typeof sinonProperty === 'function') ? sinonProperty.apply(this.actual, arguments) : sinonProperty;
};
};
while(i--) {
var sinonName = spyMatchers[i],
matcherName = "toHaveBeen" + sinonName.charAt(0).toUpperCase() + sinonName.slice(1);
spyMatcherHash[matcherName] = getMatcherFunction(sinonName, matcherName);
}
for (var j in unusualMatchers) {
spyMatcherHash[unusualMatchers[j]] = getMatcherFunction(j, unusualMatchers[j]);
}
beforeEach(function() {
this.addMatchers(spyMatcherHash);
});
})(jasmine, beforeEach);

28
test/helpers/jquery-events.js

@ -0,0 +1,28 @@
(function($) {
$.events = function(selector, root) {
var s = [];
$(selector || '*', root).addBack().each(function() {
// the following line is the only change
var e = $._data(this, 'events');
if(!e) return;
s.push(this.tagName);
if(this.id) s.push('#', this.id);
if(this.className) s.push('.', this.className.replace(/ +/g, '.'));
for(var p in e) {
var r = e[p],
h = r.length - r.delegateCount;
if(h)
s.push('\n', h, ' ', p, ' handler', h > 1 ? 's' : '');
if(r.delegateCount) {
for(var q = 0; q < r.length; q++)
if(r[q].selector) s.push('\n', p, ' for ', r[q].selector);
}
}
s.push('\n\n');
});
return s.join('');
}
$.fn.events = function(selector) {
return $.events(selector, this);
}
})(jQuery);

4290
test/helpers/sinon.js
File diff suppressed because it is too large
View File

10
test/modules/accordion.spec.js

@ -0,0 +1,10 @@
describe("UI Accordion", function() {
$.fn.dimmer.settings.debug = false;
moduleTests({
module : 'accordion',
element : '.ui.accordion'
});
});

8
test/modules/checkbox.spec.js

@ -0,0 +1,8 @@
describe("UI Checkbox", function() {
moduleTests({
module : 'checkbox',
element : '.ui.checkbox'
});
});

8
test/modules/dropdown.spec.js

@ -0,0 +1,8 @@
describe("UI Dropdown", function() {
moduleTests({
module : 'dropdown',
element : '.ui.dropdown'
});
});

11
test/modules/modal.js

@ -1,11 +0,0 @@
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);
});
});

7
test/modules/modal.spec.js

@ -1,7 +1,10 @@
describe("UI Modal", function() { describe("UI Modal", function() {
it("should have an instance in metadata after init", function() {
expect(true).toBe(true);
$.fn.dimmer.settings.debug = false;
moduleTests({
module : 'modal',
element : '.ui.modal'
}); });
}); });

215
test/modules/module.spec.js

@ -0,0 +1,215 @@
function moduleTests(ui) {
var
module = ui.module,
element = ui.element,
singleton = ui.singleton,
name = $.fn[module].settings.name,
testValue = 'Test',
fixtures = jasmine.getFixtures(),
originalSettings,
$modules,
$oneModule,
$module,
$clone
;
// set fixture path
fixtures.fixturesPath = 'base/test/fixtures/';
// disable debug
$.fn[module].settings.debug = false;
$.fn[module].settings.performance = false;
$.fn[module].settings.verbose = false;
beforeEach(function() {
// load fixtures
fixtures.load(module + '.html');
// save settings
originalSettings = $.fn[module].settings;
// module available in scope
$module = $(element);
// one module available in fixture
if($module.size() == 1) {
$oneModule = $module;
$clone = $module.clone().appendTo( $(sandbox()) );
$modules = $clone.add($module);
}
// multiple modules available in fixture
else {
$modules = $(element);
$clone = $module.eq(1);
$oneModule = $modules.first();
}
});
afterEach(function() {
// restore settings
$.fn[module].settings = originalSettings;
// remove element
$(element).remove();
});
/*******************************
Module
*******************************/
/*-------------------
Instantiation
--------------------*/
describe('Module', function() {
it("allows chaining when no settings returned", function() {
var $chain = $modules[module]();
expect($chain).toExist();
expect($chain.size()).toBe($modules.size());
});
it("returns a string when one setting returned", function() {
var result = $oneModule[module]('setting', 'name');
expect(typeof result).toBe('string');
});
it("returns an array when multiple settings returned", function() {
var result = $modules[module]('setting', 'name');
expect( $.isArray(result) ).toBeTruthy();
});
it("has an instance in metadata after init", function() {
$oneModule[module]();
expect($module).toHaveData('module-' + module);
});
});
/*-------------------
Settings
--------------------*/
describe('Settings', function() {
it("clears settings on re-init", function() {
$oneModule[module]({
name: testValue
});
var retrievedValue = $oneModule[module]('setting', 'name');
expect(retrievedValue).toBe(testValue);
// reinit
$oneModule[module]();
retrievedValue = $oneModule[module]('setting', 'name');
expect(retrievedValue).toBe(name);
});
it("allows default settings to be changed", function() {
$.fn[module].settings.name = testValue;
$oneModule[module]();
var retrievedValue = $oneModule[module]('setting', 'name');
$.fn[module].settings.name = name;
expect(retrievedValue).toBe(testValue);
});
it("allows settings to be changed during init", function() {
$oneModule[module]({
name: testValue
});
var retrievedValue = $oneModule[module]('setting', 'name');
expect(retrievedValue).toBe(testValue);
});
it("allows settings to be changed during runtime", function() {
$oneModule[module]();
var retrievedValue = $oneModule[module]('setting', 'name');
expect(retrievedValue).toBe(name);
});
});
/*-------------------
Groups
--------------------*/
if(!singleton) {
describe('Group Contamination', function() {
it("creates settings for all instances", function() {
$modules[module]('setting', 'name', testValue);
var retrievedValue = $oneModule[module]('setting', 'name');
var clonedSetting = $clone[module]('setting', 'name');
expect(retrievedValue).toBe(testValue);
expect(clonedSetting).toBe(testValue);
$oneModule[module]({
'name': testValue
});
expect(retrievedValue).toBe(testValue);
expect(clonedSetting).toBe(testValue);
});
it("does not change other elements settings when changing one element", function() {
$modules[module]();
$oneModule[module]('setting', 'name', testValue);
var retrievedValue = $oneModule[module]('setting', 'name');
var clonedSetting = $clone[module]('setting', 'name');
expect(retrievedValue).toBe(testValue);
expect(clonedSetting).toBe(name);
});
it("does not change other elements when re-initalized", function() {
$modules[module]();
$oneModule[module]({
'name': testValue
});
var retrievedValue = $oneModule[module]('setting', 'name');
var clonedSetting = $clone[module]('setting', 'name');
expect(retrievedValue).toBe(testValue);
expect(clonedSetting).toBe(name);
});
});
}
/*-------------------
Destroy
--------------------*/
describe('Destroy', function() {
it("removes all events from page", function() {
$module[module]('destroy');
expect($.events().length).toBe(0);
});
it("removes instance metadata", function() {
$module[module]('destroy');
expect( $module.data('module-'+ module) ).toBe(undefined);
});
});
}

8
test/modules/popup.spec.js

@ -0,0 +1,8 @@
describe("UI Popup", function() {
moduleTests({
module : 'popup',
element : 'i.icon'
});
});

8
test/modules/search.spec.js

@ -0,0 +1,8 @@
xdescribe("UI Search", function() {
moduleTests({
module : 'search',
element : '.ui.search'
});
});

8
test/modules/shape.spec.js

@ -0,0 +1,8 @@
describe("UI Shape", function() {
moduleTests({
module : 'shape',
element : '.ui.shape'
});
});

8
test/modules/sidebar.spec.js

@ -0,0 +1,8 @@
describe("UI Rating", function() {
moduleTests({
module : 'rating',
element : '.ui.rating'
});
});

9
test/modules/tab.spec.js

@ -0,0 +1,9 @@
xdescribe("UI Tab", function() {
moduleTests({
module : 'tab',
element : '.ui.menu .item',
singleton : true
});
});

8
test/modules/transition.spec.js

@ -0,0 +1,8 @@
xdescribe("UI Transition", function() {
moduleTests({
module : 'transition',
element : '.ui.image'
});
});

8
test/modules/video.spec.js

@ -0,0 +1,8 @@
describe("UI Video", function() {
moduleTests({
module : 'video',
element : '.ui.video'
});
});
Loading…
Cancel
Save