/* global describe, beforeEach, afterEach, it */
const knex_config = require('../../knexfile');
const knex = require('knex')(knex_config['test']);

const chai = require('chai');
const should = chai.should();

describe('Handle ads', function() {

  beforeEach(function(done) {
    knex.migrate.rollback()
      .then(function() {
        knex.migrate.latest()
          .then(function() {
            return knex.seed.run()
              .then(function() {
                done();
              });
          });
      });
  });

  afterEach(function(done) {
    knex.migrate.rollback()
      .then(function() {
        done();
      });
  });


  it('should list ads in order', (done) => {
    done();
  })
});

@@ -42,16 +42,78 @@
 , it */%0A
+%0Aconst chai = require('chai');%0Aconst should = chai.should();%0A%0A
 const kn
@@ -201,36 +201,36 @@
 test'%5D);%0A%0Aconst 
-chai
+util
  = require('chai
@@ -229,43 +229,76 @@
 re('
-chai');%0Aconst should = chai.should(
+../util')(%7B knex %7D);%0Aconst service = require('./ads')(%7B knex, util %7D
 );%0A%0A
@@ -782,23 +782,125 @@
 %3E %7B%0A    
-done();
+service.listAds(false).then((ads) =%3E %7B%0A      ads.map(ad =%3E ad.id).should.eql(%5B2, 3, 1%5D);%0A      done();%0A    %7D)
 %0A  %7D)%0A%7D)

Test that ads appear in date order latest first