From b385cf137bbaf19c43f282161df6cd09ff06a04f Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Mon, 19 May 2014 11:37:50 -0700 Subject: [PATCH] Add jsdom to fix failing tests Add development dependencies needed to execute the tests. Add `npm test` support using Cake. --- .travis.yml | 3 +++ Cakefile | 4 ++-- README.md | 2 +- package.json | 8 +++++++- test/index.coffee | 3 +++ 5 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6e5919d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "0.10" diff --git a/Cakefile b/Cakefile index 9210eb3..2cc5c22 100644 --- a/Cakefile +++ b/Cakefile @@ -18,8 +18,8 @@ task 'watch', 'Watch src/ for changes', -> print data.toString() task 'test', 'Run tests', -> - mocha = spawn 'mocha', ['--compilers', 'coffee:coffee-script'] + mocha = spawn 'mocha', ['--compilers', 'coffee:coffee-script/register'] mocha.stderr.on 'data', (data) -> process.stderr.write data.toString() mocha.stdout.on 'data', (data) -> - print data.toString() \ No newline at end of file + print data.toString() diff --git a/README.md b/README.md index 9311462..28d6c7c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# jQuery.payment +# jQuery.payment [![Build Status](https://travis-ci.org/stripe/jquery.payment.svg?branch=master)](https://travis-ci.org/stripe/jquery.payment) A general purpose library for building credit card forms, validating inputs and formatting numbers. diff --git a/package.json b/package.json index 142d49a..1eadaee 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "test": "test" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "cake test" }, "repository": { "type": "git", @@ -23,5 +23,11 @@ "license": "MIT", "dependencies": { "jquery": "latest" + }, + "devDependencies": { + "jsdom": "*", + "cake": "*", + "coffee-script": "*", + "mocha": "*" } } diff --git a/test/index.coffee b/test/index.coffee index 622d94e..6bc3072 100644 --- a/test/index.coffee +++ b/test/index.coffee @@ -1,4 +1,7 @@ assert = require('assert') +jsdom = require('jsdom').jsdom +doc = jsdom('') +global.window = doc.createWindow() $ = require('jquery') global.jQuery = $