<commit_before>_ = require 'lodash'
assert = (require 'chai').assert
Mount = require '../src/Mount'
{Todo, TodoList, NewTodo, TodoApp} = require './fixtures/components'

todos = [
  { title: 'Go to town' }
  { title: 'Buy some food' }
]

todos2 = [
  { title: 'foo' }
  { title: 'bar' }
  { title: 'baz' }
]

describe 'Mount', ->

  app = null

  beforeEach ->
    elem = document.createElement('div')
    document.body.appendChild(elem)

    app = new TodoApp(todos: todos)
    new Mount(app).mount(elem)

  describe '.mount', ->

    it 'mounts component on real dom and tracks updates', ->

      getTodosFromDOM = -> _.pluck(document.querySelectorAll('.todo-title'), 'innerText')

      assert.deepEqual getTodosFromDOM(), ['Go to town', 'Buy some food']

      app.todos = todos2
      app.update()

      assert.deepEqual getTodosFromDOM(), ['foo', 'bar', 'baz']

      app.todos = todos
      app.update()

      assert.deepEqual getTodosFromDOM(), ['Go to town', 'Buy some food']<commit_msg>Use # to describe method<commit_after>_ = require 'lodash'
assert = (require 'chai').assert
Mount = require '../src/Mount'
{Todo, TodoList, NewTodo, TodoApp} = require './fixtures/components'

todos = [
  { title: 'Go to town' }
  { title: 'Buy some food' }
]

todos2 = [
  { title: 'foo' }
  { title: 'bar' }
  { title: 'baz' }
]

describe 'Mount', ->

  app = null

  beforeEach ->
    elem = document.createElement('div')
    document.body.appendChild(elem)

    app = new TodoApp(todos: todos)
    new Mount(app).mount(elem)

  describe '#mount', ->

    it 'mounts component on real dom and tracks updates', ->

      getTodosFromDOM = -> _.pluck(document.querySelectorAll('.todo-title'), 'innerText')

      assert.deepEqual getTodosFromDOM(), ['Go to town', 'Buy some food']

      app.todos = todos2
      app.update()

      assert.deepEqual getTodosFromDOM(), ['foo', 'bar', 'baz']

      app.todos = todos
      app.update()

      assert.deepEqual getTodosFromDOM(), ['Go to town', 'Buy some food']
{'fraction_non_alphanumeric': 0.1607765057242409, 'fraction_numerical': 0.001991040318566451, 'mean_word_length': 3.1020408163265305, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '7281906', 'n_tokens_mistral': 719, 'n_tokens_neox': 684, 'n_words': 174}