-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* validate where statement * add link to issue
- Loading branch information
1 parent
58e5794
commit 388bf26
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {DataModelFilterParser} from '../data-model-filter.parser'; | ||
import {TestApplication} from './TestApplication'; | ||
import {DataContext} from '../types'; | ||
import {resolve} from 'path'; | ||
|
||
describe('DataQueryable', () => { | ||
|
||
let app: TestApplication; | ||
let context: DataContext; | ||
beforeAll((done) => { | ||
app = new TestApplication(resolve(__dirname, 'test2')); | ||
context = app.createContext(); | ||
return done(); | ||
}); | ||
afterAll(async () => { | ||
await context.finalizeAsync(); | ||
await app.finalize(); | ||
}); | ||
|
||
/** | ||
* @see https://github.com/themost-framework/data/issues/161 | ||
*/ | ||
it('should validate where statement', async () => { | ||
const Orders = context.model('Order').silent(); | ||
const items = await Orders.where('orderStatus/alternateName').equal('OrderDelivered') | ||
.orderByDescending('orderDate').take(10).getItems(); | ||
expect(items).toBeTruthy(); | ||
expect(items.length).toBeGreaterThan(0); | ||
}); | ||
|
||
/** | ||
* @see https://github.com/themost-framework/data/issues/161 | ||
*/ | ||
it('should validate where statement with error', async () => { | ||
const Orders = context.model('Order').silent(); | ||
const q = Orders.where('orderStatus/alternateName').equal('OrderDelivered') | ||
.orderByDescending('orderDate').take(10); | ||
expect(() => q.where('orderedItem/category').equal('Laptops')).toThrow('The where expression has already been initialized.'); | ||
}); | ||
|
||
/** | ||
* @see https://github.com/themost-framework/data/issues/161 | ||
*/ | ||
it('should validate where statement after prepare', async () => { | ||
const Orders = context.model('Order').silent(); | ||
const q = Orders.where('orderStatus/alternateName').equal('OrderDelivered') | ||
.orderByDescending('orderDate').take(10); | ||
expect(() => q.prepare().where('orderedItem/category').equal('Laptops')).toBeTruthy(); | ||
}); | ||
|
||
}); |