<commit_before>import assert from 'power-assert'
import Vue from 'vue'


describe('asset', () => {
  const DELAY = 10

  describe('sync', () => {
    it('should be translated', () => {
      Vue.locale('en', {
        message: {
          foo: 'foo'
        }
      })
      assert(Vue.t('message.foo') === 'foo')
    })
  })


  describe('async', () => {
    describe('promise like function', () => {
      beforeEach((done) => {
        Vue.locale('en', () => {
          return (resolve, reject) => {
            setTimeout(() => {
              resolve({ message: { bar: 'bar' } })
            }, DELAY)
          }
        })
        Vue.nextTick(done)
      })

      it('should be translated', (done) => {
        setTimeout(() => {
          assert(Vue.t('message.bar') === 'bar')
          done()
        }, DELAY + 5)
      })
    })

    describe('promise ', () => {
      beforeEach((done) => {
        Vue.locale('en', () => {
          return new Promise((resolve, reject) => {
            setTimeout(() => {
              resolve({ message: { buz: 'buz' } })
            }, DELAY)
          })
        })
        Vue.nextTick(done)
      })

      it('should be translated', (done) => {
        setTimeout(() => {
          assert(Vue.t('message.buz') === 'buz')
          done()
        }, DELAY + 5)
      })
    })
  })
})<commit_msg>test(asset): add more tests :white_check_mark:<commit_after>import assert from 'power-assert'
import Vue from 'vue'


describe('asset', () => {
  let locale
  const DELAY = 10

  beforeEach(() => {
    Vue.locale('en', null) // reset
  })

  describe('register sync', () => {
    it('should be registed', () => {
      let locale = {
        message: {
          foo: 'foo'
        }
      }
      Vue.locale('en', locale)
      assert(Vue.locale('en') === locale)
    })
  })


  describe('regsiter async', () => {
    describe('promise like function', () => {
      describe('resolve', () => {
        beforeEach((done) => {
          locale = { message: { bar: 'bar' } }
          Vue.locale('en', () => {
            return (resolve, reject) => {
              setTimeout(() => {
                resolve(locale)
              }, DELAY)
            }
          })
          Vue.nextTick(done)
        })

        it('should be registered', (done) => {
          setTimeout(() => {
            assert(Vue.locale('en') === locale)
            done()
          }, DELAY + 5)
        })
      })

      describe('reject', () => {
        beforeEach((done) => {
          Vue.locale('en', () => {
            return (resolve, reject) => {
              setTimeout(() => {
                reject()
              }, DELAY)
            }
          })
          Vue.nextTick(done)
        })

        it('should not be registered', (done) => {
          setTimeout(() => {
            assert(!Vue.locale('en'))
            done()
          }, DELAY + 5)
        })
      })
    })

    describe('promise ', () => {
      describe('resolve', () => {
        beforeEach((done) => {
          locale = { mesasge: { buz: 'buz' } }
          Vue.locale('en', () => {
            return new Promise((resolve, reject) => {
              setTimeout(() => {
                resolve(locale)
              }, DELAY)
            })
          })
          Vue.nextTick(done)
        })

        it('should be translated', (done) => {
          setTimeout(() => {
            assert(Vue.locale('en') === locale)
            done()
          }, DELAY + 5)
        })
      })

      describe('reject', () => {
        beforeEach((done) => {
          Vue.locale('en', () => {
            return new Promise((resolve, reject) => {
              setTimeout(() => {
                reject()
              }, DELAY)
            })
          })
          Vue.nextTick(done)
        })

        it('should be translated', (done) => {
          setTimeout(() => {
            assert(!Vue.locale('en'))
            done()
          }, DELAY + 5)
        })
      })
    })
  })
})
{'fraction_non_alphanumeric': 0.18810891831126655, 'fraction_numerical': 0.002498126405196103, 'mean_word_length': 1.3608490566037736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 56, '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': '5859020', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1167, 'n_words': 203}