Skip to content

Commit

Permalink
remove property name existance check from botstate
Browse files Browse the repository at this point in the history
  • Loading branch information
johnataylor committed May 24, 2019
1 parent c1ce919 commit bd792d4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
7 changes: 0 additions & 7 deletions libraries/botbuilder-core/src/botState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ export interface CachedBotState {
*/
export class BotState implements PropertyManager {

/**
* Collection of state property accessors added through [createProperty()](#createproperty).
*/
public readonly properties: Map<string, StatePropertyAccessor> = new Map();
private stateKey: symbol = Symbol('state');

/**
Expand All @@ -58,10 +54,7 @@ export class BotState implements PropertyManager {
* @param name Name of the property to add. Must be unique within the set.
*/
public createProperty<T = any>(name: string): StatePropertyAccessor<T> {
if (this.properties.has(name)) { throw new Error(`BotState.createProperty(): a property named '${ name }' already exists.`); }
const prop: BotStatePropertyAccessor<T> = new BotStatePropertyAccessor<T>(this, name);
this.properties.set(name, prop);

return prop;
}

Expand Down
15 changes: 0 additions & 15 deletions libraries/botbuilder-core/tests/botState.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,4 @@ describe(`BotState`, function () {
assert(count !== undefined, `did not successfully create PropertyAccessor.`);
done();
});

it(`should not allow registering of PropertyAccessors with the same name`, function (done) {
const duplicateName = 'test';
let testA = botState.createProperty(duplicateName, 0);
try {
let testB = botState.createProperty(duplicateName, 0);
} catch (e) {
// Checking the error message because JavaScript does not have specific Error types like Python, e.g. ValueError.
// This message check verifies that the bot threw the correct error, and that not something else is breaking.
assert(e.message === `BotState.createProperty(): a property named '${duplicateName}' already exists.`, `another error was thrown: "${e.message}".`);
done();
}
throw new Error(`Should have raised a duplicate property name error.`);
done();
});
});

0 comments on commit bd792d4

Please sign in to comment.