Skip to content

Commit ced7730

Browse files
committed
test: check Mongoose Discriminators proper behavior
related #78
1 parent d5d5fdb commit ced7730

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* @flow */
2+
3+
import mongoose from 'mongoose';
4+
import { composeWithMongoose } from '../index';
5+
6+
describe('github issues checks', () => {
7+
it('#78 Mongoose and Discriminators', () => {
8+
const options = { discriminatorKey: 'kind' };
9+
10+
const eventSchema = new mongoose.Schema({ time: Date }, options);
11+
const Event = mongoose.model('GenericEvent', eventSchema);
12+
13+
const clickedLinkSchema = new mongoose.Schema({ url: String }, options);
14+
const ClickedLinkEvent = Event.discriminator('ClickedLinkEvent', clickedLinkSchema);
15+
16+
const EventTC = composeWithMongoose(Event);
17+
const ClickedLinkEventTC = composeWithMongoose(ClickedLinkEvent);
18+
19+
expect(EventTC.getFieldNames()).toEqual(['time', '_id', 'kind']);
20+
expect(ClickedLinkEventTC.getFieldNames()).toEqual(['url', '_id', 'time', 'kind']);
21+
});
22+
});

0 commit comments

Comments
 (0)