Use Prettier JS (#5017)

* Adds prettier

* Run lint before tests
This commit is contained in:
Florent Vilmart
2018-09-01 13:58:06 -04:00
committed by GitHub
parent 189cd259ee
commit d83a0b6808
240 changed files with 41098 additions and 29020 deletions

View File

@@ -1,31 +1,36 @@
const AggregateRouter = require('../lib/Routers/AggregateRouter').AggregateRouter;
const AggregateRouter = require('../lib/Routers/AggregateRouter')
.AggregateRouter;
describe('AggregateRouter', () => {
it('get pipeline from Array', () => {
const body = [{
group: { objectId: {} }
}];
const expected = [ { $group: { _id: {} } } ];
const body = [
{
group: { objectId: {} },
},
];
const expected = [{ $group: { _id: {} } }];
const result = AggregateRouter.getPipeline(body);
expect(result).toEqual(expected);
});
it('get pipeline from Object', () => {
const body = {
group: { objectId: {} }
group: { objectId: {} },
};
const expected = [ { $group: { _id: {} } } ];
const expected = [{ $group: { _id: {} } }];
const result = AggregateRouter.getPipeline(body);
expect(result).toEqual(expected);
});
it('get pipeline from Pipeline Operator (Array)', () => {
const body = {
pipeline: [{
group: { objectId: {} }
}]
pipeline: [
{
group: { objectId: {} },
},
],
};
const expected = [ { $group: { _id: {} } } ];
const expected = [{ $group: { _id: {} } }];
const result = AggregateRouter.getPipeline(body);
expect(result).toEqual(expected);
});
@@ -33,37 +38,45 @@ describe('AggregateRouter', () => {
it('get pipeline from Pipeline Operator (Object)', () => {
const body = {
pipeline: {
group: { objectId: {} }
}
group: { objectId: {} },
},
};
const expected = [ { $group: { _id: {} } } ];
const expected = [{ $group: { _id: {} } }];
const result = AggregateRouter.getPipeline(body);
expect(result).toEqual(expected);
});
it('get pipeline fails multiple keys in Array stage ', () => {
const body = [{
group: { objectId: {} },
match: { name: 'Test' },
}];
const body = [
{
group: { objectId: {} },
match: { name: 'Test' },
},
];
try {
AggregateRouter.getPipeline(body);
} catch (e) {
expect(e.message).toBe('Pipeline stages should only have one key found group, match');
expect(e.message).toBe(
'Pipeline stages should only have one key found group, match'
);
}
});
it('get pipeline fails multiple keys in Pipeline Operator Array stage ', () => {
const body = {
pipeline: [{
group: { objectId: {} },
match: { name: 'Test' },
}]
pipeline: [
{
group: { objectId: {} },
match: { name: 'Test' },
},
],
};
try {
AggregateRouter.getPipeline(body);
} catch (e) {
expect(e.message).toBe('Pipeline stages should only have one key found group, match');
expect(e.message).toBe(
'Pipeline stages should only have one key found group, match'
);
}
});
});