Skip to content

Commit

Permalink
Add test to cover selecting single root field
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff3yan committed Feb 4, 2019
1 parent f7e9b70 commit 29ebc58
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/basic.test.js
Expand Up @@ -48,17 +48,30 @@ describe('basic filters', function () {
result[0].firstName.should.equal('F01');
});

it('should select limited fields', async () => {
const result = await buildFilter(Person)
it('should select single field using alias', async () => {
const query = buildFilter(Person)
.build({
limit: 1,
fields: ['id']
});
query.toSql().replace(/"|`/g, '').should.equal('select Person.id as id from Person limit 1');
const result = await query;
result.should.be.an.an('array');
result.should.have.length(1);
_.keys(result[0]).should.deep.equal(['id']);
});

it('should select limited fields', async () => {
const result = await buildFilter(Person)
.build({
limit: 1,
fields: ['id', 'firstName']
});
result.should.be.an.an('array');
result.should.have.length(1);
_.keys(result[0]).should.deep.equal(['id', 'firstName']);
});

it('should order by descending', async () => {
const result = await buildFilter(Person)
.build({
Expand Down

0 comments on commit 29ebc58

Please sign in to comment.