<commit_before>module.exports = storeTest
var toValue = require('./utils/to-value')

function storeTest (test, api, server, debug) {
  test('hoodie.store', function (t) {
    t.beforeEach(function (done) {
      api.browser.url(server.info.uri).then(function () {
        done()
      })
    })

    t.afterEach(function (done) {
      api.browser.execute(function () {
        window.localStorage.clear()
      }).url('about:blank').then(function () {
        done()
      }).catch(function (error) {
        done(error)
      })
    })

    t.test('.hasLocalChanges() cleared after sign up', function (tt) {
      api.browser.executeAsync(function (done) {
        window.hoodie.store.removeAll().then(function () {
          return window.hoodie.store.hasLocalChanges()
        }).then(done, done)
      }).then(toValue).then(function (hasChanges) {
        tt.is(hasChanges, false)
      }).executeAsync(function (done) {
        window.hoodie.store.add({ foo: 'bar' }).then(function () {
          return window.hoodie.store.hasLocalChanges()
        }).then(done, done)
      }).then(toValue).then(function (hasChanges) {
        tt.is(hasChanges, true)
      })

      // sanity check
      .execute(function getUsername () {
        return window.hoodie.account.username
      }).then(toValue).then(function (username) {
        tt.is(username, null)
      }).executeAsync(function (done) {
        window.hoodie.account.signUp({
          username: 'storetest',
          password: '<PASSWORD>'
        }).then(function () {
          return window.hoodie.account.signIn({
            username: 'storetest',
            password: '<PASSWORD>'
          })
        }).then(done, done)
      }).waitUntil(function () {
        return this.execute(function storeHasNoLocalChanges (done) {
          return window.hoodie.store.hasLocalChanges() === false
        }).then(toValue)
      }, 10000, 'waiting for "hoodie.store.hasLocalChanges() === false"').then(function () {
        tt.end()
      }).catch(tt.error)
    })

    // https://github.com/hoodiehq/hoodie-client/issues/44
    t.test('.findAll() objects after signin', function (tt) {
      tt.plan(1)

      api.browser.executeAsync(function (done) {
        window.hoodie.account.signIn({
          username: 'storetest',
          password: '<PASSWORD>'
        }).then(done, done)
      }).waitUntil(function () {
        return this.executeAsync(function findsObjects (done) {
          window.hoodie.store.findAll().then(done, done)
        }).then(toValue).then(function (objects) {
          return objects.length === 1
        })
      }, 10000).then(function () {
        tt.pass('finds objects after signin')
      }).catch(tt.error)
    })

    t.end()
  })
}<commit_msg>test: remove tests for hoodie.store.hasLocalChanges()<commit_after>module.exports = storeTest
var toValue = require('./utils/to-value')

function storeTest (test, api, server, debug) {
  test('hoodie.store', function (t) {
    t.beforeEach(function (done) {
      api.browser.url(server.info.uri).then(function () {
        done()
      })
    })

    t.afterEach(function (done) {
      api.browser.executeAsync(function (done) {
        window.hoodie.account.destroy()

        .then(done, done)
      }).url('about:blank').then(function () {
        done()
      }).catch(function (error) {
        done(error)
      })
    })

    // https://github.com/hoodiehq/hoodie-client/issues/44
    t.test('.findAll() objects after signin', function (tt) {
      tt.plan(4)

      api.browser

      .executeAsync(function (done) {
        window.hoodie.store.add({ foo: 'bar' }).then(done, done)
      })

      .executeAsync(function (done) {
        window.hoodie.store.findAll().then(done, done)
      }).then(toValue)

      .then(function (docs) {
        tt.is(docs.length, 1, 'finds 1 doc after creating one')
        tt.is(docs[0].foo, 'bar', 'doc has expected properties')
      })

      .executeAsync(function (done) {
        window.hoodie.account.signUp({
          username: 'storetest',
          password: '<PASSWORD>'
        }).then(function () {
          return window.hoodie.account.signIn({
            username: 'storetest',
            password: '<PASSWORD>'
          })
        }).then(done, done)
      })

      .executeAsync(function (done) {
        window.hoodie.account.signOut().then(done, done)
      })

      .executeAsync(function (done) {
        window.hoodie.store.findAll().then(done, done)
      }).then(toValue)

      .then(function (docs) {
        tt.is(docs.length, 0, 'does not find created doc after signout')
      })

      .executeAsync(function (done) {
        window.hoodie.account.signIn({
          username: 'storetest',
          password: '<PASSWORD>'
        }).then(done, done)
      })

      .waitUntil(function () {
        return this.executeAsync(function findsObjects (done) {
          window.hoodie.store.findAll().then(done, done)
        }).then(toValue).then(function (objects) {
          return objects.length === 1
        })
      }, 10000).then(function () {
        tt.pass('finds objects after signin')
      }).catch(tt.error)
    })

    t.end()
  })
}
{'fraction_non_alphanumeric': 0.159165539887966, 'fraction_numerical': 0.005215375700212479, 'mean_word_length': 2.2710044219835757, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '5663710', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1543, 'n_words': 272}