<commit_before>describe 'Custom Element Base', ->
  registerCustomElement = require('../base.min.js')
  {getCustomElement} = require('./helper')

  it 'fires the events in order', ->
    lastRan = null
    element = new (registerCustomElement(getCustomElement({
      name: 'x-spec-event-order'
      created: -> lastRan = 'created'
      initialize: -> lastRan = 'initialize'
      attached: ->
        expect(lastRan).toBe('initialize')
        lastRan = 'attached'
      detached: -> lastRan = 'detached'
      attributeChanged: -> lastRan = 'attributeChanged'
    })))
    expect(lastRan).toBe('created')
    element.setAttribute('a-b', 'c')
    expect(lastRan).toBe('attributeChanged')
    document.body.appendChild(element)
    expect(lastRan).toBe('attached')
    element.remove()
    expect(lastRan).toBe('detached')

  it 'lowercases config keys', ->
    element = new (registerCustomElement(getCustomElement({
      name: 'x-spec-lowercase-config-keys',
      config: {Wow: {type: Boolean, default: false}}
    })))
    expect(element.Wow).toBeUndefined()
    expect(element.wow).toBe(false)

  it 'does not fire attributeChanged on config change', ->
    executed = false
    element = new (registerCustomElement(getCustomElement({
      name: 'x-spec-attributechanged-fired'
      attributeChanged: -> executed = true
      config: {asd: {type: Boolean, default: false}}
    })))
    element.setAttribute('asd', false)<commit_msg>:new: Add a spec about returning null for non-specified keys<commit_after>describe 'Custom Element Base', ->
  registerCustomElement = require('../base.min.js')
  {getCustomElement} = require('./helper')

  it 'fires the events in order', ->
    lastRan = null
    element = new (registerCustomElement(getCustomElement({
      name: 'x-spec-event-order'
      created: -> lastRan = 'created'
      initialize: -> lastRan = 'initialize'
      attached: ->
        expect(lastRan).toBe('initialize')
        lastRan = 'attached'
      detached: -> lastRan = 'detached'
      attributeChanged: -> lastRan = 'attributeChanged'
    })))
    expect(lastRan).toBe('created')
    element.setAttribute('a-b', 'c')
    expect(lastRan).toBe('attributeChanged')
    document.body.appendChild(element)
    expect(lastRan).toBe('attached')
    element.remove()
    expect(lastRan).toBe('detached')

  it 'lowercases config keys', ->
    element = new (registerCustomElement(getCustomElement({
      name: 'x-spec-lowercase-config-keys',
      config: {Wow: {type: Boolean, default: false}}
    })))
    expect(element.Wow).toBeUndefined()
    expect(element.wow).toBe(false)

  it 'returns null for non-specified config keys', ->
    element = new (registerCustomElement(getCustomElement({
      name: 'x-spec-return-null-nonspecified-keys'
      config: {wow: {type: Boolean}}
    })))
    expect(element.wow).toBe(null)

  it 'does not fire attributeChanged on config change', ->
    executed = false
    element = new (registerCustomElement(getCustomElement({
      name: 'x-spec-attributechanged-fired'
      attributeChanged: -> executed = true
      config: {asd: {type: Boolean, default: false}}
    })))
    element.setAttribute('asd', false)
{'fraction_non_alphanumeric': 0.14568911264946507, 'fraction_numerical': 0.0, 'mean_word_length': 3.471167369901547, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3928706', 'n_tokens_mistral': 956, 'n_tokens_neox': 945, 'n_words': 201}