Comparing version 0.0.6 to 0.0.7
@@ -110,3 +110,7 @@ 'use strict' | ||
remember: (item, value) => state.set(item, value), | ||
recall: item => state.get(item), | ||
recall: item => { | ||
if (!state.has(item)) | ||
throw new Error(`I do not remember anything about '${item}', sorry`) | ||
return state.get(item) | ||
} | ||
} | ||
@@ -113,0 +117,0 @@ }, |
@@ -304,6 +304,7 @@ 'use strict' | ||
describe('Memory', () => { | ||
const perspective = Perspective('test', handle => | ||
Memory.addToPerspective(handle) | ||
) | ||
it('allows an actor to remember state', async () => { | ||
const perspective = Perspective('test', handle => | ||
Memory.addToPerspective(handle) | ||
) | ||
const joe = Actor(perspective, { ...Memory.abilities() }) | ||
@@ -313,3 +314,15 @@ await joe.attemptsTo(Remember('thing').is('something')) | ||
}) | ||
it('throws when asked for something it can\'t remember', async () => { | ||
const joe = Actor(perspective, { ...Memory.abilities() }) | ||
let err | ||
try { | ||
await joe.asks(Memory.about('something unknown')) | ||
} catch (e) { | ||
err = e | ||
} | ||
assert(err, 'Expected it to throw') | ||
assert(err.message.match(/something unknown/), 'The error message doesn\'t look right') | ||
}) | ||
}) | ||
}) |
{ | ||
"name": "feynman", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A screenplay pattern library for javascript", | ||
@@ -5,0 +5,0 @@ "main": "lib/feynman.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32298132
418