diff --git a/devel/js/main.js b/devel/js/main.js
index 3b99d3c..3b1ee5c 100644
--- a/devel/js/main.js
+++ b/devel/js/main.js
@@ -2,7 +2,8 @@ var situation = require('raconteur/situation.js'),
$ = require('jquery'),
oneOf = require('raconteur/oneOf.js'),
elements = require('raconteur/elements.js'),
- qualities = require('raconteur/qualities.js');
+ qualities = require('raconteur/qualities.js'),
+ racontest = require('raconteur/racontest.js');
situation.exportUndum();
@@ -183,6 +184,7 @@ qualities({
});
undum.game.init = function (character, system) {
+ racontest.init(system);
character.qualities.intelligence = 10;
character.qualities.perception = 10;
character.qualities.size = 1;
diff --git a/devel/less/undum.less b/devel/less/undum.less
index f74abe4..9dcc85d 100644
--- a/devel/less/undum.less
+++ b/devel/less/undum.less
@@ -577,4 +577,19 @@ img.float_left {
.fade-in();
}
+/* Debug */
+
+#debug_interface {
+ position: fixed;
+ bottom: 0;
+ left: 0;
+ background: fade(white, 50%);
+ padding: 10px;
+ border-radius: 0 10px 0 0;
+
+ p {
+ font-size: .8rem;
+ }
+}
+
@import "undum-mobile.less";
\ No newline at end of file
diff --git a/karma.conf.js b/karma.conf.js
index 4730c33..4bb97f1 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -32,7 +32,6 @@ module.exports = function(config) {
"spec/*.js": ['browserify']
},
-
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
@@ -66,7 +65,7 @@ module.exports = function(config) {
browserify: {
debug: true,
- transform: ['babelify']
+ transform: ['browserify-shim', 'babelify']
}
diff --git a/lib/racontest.js b/lib/racontest.js
new file mode 100644
index 0000000..c214765
--- /dev/null
+++ b/lib/racontest.js
@@ -0,0 +1,29 @@
+var $ = require('jquery');
+
+var RACONTEST_TEMPLATE = `
+
+`;
+
+var init = function (system) {
+ if (location.hash !== '#debug') return;
+ $('body').append(RACONTEST_TEMPLATE)
+ $('#situation_hop').submit(function (event) {
+ event.preventDefault();
+ /*
+ While I could have a try/catch block here, it would be useless; the
+ assertionError thrown from going to a nonexistant situation can be
+ caught, but Undum breaks anyway.
+ */
+ system.doLink($('#hop_target').val())
+ });
+};
+
+module.exports.init = init;
\ No newline at end of file
diff --git a/package.json b/package.json
index 7df0409..cac6f78 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "raconteur",
- "version": "0.1.2-master",
+ "version": "0.2.2-master",
"description": "A friendly API framework for building hypertext interactive fiction with Undum",
"license": "MIT",
"author": {
@@ -22,11 +22,13 @@
"babelify": "~6.0.2",
"browser-sync": "~2.5.3",
"browserify": "~9.0.8",
+ "browserify-shim": "^3.8.5",
"gulp": "~3.8.11",
"gulp-less": "~3.0.2",
"gulp-sourcemaps": "^1.5.1",
"gulp-util": "^3.0.4",
"jasmine-core": "^2.2.0",
+ "jasmine-jquery": "^2.0.6",
"karma": "^0.12.31",
"karma-babel-preprocessor": "^5.0.1",
"karma-browserify": "^4.1.2",
@@ -39,8 +41,19 @@
},
"browserify": {
"transform": [
+ "browserify-shim",
"babelify"
]
},
+ "browser": {
+ "jasmine-jquery": "./node_modules/jasmine-jquery/lib/jasmine-jquery.js"
+ },
+ "browserify-shim": {
+ "jasmine-jquery": {
+ "depends": [
+ "jquery:jQuery"
+ ]
+ }
+ },
"private": true
}
diff --git a/spec/racontestSpec.js b/spec/racontestSpec.js
new file mode 100644
index 0000000..47d78e2
--- /dev/null
+++ b/spec/racontestSpec.js
@@ -0,0 +1,55 @@
+var
+ $ = require('jquery'),
+ racontest = require('raconteur/racontest.js');
+
+require('jasmine-jquery');
+
+describe('debug mode', function () {
+ it('should only happen if #debug is the location.hash value', function () {
+ location.hash = "#foo";
+ racontest.init();
+ expect($('#debug_interface')).not.toBeInDOM();
+ });
+});
+
+describe('racontest', function () {
+ var system;
+
+ beforeEach(function () {
+ system = {
+ doLink () {}
+ };
+
+ spyOn(system, 'doLink');
+
+ location.hash = '#debug'
+ racontest.init(system);
+ });
+
+ afterEach(function () {
+ $('body').empty();
+ });
+
+ it('inserts a #debug_interface div', function () {
+ expect($('#debug_interface')).toBeInDOM();
+ });
+
+ describe('situation hopper', function () {
+ it('inserts a form to hop from situation to situation', function () {
+ expect($('#debug_interface')).toContainElement('form#situation_hop');
+
+ });
+
+ it('attaches a handler to submitting the form', function () {
+ expect($('#situation_hop')).toHandle('submit');
+ });
+
+ it('responds to form submission with a call to doLink()', function () {
+ $('#hop_target').val('foo_situation');
+ $('#situation_hop').trigger('submit');
+ expect(system.doLink).toHaveBeenCalledWith('foo_situation');
+ });
+
+ });
+
+});
\ No newline at end of file