import test from 'ava';
import ResourceArray from '../src/ResourceArray';
import applyHooks from './helpers/applyHooks';
import { model } from '../src';

applyHooks(test);

test('should find all users', async t => {
  try {
    const users = await model('user').find();

    t.truthy(users instanceof ResourceArray);
    t.is(users.size(), 2);
    t.is(users.first().id, '1');
    t.is(users.last().id, '2');
  } catch (err) {
    t.fail(err);
  }
});

test('should find users with options', async t => {
  try {
    const users = await model('user').find({
      filter: { name: 'Bob' },
      include: { company: true, friends: true },
    });

    t.truthy(users instanceof ResourceArray);
    t.is(users.first().relationship('friends').records[0].name, 'Billy');
    t.is(users.first().relationship('company').record.name, 'Apple');
    t.is(users.size(), 1);
  } catch (err) {
    t.fail(err);
  }
});

@@ -1,12 +1,39 @@
+import r from 'rethinkdb';%0A
 import test 
@@ -907,28 +907,682 @@
  %7B%0A    t.fail(err);%0A  %7D%0A%7D);%0A
+%0Atest('should find users with native RethinkDB functions (1)', async t =%3E %7B%0A  try %7B%0A    const users = await model('user').find(%7B%0A      filter: (user) =%3E user('name').eq('Bob').or(user('name').eq('Billy')),%0A    %7D);%0A%0A    t.truthy(users instanceof ResourceArray);%0A    t.is(users.size(), 2);%0A  %7D catch (err) %7B%0A    t.fail(err);%0A  %7D%0A%7D);%0A%0Atest('should find users with native RethinkDB functions (2)', async t =%3E %7B%0A  try %7B%0A    const users = await model('user').find(%7B%0A      filter: r.row('name').eq('Bob').or(r.row('name').eq('Billy')),%0A    %7D);%0A%0A    t.truthy(users instanceof ResourceArray);%0A    t.is(users.size(), 2);%0A  %7D catch (err) %7B%0A    t.fail(err);%0A  %7D%0A%7D);%0A

Add a couple more `find` tests