<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License") you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
import {
  collectStatPerf,
  tagFirstScreen,
  tagImg,  
  tagBeforeCreate,
  tagRootMounted,
  tagMounted,
  tagBeforeUpdate,
  tagUpdated,
  tagBegin,
  tagEnd
} from '../../../../render/vue/utils/perf'
describe('utils', function () {
  before(function(){
  })
  describe('pref', function () {
    before(function () {
      this.clock = sinon.useFakeTimers()
    })
    after(function () {
      this.clock.restore()
    })
    it('collectStatPerf', function () {
      expect(collectStatPerf).to.be.a('function')
      expect(collectStatPerf('totalTime', (new Date()).getTime())).to.be.a('undefined')
      expect(collectStatPerf()).to.be.a('undefined')
    })
    it('tagFirstScreen', function () {
      const weexEmit = sinon.stub(window.weex,'emit')
      expect(tagFirstScreen).to.be.a('function')
      tagFirstScreen()
      expect(weexEmit.withArgs('renderfinish').callCount).to.be.equal(1)
      expect(weexEmit.withArgs('firstscreenfinish').callCount).to.be.equal(0)
      window._first_screen_detected = false
      tagFirstScreen()
      expect(weexEmit.withArgs('renderfinish').callCount).to.be.equal(2)
      expect(weexEmit.withArgs('firstscreenfinish').callCount).to.be.equal(1)
      weexEmit.restore()
    })
    it('tagImg', function () {
      const weexEmit = sinon.stub(window.weex,'emit')
      tagImg()
      this.clock.tick(500)
      expect(weexEmit.withArgs('renderfinish').callCount).to.be.equal(1)
      expect(tagImg).to.be.a('function')
    })
  })
})<commit_msg>* [html5] improve utils/pref.js unit test cast coverage<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License") you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
import {
  collectStatPerf,
  tagFirstScreen,
  tagImg,
  tagBeforeCreate,
  tagRootMounted,
  tagMounted,
  tagBeforeUpdate,
  tagUpdated,
  tagBegin,
  tagEnd
} from '../../../../render/vue/utils/perf'
describe('utils', function () {
  before(function () {})
  describe('pref', function () {
    before(function () {
      this.clock = sinon.useFakeTimers()
    })
    after(function () {
      this.clock.restore()
    })
    it('collectStatPerf', function () {
      expect(collectStatPerf).to.be.a('function')
      expect(collectStatPerf('totalTime', (new Date()).getTime())).to.be.a('undefined')
      expect(collectStatPerf()).to.be.a('undefined')
    })
    it('tagFirstScreen', function () {
      const weexEmit = sinon.stub(window.weex, 'emit')
      expect(tagFirstScreen).to.be.a('function')
      tagFirstScreen()
      expect(weexEmit.withArgs('renderfinish').callCount).to.be.equal(1)
      expect(weexEmit.withArgs('firstscreenfinish').callCount).to.be.equal(0)
      window._first_screen_detected = false
      tagFirstScreen()
      expect(weexEmit.withArgs('renderfinish').callCount).to.be.equal(2)
      expect(weexEmit.withArgs('firstscreenfinish').callCount).to.be.equal(1)
      weexEmit.restore()
    })
    it('tagImg', function () {
      const weexEmit = sinon.stub(window.weex, 'emit')
      tagImg()
      this.clock.tick(500)
      expect(weexEmit.withArgs('renderfinish').callCount).to.be.equal(1)
      expect(tagImg).to.be.a('function')
      weexEmit.restore()
    })
    it('tagBeforeCreate', function () {
      const shouldBe = tagBeforeCreate()
      this.clock.tick(25)
      expect(shouldBe).to.be.a('undefined')
      expect(tagBeforeCreate).to.be.a('function')
    })
    it('tagRootMounted', function () {
      expect(tagRootMounted()).to.be.a('undefined')
      expect(tagRootMounted).to.be.a('function')
    })
    it('tagMounted', function () {
      const tagmount = tagMounted()
      this.clock.tick(25)
      expect(tagMounted).to.be.a('function')
      expect(tagmount).to.be.a('undefined')
    })
    it('tagBeforeUpdate', function () {
      const tagbeforeupdate = tagBeforeUpdate()
      this.clock.tick(25)
      expect(tagBeforeUpdate).to.be.a('function')
      expect(tagbeforeupdate).to.be.a('undefined')
    })
    it('tagUpdated', function () {
      const tagupdated = tagUpdated()
      this.clock.tick(25)
      expect(tagUpdated).to.be.a('function')
      expect(tagupdated).to.be.a('undefined')
    })
    it('tagBegin', function () {
      const tagbegin = tagBegin()
      expect(tagbegin).to.be.a('undefined')
      expect(tagBegin).to.be.a('function')
    })
    it('tagEnd', function () {
      const tagend = tagEnd()
      expect(tagend).to.be.a('undefined')
      expect(tagEnd).to.be.a('function')
    })
  })
})
{'fraction_non_alphanumeric': 0.14080507766828126, 'fraction_numerical': 0.005511942542174712, 'mean_word_length': 3.402941176470588, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3205158', 'n_tokens_mistral': 1822, 'n_tokens_neox': 1834, 'n_words': 394}