convert-runner.js 572 B

1234567891011121314151617181920212223
  1. // Given a Waterline criteria, convert it to a Waterline query.
  2. var assert = require('assert');
  3. var Converter = require('../../lib/query/converter');
  4. module.exports = function(test) {
  5. var criteria = test.criteria;
  6. var joins = test.joins;
  7. var query = test.query;
  8. if (!criteria || !query) {
  9. throw new Error('Missing test case.');
  10. }
  11. var result = Converter({
  12. model: criteria.model,
  13. method: criteria.method,
  14. criteria: criteria.criteria || {},
  15. joins: joins || [],
  16. values: criteria.values || {}
  17. });
  18. assert.deepEqual(result, query);
  19. };