Skip to content

Commit

Permalink
Merge pull request #1 from zemlanin/master
Browse files Browse the repository at this point in the history
karma testing
  • Loading branch information
seedofjoy committed Mar 16, 2015
2 parents 6561171 + fe471d0 commit 091c7fc
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
bin = $(shell npm bin)
browserify = $(bin)/browserify

node_modules = $(shell pwd)/node_modules
karma = $(node_modules)/karma/bin/karma
karma_conf = $(shell pwd)/spec/karma.conf.js

.PHONY: example test

example:
$(browserify) examples/app.js -r ./src/main.js:'rocket-launcher' > examples/app.bundle.js

test:
$(karma) start $(karma_conf) --single-run
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"example": "examples"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "make test"
},
"repository": {
"type": "git",
Expand All @@ -31,6 +31,12 @@
},
"homepage": "https://github.com/seedofjoy/rocket-launcher",
"devDependencies": {
"browserify": "^9.0.3"
"browserify": "^9.0.3",
"karma": "^0.12.31",
"karma-browserify": "^4.0.0",
"karma-jasmine": "^0.3.5",
"karma-phantomjs-launcher": "^0.1.4",
"phantomjs": "^1.9.16",
"proxyquireify": "^1.2.2"
}
}
42 changes: 42 additions & 0 deletions spec/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = function(config) {
config.set({
basePath: '',

frameworks: ['browserify', 'jasmine'],

files: [
'**/*Spec.js'
],

exclude: [],

preprocessors: {
'**/*Spec.js': ['browserify']
},

reporters: ['progress'],

port: 9876,

colors: true,

// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

autoWatch: false,

browsers: ['PhantomJS'],

plugins: [
'karma-browserify',
'karma-jasmine',
'karma-phantomjs-launcher'
],

browserify: {
plugin: ['proxyquireify/plugin']
},

singleRun: false
});
};
35 changes: 35 additions & 0 deletions spec/main/mainSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function appendDiv() {
var node = document.createElement('div');
node.setAttribute('test-node', '');
document.body.appendChild(node);
return node;
}

describe("main", function() {
var launcher = require('../../src/main.js');

beforeEach(function() {
});

afterEach(function() {
// Array.prototype.forEach.call(
// document.querySelectorAll('[test-node]'),
// function (el) {
// el.remove();
// }
// );
});

it("should run component function", function(done) {
var node = appendDiv();
node.setAttribute('data-launcher', 'testComponent');

var component = function (element, opts) {
done();
};

launcher({
'testComponent': component
});
});
});
9 changes: 9 additions & 0 deletions spec/support/jasmine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"spec_dir": "spec",
"spec_files": [
"**/*[sS]pec.js"
],
"helpers": [
"helpers/**/*.js"
]
}

0 comments on commit 091c7fc

Please sign in to comment.