<commit_before>import Ember from 'ember';
import { configurations, cleanup, wait } from '../helpers/setup';

const {
  RSVP: { all }
} = Ember;

configurations(({ module, test, createDatabase, config }) => {

  let db;

  function flush() {
    db = createDatabase();
  }

  module('database-changes-view', () => {
    flush();
    /* global emit */
    return cleanup(db).then(() => {
      return db.get('design').save('changes', {
        views: {
          'only-things': {
            map(doc) {
              if(doc.type !== 'thing') {
                return;
              }
              emit(doc._id, null);
            }
          }
        }
      });
    });
  });

  test('listen for changes', assert => {
    let changes = db.changes({ feed: config.feed, view: 'changes/only-things' });
    let data = [];
    changes.on('data', doc => {
      data.push(doc);
    });
    changes.start();
    return wait(null, 1000).then(() => {
      return all([
        db.save({ _id: 'foo', type: 'thing' }),
        db.save({ _id: 'bar', type: 'duck' })
      ]);
    }).then(([ foo ]) => {
      return db.save({ _id: 'foo', _rev: foo.rev, _deleted: true, type: 'thing' });
    }).then(() => {
      return wait(null, 1000);
    }).then(() => {
      assert.deepEqual_(data.map(row => row.doc), [
        {
          "_id": "foo",
          "_rev": "ignored",
          "type": "thing"
        },
        {
          "_deleted": true,
          "_id": "foo",
          "_rev": "ignored",
          "type": "thing"
        }
      ]);
    });
  });

});
<commit_msg>increase delay for changes unittest<commit_after>import Ember from 'ember';
import { configurations, cleanup, wait } from '../helpers/setup';

const {
  RSVP: { all }
} = Ember;

configurations(({ module, test, createDatabase, config }) => {

  let db;

  function flush() {
    db = createDatabase();
  }

  module('database-changes-view', () => {
    flush();
    /* global emit */
    return cleanup(db).then(() => {
      return db.get('design').save('changes', {
        views: {
          'only-things': {
            map(doc) {
              if(doc.type !== 'thing') {
                return;
              }
              emit(doc._id, null);
            }
          }
        }
      });
    });
  });

  test('listen for changes', assert => {
    let changes = db.changes({ feed: config.feed, view: 'changes/only-things' });
    let data = [];
    changes.on('data', doc => {
      data.push(doc);
    });
    changes.start();
    return wait(null, 1500).then(() => {
      return all([
        db.save({ _id: 'foo', type: 'thing' }),
        db.save({ _id: 'bar', type: 'duck' })
      ]);
    }).then(([ foo ]) => {
      return db.save({ _id: 'foo', _rev: foo.rev, _deleted: true, type: 'thing' });
    }).then(() => {
      return wait(null, 1500);
    }).then(() => {
      assert.deepEqual_(data.map(row => row.doc), [
        {
          "_id": "foo",
          "_rev": "ignored",
          "type": "thing"
        },
        {
          "_deleted": true,
          "_id": "foo",
          "_rev": "ignored",
          "type": "thing"
        }
      ]);
    });
  });

});

{'fraction_non_alphanumeric': 0.20316455696202532, 'fraction_numerical': 0.005063291139240506, 'mean_word_length': 1.732065687121867, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3004080', 'n_tokens_mistral': 1028, 'n_tokens_neox': 1002, 'n_words': 216}