Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
samgladstone committed Jan 30, 2020
1 parent 834200d commit 2389ea4
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions test/schema.singlenestedpath.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ describe('SingleNestedPath', function() {
}, {_id: false});

subEventSchema.path('sub_events').discriminator('SubEvent', subEventSchema);

let currentEventLevel = subEventSchema;
for (let i = 0; i < 5; i++) {
const subEventSchemaDiscriminators = currentEventLevel.path('sub_events').schema.discriminators;
assert.ok(subEventSchemaDiscriminators);
assert.ok(subEventSchemaDiscriminators.SubEvent)
assert.ok(subEventSchemaDiscriminators.SubEvent);
currentEventLevel = subEventSchemaDiscriminators.SubEvent;
}
});
Expand All @@ -49,26 +49,26 @@ describe('SingleNestedPath', function() {
// To create a recursive document, the schema was modified, so kind & message are added
kind: 'SubEvent',
message: 'level 1',
sub_events: [{
kind: 'SubEvent',
sub_events: [{
kind: 'SubEvent',
message: 'level 2',
sub_events: [{
sub_events: [{
kind: 'SubEvent',
message: 'level 3',
sub_events: [{
kind: 'SubEvent',
sub_events: [{
kind: 'SubEvent',
message: 'level 4',
sub_events: [{
kind: 'SubEvent',
sub_events: [{
kind: 'SubEvent',
message: 'level 5',
sub_events: [],
}],
sub_events: [],
}],
}],
}],
}]
};
const subEvent = SubEvent(multiLevel);

assert.deepStrictEqual(multiLevel, subEvent.toJSON());
});

Expand All @@ -77,21 +77,21 @@ describe('SingleNestedPath', function() {
_id: { type: Number, required: true },
message: String,
}, { discriminatorKey: 'kind' });

const subEventSchema = new Schema({
sub_events: [singleEventSchema]
});

subEventSchema.path('sub_events').discriminator('SubEvent', subEventSchema);

// To create a recursive document, the schema was modified, so the _id property is now a number
assert.equal(subEventSchema.path('_id').instance, 'Number');

let currentEventLevel = subEventSchema;
for (let i = 0; i < 5; i++) {
const subEventSchemaDiscriminators = currentEventLevel.path('sub_events').schema.discriminators;
assert.ok(subEventSchemaDiscriminators);
assert.ok(subEventSchemaDiscriminators.SubEvent)
assert.ok(subEventSchemaDiscriminators.SubEvent);
currentEventLevel = subEventSchemaDiscriminators.SubEvent;
assert.equal(currentEventLevel.path('_id').instance, 'Number');
}
Expand All @@ -102,13 +102,13 @@ describe('SingleNestedPath', function() {
_id: { type: Number, required: true },
message: String,
}, { discriminatorKey: 'kind' });

const subEventSchema = new Schema({
sub_events: [singleEventSchema]
});

subEventSchema.path('sub_events').discriminator('SubEvent', subEventSchema);

const SubEvent = mongoose.model('MultiLevelDataWithIdDoc', subEventSchema);
const multiLevel = {
// To create a recursive document, the schema was modified, so kind & message are added & _id is now Number
Expand All @@ -117,22 +117,22 @@ describe('SingleNestedPath', function() {
message: 'level 1',
sub_events: [{
_id: 1,
kind: 'SubEvent',
kind: 'SubEvent',
message: 'level 2',
sub_events: [{
sub_events: [{
_id: 1,
kind: 'SubEvent',
message: 'level 3',
sub_events: [{
sub_events: [{
_id: 1,
kind: 'SubEvent',
kind: 'SubEvent',
message: 'level 4',
sub_events: [{
sub_events: [{
_id: 1,
kind: 'SubEvent',
kind: 'SubEvent',
message: 'level 5',
sub_events: [],
}],
sub_events: [],
}],
}],
}],
}]
Expand All @@ -141,6 +141,6 @@ describe('SingleNestedPath', function() {

assert.deepStrictEqual(multiLevel, subEvent.toJSON());
});
})
});
});
});

0 comments on commit 2389ea4

Please sign in to comment.