<commit_before>goog.require 'spark.core.Object'
goog.require 'spark.core.View'
goog.require 'spark.utils'


describe 'spark.core.View', ->


  view      = null
  element   = null
  isClicked = null
  isHovered = null

  fireEvent = (type) ->
    event = document.createEvent 'MouseEvents'
    event.initEvent type, yes, yes
    element.dispatchEvent event

  beforeEach ->
    isClicked       = null
    isHovered       = null
    options         =
      tagName       : 'span'
      cssClass      : 'hello buddy'
      domId         : 'world'
      template      : '<p>Hello World</p>'
      eventHandlers :
        click       : -> isClicked = yes
        mouseover   : -> isHovered = yes

    view            = new spark.core.View options
    element         = view.getElement()


  it 'should create a DOM element with passed options', ->
    expect(element).toBeDefined()
    expect(element.id).toBe 'world'
    expect(element.classList.contains('hello')).toBeTruthy()
    expect(element.firstChild.tagName).toBe 'P'


  it 'should be appendable to document body', ->
    # it will throw an error if it couldn't append it to dom
    # there is not assertion needed
    document.body.appendChild element


  it 'should bind events in eventHandlers object', ->
    expect(isClicked).toBe null
    expect(isHovered).toBe null
<commit_msg>View: Added test for options.<commit_after>goog.require 'spark.core.Object'
goog.require 'spark.core.View'
goog.require 'spark.utils'


describe 'spark.core.View', ->


  view      = null
  element   = null
  isClicked = null
  isHovered = null

  fireEvent = (type) ->
    event = document.createEvent 'MouseEvents'
    event.initEvent type, yes, yes
    element.dispatchEvent event

  beforeEach ->
    isClicked       = null
    isHovered       = null
    options         =
      tagName       : 'span'
      cssClass      : 'hello buddy'
      domId         : 'world'
      template      : '<p>Hello World</p>'
      eventHandlers :
        click       : -> isClicked = yes
        mouseover   : -> isHovered = yes

    view            = new spark.core.View options
    element         = view.getElement()


  it 'should has default options if no options passed', ->
    v = new spark.core.View
    expect(v.getOptions()).not.toBe {}


  it 'should create a DOM element with passed options', ->
    expect(element).toBeDefined()
    expect(element.id).toBe 'world'
    expect(element.classList.contains('hello')).toBeTruthy()
    expect(element.firstChild.tagName).toBe 'P'


  it 'should be appendable to document body', ->
    # it will throw an error if it couldn't append it to dom
    # there is not assertion needed
    document.body.appendChild element


  it 'should bind events in eventHandlers object', ->
    expect(isClicked).toBe null
    expect(isHovered).toBe null

{'fraction_non_alphanumeric': 0.10162889518413598, 'fraction_numerical': 0.0, 'mean_word_length': 2.3711217183770885, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 24, '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': '7534816', 'n_tokens_mistral': 858, 'n_tokens_neox': 806, 'n_words': 233}