From 499b73ec19befdb55cbbcc1a4e824434eb7a8120 Mon Sep 17 00:00:00 2001 From: Justin Meyer Date: Mon, 21 May 2018 20:41:32 -0500 Subject: [PATCH] respond with all data in create --- store.js | 4 +--- test/store-test.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/store.js b/store.js index 18066a4..fb521f7 100644 --- a/store.js +++ b/store.js @@ -116,9 +116,7 @@ canReflect.assignMap(Store.prototype,{ req.data[idProp] = ++this.maxId; this.connection.createData( typeConvert.call(this,req.data) ).then(function(data){ - var responseData = {}; - responseData[idProp] = req.data[idProp]; - res(responseData); + res(data); }, function(err){ res(403, err); }); diff --git a/test/store-test.js b/test/store-test.js index 1f5ead7..df3e933 100644 --- a/test/store-test.js +++ b/test/store-test.js @@ -74,3 +74,40 @@ QUnit.test("anything with a schema will be converted to a queryLogic automatical }); + + +QUnit.test("createData, destroyData, updateData", function(assert){ + var store = fixture.store([ + {id: 0, name: "foo"} + ], new QueryLogic({identity: ["id"]})); + + QUnit.stop(); + store.createData({ + data: {name: "bar"} + }, function(instance){ + QUnit.deepEqual(instance, {id: 1, name: "bar"} ); + QUnit.start(); + }); + /* + .then(function(instance){ + var data = store.getList({}); + assert.deepEqual(data, { + count: 2, + data: [ + {id: 0, name: "foo"}, + {id: 1, name: "updated"} + ] + }); + return store.destroyInstance(instance); + }) + .then(function(){ + var data = store.getList({}); + assert.deepEqual(data, { + count: 1, + data: [ + {id: 0, name: "foo"} + ] + }); + QUnit.start(); + });*/ +});