|
1 |
| -// These tests check the "create" functionality of the REST API. |
| 1 | +// These tests check the "create" / "update" functionality of the REST API. |
2 | 2 | var auth = require('../src/Auth');
|
3 | 3 | var cache = require('../src/cache');
|
4 | 4 | var Config = require('../src/Config');
|
@@ -41,6 +41,38 @@ describe('rest create', () => {
|
41 | 41 | });
|
42 | 42 | });
|
43 | 43 |
|
| 44 | + it('handles object and subdocument', (done) => { |
| 45 | + var obj = { |
| 46 | + subdoc: {foo: 'bar', wu: 'tan'}, |
| 47 | + }; |
| 48 | + rest.create(config, auth.nobody(config), 'MyClass', obj).then(() => { |
| 49 | + return database.mongoFind('MyClass', {}, {}); |
| 50 | + }).then((results) => { |
| 51 | + expect(results.length).toEqual(1); |
| 52 | + var mob = results[0]; |
| 53 | + expect(typeof mob.subdoc).toBe('object'); |
| 54 | + expect(mob.subdoc.foo).toBe('bar'); |
| 55 | + expect(mob.subdoc.wu).toBe('tan'); |
| 56 | + expect(typeof mob._id).toEqual('string'); |
| 57 | + |
| 58 | + var obj = { |
| 59 | + 'subdoc.wu': 'clan', |
| 60 | + }; |
| 61 | + |
| 62 | + rest.update(config, auth.nobody(config), 'MyClass', mob._id, obj).then(() => { |
| 63 | + return database.mongoFind('MyClass', {}, {}); |
| 64 | + }).then((results) => { |
| 65 | + expect(results.length).toEqual(1); |
| 66 | + var mob = results[0]; |
| 67 | + expect(typeof mob.subdoc).toBe('object'); |
| 68 | + expect(mob.subdoc.foo).toBe('bar'); |
| 69 | + expect(mob.subdoc.wu).toBe('clan'); |
| 70 | + done(); |
| 71 | + }); |
| 72 | + |
| 73 | + }); |
| 74 | + }); |
| 75 | + |
44 | 76 | it('handles user signup', (done) => {
|
45 | 77 | var user = {
|
46 | 78 | username: 'asdf',
|
|
0 commit comments