Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

karma testing #1

Merged
merged 1 commit into from
Mar 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
]
}