From c050e9e45ed64cfde0bb90f00cd4a4b13374a95f Mon Sep 17 00:00:00 2001 From: jw255 Date: Sun, 22 Apr 2018 17:38:11 +0100 Subject: fixing tests --- src/FileRouter.ts | 4 +++- src/serverConfig.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/FileRouter.ts b/src/FileRouter.ts index ecd5185..7b19abd 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -171,7 +171,7 @@ const postProperties: Middleware = ( logger.debug('Editing server properties'); res.locals.modified = true; for (const newProp of req.body) { - const prop: Property | undefined = serverConfig.find( + let prop: Property | undefined = serverConfig.find( (p: Property): boolean => p.id === newProp.id ); if (prop === undefined) { @@ -183,6 +183,7 @@ const postProperties: Middleware = ( } try { prop.value = newProp.value; + } catch (err) { // FIXME: Assuming it's a value-type error, but it might not be! next(new RequestError(400, 'invalid_property_value', undefined, newProp.id)); @@ -968,6 +969,7 @@ export class FileRouter { name: projectName } }); + console.log("here") next(); } ); diff --git a/src/serverConfig.ts b/src/serverConfig.ts index 136995a..5d2575a 100644 --- a/src/serverConfig.ts +++ b/src/serverConfig.ts @@ -82,7 +82,7 @@ export class Property { } public set value(value: Value) { - if (!this.readOnly) { + if (this.readOnly) { throw new Error('this property is read-only'); } else if (!types[this.type](value)) { throw new Error(`value ${value} is not of type ${this.type}`); -- cgit v1.2.1