mirror of https://github.com/Oreolek/raconteur.git
Add racontest
This commit is contained in:
parent
931a8b780b
commit
f6b775bf54
|
@ -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;
|
||||
|
|
|
@ -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";
|
|
@ -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']
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
var $ = require('jquery');
|
||||
|
||||
var RACONTEST_TEMPLATE = `
|
||||
<div id="debug_interface">
|
||||
<form id="situation_hop">
|
||||
<p>
|
||||
<label for="hop_target">Go to situation</label>
|
||||
<input type="text" id="hop_target" name="hop_target" />
|
||||
</p>
|
||||
<input type="submit" id="submit_hop" name="submit_hop" />
|
||||
</form>
|
||||
</div>
|
||||
`;
|
||||
|
||||
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;
|
15
package.json
15
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
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue