NPMBIN:=$(shell npm bin)
-all: npmdeps build-dist
+all: npmdeps build
clean:
rm -rvf dist
for x in bootstrap bower browserify chai chai-jquery jquery mithril mithril-query mocha mocha-phantomjs sinon; do [ -d "$(NPMBIN)/../$$x" ] || npm install $$x --save-dev; done
# This uses --debug to enable source maps.
-build-dist:
+build: build-app build-test build-css
+build-app:
mkdir -p dist
$(NPMBIN)/browserify --debug -o dist/app.js app/app.js
+build-test:
+ mkdir -p dist
$(NPMBIN)/browserify --debug -o dist/test.js test/runner.js
+build-css:
+ mkdir -p dist
rsync -a $(NPMBIN)/../bootstrap/dist/ dist/bootstrap/
-server: build-dist
+server: build
[ -e $(NPMBIN)/harp ] || npm install harp
$(NPMBIN)/harp server --port 9000
+
+test: build-test build-css
+ $(NPMBIN)/mocha-phantomjs test.html
-require(['chai', 'test/webdriver-client'], function(chai, c) {
- var assert = chai.assert;
- describe('Dashboard page', function() {
- before(function() {
- c.init().url('http://localhost:5555');
- });
- it('has a nav', function() {
- assert(c.isVisible('nav'));
- });
+var chai = require('chai')
+, wd = require('webdriver-client')
+, c = chai;
+
+suite('Dashboard page', function() {
+ setup(function() {
+ wd.url('http://localhost:5555');
+ });
+ test('has a nav', function() {
+ c.assert(wd.isVisible('nav'));
});
});
, s = sinon;
suite('Filter', function() {
- test("changing input fires currentFilter", function() {
- var tested = new Filter.AnyText();
- var cfSpy = sinon.spy();
- var ctrl = {currentFilter: cfSpy};
- var v = tested.view(ctrl);
- s.assert.notCalled(cfSpy);
- mq(v).setValue('input', 'qux');
- s.assert.calledOnce(cfSpy);
- s.assert.calledOn(cfSpy, ctrl);
- s.assert.calledWith(cfSpy, 'any', 'ilike', '%qux%');
+ function setup(filterClass) {
+ var f = {};
+ f.tested = new filterClass({attr: 'fakeAttr'});
+ f.cfSpy = sinon.spy();
+ f.ctrl = {currentFilter: f.cfSpy};
+ f.rendered = f.tested.view(f.ctrl);
+ f.domfrag = mq(f.rendered);
+ return f;
+ }
+ suite('AnyText', function() {
+ test.skip("default is existing filter value", function() {
+ // TODO
+ });
+ test("fires currentFilter on input change", function() {
+ f = setup(Filter.AnyText);
+ // XXX: should call once to retrieve current filter value
+ // s.assert.calledWith(f.cfSpy);
+ f.domfrag.setValue('input', 'qux');
+ // Should call again to set new filter value
+ s.assert.calledWith(f.cfSpy, 'any', 'ilike', '%qux%');
+ });
+ });
+ suite('ObjectType', function() {
+ test.skip("default is existing filter value", function() {
+ // TODO
+ });
+ test("fires currentFilter on selection", function() {
+ f = setup(Filter.ObjectType);
+ f.domfrag.click('li a');
+ s.assert.calledOn(f.cfSpy, f.ctrl);
+ s.assert.calledWith(f.cfSpy, 'fakeAttr', 'is_a', 'arvados#collection');
+ });
});
});
-define(['webdriverjs'], function(webdriverjs) {
- var client = webdriverjs.remote({
- desiredCapabilities: {
- // http://code.google.com/p/selenium/wiki/DesiredCapabilities
- browserName: 'phantomjs'
- },
- // webdriverjs has a lot of output which is generally useless
- // However, if anything goes wrong, remove this to see more details
- // logLevel: 'silent'
- });
- client.init();
- return client;
+var webdriverjs = require('webdriverjs');
+
+var client = webdriverjs.remote({
+ desiredCapabilities: {
+ // http://code.google.com/p/selenium/wiki/DesiredCapabilities
+ browserName: 'phantomjs'
+ },
+ // webdriverjs has a lot of output which is generally useless
+ // However, if anything goes wrong, remove this to see more details
+ // logLevel: 'silent'
});
+client.init();
+module.exports = client;