Refactor spec runner, update to newer mocha.

This commit is contained in:
Olly Smith 2012-10-25 07:51:13 +01:00
parent 1aca098694
commit 69f949b132
16 changed files with 4670 additions and 3728 deletions

View file

@ -7,25 +7,26 @@ module.exports = function (grunt) {
options: { bare: false }
},
spec: {
src: ['spec/lib/*.coffee'],
dest: 'build/spec/lib',
options: { bare: false }
src: ['build/spec.coffee'],
dest: 'build',
options: { bare: true }
}
},
concat: {
'build/morris.coffee': ['lib/**/*.coffee']
'build/morris.coffee': ['lib/**/*.coffee'],
'build/spec.coffee': ['spec/support/**/*.coffee', 'spec/lib/**/*.coffee']
},
min: {
'morris.min.js': 'morris.js'
},
mocha: {
spec: {
runner: ['spec/spec_runner.html'],
specs: ['build/spec/**/*.js']
src: 'spec/specs.html',
run: true
}
},
watch: {
files: ['lib/**/*.coffee', 'spec/lib/**/*.coffee'],
files: ['lib/**/*.coffee', 'spec/lib/**/*.coffee', 'spec/support/**/*.coffee'],
tasks: 'default'
}
});

View file

@ -62,16 +62,6 @@
return (number < 10 ? '0' : '') + number;
};
Morris.Data = (function() {
function Data() {}
Data.prototype.initialize = function(options) {};
return Data;
})();
Morris.Donut = (function() {
Donut.prototype.defaults = {

2
morris.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -15,7 +15,7 @@
"url": "https://github.com/oesmith/morris.js/issues"
},
"devDependencies": {
"grunt-coffee": "0.0.x",
"grunt-mocha": "git+https://github.com/oesmith/grunt-mocha.git#0e67fc4"
"grunt-coffee": "~> 0.0.6",
"grunt-mocha": "~> 0.1.7"
}
}
}

View file

@ -1,12 +1,5 @@
describe 'Morris.Line', ->
beforeEach ->
placeholder = $('<div id="graph" style="width: 100px; height: 50px"></div>')
$('#test').append(placeholder)
afterEach ->
$('#test').empty()
it 'should not alter user-supplied data', ->
my_data = [{x: 1, y: 1}, {x: 2, y: 2}]
expected_data = [{x: 1, y: 1}, {x: 2, y: 2}]

View file

@ -1,18 +0,0 @@
<!doctype html>
<head>
<meta charset="utf-8">
<script src="support/jquery-1.7.2.min.js"></script>
<link rel="stylesheet" href="support/mocha-1.1.0.css" type="text/css" media="screen" />
<script type="text/javascript" src="support/mocha-1.1.0.js"></script>
<script type="text/javascript" src="support/chai-1.0.4.js"></script>
<script type="text/javascript" src="support/raphael-2.1.0.min.js"></script>
<script type="text/javascript" src="../morris.js"></script>
<script>
should = chai.should();
</script>
</head>
<body>
<div id="mocha"></div>
<div id="test" style="visibility: hidden"></div>
</body>
</html>

31
spec/specs.html Normal file
View file

@ -0,0 +1,31 @@
<!doctype html>
<head>
<meta charset="utf-8">
<title>morris.js tests</title>
<link rel="stylesheet" href="vendor/mocha-1.6.0.css" type="text/css" media="screen" />
<script src="vendor/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="vendor/raphael-2.1.0.min.js"></script>
</head>
<body>
<div id="mocha"></div>
<script type="text/javascript" src="vendor/mocha-1.6.0.js"></script>
<script>
mocha.setup('bdd');
</script>
<script type="text/javascript" src="vendor/chai-1.3.0.js"></script>
<script>
should = chai.should();
</script>
<script type="text/javascript" src="../morris.js"></script>
<script type="text/javascript" src="../build/spec.js"></script>
<div id="test" style="visibility: hidden"></div>
<script>
if (navigator.userAgent.indexOf('PhantomJS') < 0) {
mocha.run();
}
</script>
</body>
</html>

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,6 @@
beforeEach ->
placeholder = $('<div id="graph" style="width: 600px; height: 400px"></div>')
$('#test').append(placeholder)
afterEach ->
$('#test').empty()

3649
spec/vendor/chai-1.3.0.js vendored Normal file

File diff suppressed because it is too large Load diff

2
spec/vendor/jquery-1.8.2.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
@charset "UTF-8";
body {
font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
padding: 60px 50px;
@ -37,6 +37,10 @@ body {
font-size: .8em;
}
.hidden {
display: none;
}
#mocha h2 {
font-size: 12px;
font-weight: normal;
@ -143,6 +147,14 @@ body {
-webkit-box-shadow: 0 1px 3px #eee;
}
#report.pass .test.fail {
display: none;
}
#report.fail .test.pass {
display: none;
}
#error {
color: #c00;
font-size: 1.5 em;
@ -168,6 +180,15 @@ body {
color: black;
}
#stats a {
text-decoration: none;
color: inherit;
}
#stats a:hover {
border-bottom: 1px solid #eee;
}
#stats li {
display: inline-block;
margin: 0 5px;

File diff suppressed because it is too large Load diff