Skip to content

Commit

Permalink
Added support for sauce labs
Browse files Browse the repository at this point in the history
  • Loading branch information
sclevine authored and Mariana Lenetis and Stephen Levine committed Mar 7, 2014
1 parent 090dae1 commit 504f909
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 14 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
language: node_js
node_js:
- "0.10"
- '0.10'
script: grunt ci
env:
global:
- secure: Kt+5IJDJRVwr28xRnmR5YDsJceXDcDR21/JUBfk6DYFixPbIq7LCPnZUmiSZQs8akU95ucXwB5hsirUAdEhXdYKilec6go70lticVlZBLy8IdJ+Di1uPwMOeMHvalC2P0woIRJSMzP8u5E+e+5ASggTjsXID7/p1rE0jXtoOueQ=
- secure: TED5eLMxEsyIGzKP8xxhyRDbKlIX9POzj1qgan40a8rkwIVzkdglkviLAXJJeP0ilc1GeGz1ctXyA6NAZt7RHB79mdQbH9iV1AsR29ItH4jdBs7eWRybDRKYRlmOntH0n7zlJDB4qQMxvNdI8BKYrPQymgZ3jtRJ/INOvLerg1g=
21 changes: 19 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = function (grunt) {
source: {
src: ['src/**/*.js'],
options: {
indent:4,
indent: 4,
ignores: ['src/banner.js','src/footer.js','src/d3.box.js']
}
},
Expand Down Expand Up @@ -114,6 +114,22 @@ module.exports = function (grunt) {
}
}
},
'saucelabs-jasmine': {
all: {
options: {
urls: ["http://localhost:8888/spec/"],
tunnelTimeout: 5,
build: process.env.TRAVIS_JOB_ID,
concurrency: 3,
browsers: [
{ browserName: "firefox", version: "25", platform: "linux" },
{ browserName: "safari", version: "6", platform: "OS X 10.8" },
{ browserName: "internet explorer", version: "10", platform: "WIN8" }
],
testname: "dc.js"
}
}
},
emu: {
api: {
src: output.js,
Expand Down Expand Up @@ -202,6 +218,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-docco2');
grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-saucelabs');
grunt.loadNpmTasks('grunt-markdown');
grunt.loadNpmTasks('grunt-sed');
grunt.loadNpmTasks('grunt-shell');
Expand Down Expand Up @@ -251,14 +268,14 @@ module.exports = function (grunt) {
grunt.task.run('watch');
});


// task aliases
grunt.registerTask('build', ['concat', 'uglify', 'sed']);
grunt.registerTask('docs', ['build', 'copy', 'emu', 'toc', 'markdown', 'docco']);
grunt.registerTask('web', ['docs', 'gh-pages']);
grunt.registerTask('server', ['docs', 'jasmine:specs:build', 'connect:server', 'watch:jasmine']);
grunt.registerTask('test', ['docs', 'jasmine:specs', 'test-stock-example', 'shell:hooks']);
grunt.registerTask('coverage', ['docs', 'jasmine:coverage']);
grunt.registerTask('ci', ['test', 'jasmine:specs:build', 'connect:server', 'saucelabs-jasmine']);
grunt.registerTask('lint', ['build', 'jshint']);
grunt.registerTask('default', ['build']);
};
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Build Status](https://api.travis-ci.org/dc-js/dc.js.png?branch=master)](http://travis-ci.org/dc-js/dc.js)
[![Sauce Status](https://saucelabs.com/buildstatus/sclevine)](https://saucelabs.com/u/sclevine)
[![NPM Status](https://badge.fury.io/js/dc.png)](http://badge.fury.io/js/dc)

dc.js
Expand Down Expand Up @@ -45,6 +46,18 @@ dc.js$ npm install
dc.js$ grunt test
```

Developing dc.js
----------------

### Start the development server
```
dc.js$ grunt server
```

* Jasmine specs are hosted at http://localhost:8888/spec
* The stock example is at http://localhost:8888/web
* More examples are at http://localhost:8888/web/examples

License
--------------------

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"grunt-gh-pages": "~0.8.0",
"grunt-lib-phantomjs": "~0.5.0",
"grunt-markdown": "~0.5.0",
"grunt-saucelabs": "~5.0.1",
"grunt-sed": "~0.1.1",
"grunt-shell": "~0.5.0",
"uglify-js": "2.4.x",
Expand Down
10 changes: 5 additions & 5 deletions spec/core-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('dc.core', function() {
});

describe('units', function() {
it('.integers', function() {
describe('.integers', function() {
var result;
beforeEach(function() {
result = dc.units.integers(0, 100);
Expand All @@ -142,7 +142,7 @@ describe('dc.core', function() {
});
});

it('.float', function() {
describe('.float', function() {
var result;
beforeEach(function() {
result = dc.units.fp.precision(0.001)(0.49999, 1.0);
Expand All @@ -152,7 +152,7 @@ describe('dc.core', function() {
});
});

it('.ordinal', function() {
describe('.ordinal', function() {
var result;
beforeEach(function() {
result = dc.units.ordinal("a", "d", ["a", "b", "c", "d"]);
Expand All @@ -164,7 +164,7 @@ describe('dc.core', function() {
});

describe('round', function() {
it('.floor', function() {
describe('.floor', function() {
var result;
beforeEach(function() {
result = dc.round.floor(0.33);
Expand Down Expand Up @@ -283,4 +283,4 @@ describe('dc.core', function() {
expect("group").toEqual(result.called);
});
});
});
});
147 changes: 147 additions & 0 deletions spec/helpers/jasmine-jsreporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/*
This file is part of the Jasmine JSReporter project from Ivan De Marino.
Copyright (C) 2011 Ivan De Marino (aka detro, aka detronizator), http://blog.ivandemarino.me, ivan.de.marino@gmail.com
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL IVAN DE MARINO BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

(function () {
var finalResults;

// Ensure that Jasmine library is loaded first
if (!jasmine) {
throw new Exception("[Jasmine JSReporter] 'Jasmine' library not found");
}

/**
* Round an amount to the given number of Digits.
* If no number of digits is given, than '2' is assumed.
* @param amount Amount to round
* @param numOfDecDigits Number of Digits to round to. Default value is '2'.
* @return Rounded amount */
function round (amount, numOfDecDigits) {
numOfDecDigits = numOfDecDigits || 2;
return Math.round(amount * Math.pow(10, numOfDecDigits)) / Math.pow(10, numOfDecDigits);
}

/**
* Collect information about a Suite, recursively, and return a JSON result.
* @param suite The Jasmine Suite to get data from
*/
function getSuiteData (suite) {
var suiteData = {
passed: true,
durationSec : 0,
suites: [],
description : suite.description,
specs: []
};

for (var i = 0; i < suite.children.length; ++i) {
var childFailed = false;

if (suite.children[i] instanceof jasmine.Spec) {
var specResult = suite.children[i].result;
childFailed = specResult.status === "failed";

suiteData.specs.push({
description : specResult.description,
durationSec : specResult.duration / 1000,
passed : specResult.status === "passed",
skipped : specResult.status === "disabled" || specResult.status === "pending",
passedCount : specResult.status === "passed" ? 1 : 0,
failedCount : childFailed ? 1 : 0,
totalCount : specResult.status !== "disabled" ? 1 : 0
});
} else if (suite.children[i] instanceof jasmine.Suite) {
var childSuiteData = getSuiteData(suite.children[i]);
childFailed = !childSuiteData.passed;
suiteData.suites.push(childSuiteData);
}

suiteData.passed = childFailed ? false : suiteData.passed;
}

// Rounding duration numbers to 3 decimal digits
suiteData.durationSec = round(suite.result.duration / 1000, 4);

return suiteData;
}

jasmine.getJSReport = function () {
if (finalResults) {
return finalResults;
}

return null;
};

jasmine.getJSReportAsString = function () {
return JSON.stringify(jasmine.getJSReport());
};

var JSReporter = function () {};
JSReporter.prototype = {
jasmineDone: function () {
// Attach results to the "jasmine" object to make those results easy to scrap/find
var results = getSuiteData(jasmine.getEnv().topSuite());
var totalDuration = 0;

var specs = results.specs;
for (var i = 0; i < specs.length; ++i) {
totalDuration += specs[i].durationSec;
}

var suites = results.suites;
for (i = 0; i < suites.length; ++i) {
totalDuration += suites[i].durationSec;
}

results.durationSec = round(totalDuration, 4);

// PATCH FOR SAUCE LABS LENGTH ISSUES
results.suites = [
{
description: "DC.js jasmine tests",
passed: results.passed,
durationSec: results.durationSec,
specs: [
{
description: "SEE SAUCE SCREENCAST"
}
]
}
];
/////////////////////////////////////

finalResults = results;
}
};

// export public
jasmine.JSReporter = JSReporter;
jasmine.getEnv().addReporter(new jasmine.JSReporter());
})();

2 changes: 1 addition & 1 deletion spec/number-display-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('dc.numberDisplay', function() {
it('should have text value in child', function() {
expect(chart.select("span.number-display").text()).toEqual("38.5");
});
it('redraw', function() {
describe('redraw', function() {
beforeEach(function() {
countryDimension.filterAll();
chart.redraw();
Expand Down
6 changes: 1 addition & 5 deletions spec/pie-chart-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ describe('dc.pieChart', function() {
});
});
describe('slice selection', function() {
beforeEach(function() {
});
it('on click function should be defined', function() {
expect(chart.selectAll("svg g g.pie-slice path").on("click") !== undefined).toBeTruthy();
});
Expand Down Expand Up @@ -267,8 +265,6 @@ describe('dc.pieChart', function() {
expect(cls === null || cls === "").toBeTruthy();
});
});
afterEach(function() {
});
});
describe('filter through clicking', function() {
it('onClick should trigger filtering of according group', function() {
Expand Down Expand Up @@ -364,7 +360,7 @@ describe('dc.pieChart', function() {
.othersLabel("small");
chart.render();
});
it('with normal valueAccessor', function() {
describe('with normal valueAccessor', function() {
beforeEach(function() {
chart.dimension(valueDimension).group(valueGroup)
.valueAccessor(dc.pluck('value'))
Expand Down

0 comments on commit 504f909

Please sign in to comment.