<commit_before>import trigger from 'trigger-event';
import Emitter from 'component-emitter';
import raf from 'component-raf';
import assert from 'assert';
import {component,scene,dom,render} from '../../';
import {HelloWorld,Span,TwoWords,mount,div} from '../helpers';

it('should render a component', function(){
  var Test = component(HelloWorld)
  var app = scene(Test)
  mount(app, function(el){
    assert.equal(el.innerHTML, '<span>Hello World</span>')
  })
})

it('should have initial state', function(){
  var DefaultState = component({
    initialState: function(){
      return {
        text: '<NAME>'
      };
    },
    render: function(props, state){
      return dom('span', null, state.text);
    }
  });
  var app = scene(DefaultState)
  mount(app, function(el, renderer){
    assert.equal(el.innerHTML, '<span>Hello World</span>')
  })
})

it('should create a component with properties', function(){
  var Test = component({
    render(props) {
      return dom('span', null, [props.text])
    }
  })
  var app = scene(Test)
  app.setProps({ text: 'Hello World' })
  mount(app, function(el){
    assert.equal(el.innerHTML, '<span>Hello World</span>')
  })
})

it('should remove from the DOM', function () {
  var Test = component(HelloWorld);
  var el = mount(scene(Test));
  assert.equal(el.innerHTML, '');
})

it('should compose components', function(){
  var Inner = component(HelloWorld);
  var Composed = component({
    render: function(props, state){
      return dom(Inner);
    }
  });
  mount(scene(Composed), function(el){
    assert.equal(el.innerHTML, '<span>Hello World</span>');<commit_msg>dom: Tests for scene removal<commit_after>import trigger from 'trigger-event';
import Emitter from 'component-emitter';
import raf from 'component-raf';
import assert from 'assert';
import {component,scene,dom,render} from '../../';
import {HelloWorld,Span,TwoWords,mount,div} from '../helpers';

it('should render a component', function(){
  var Test = component(HelloWorld)
  var app = scene(Test)
  mount(app, function(el){
    assert.equal(el.innerHTML, '<span>Hello World</span>')
  })
})

it('should have initial state', function(){
  var DefaultState = component({
    initialState: function(){
      return {
        text: '<NAME>'
      };
    },
    render: function(props, state){
      return dom('span', null, state.text);
    }
  });
  var app = scene(DefaultState)
  mount(app, function(el, renderer){
    assert.equal(el.innerHTML, '<span>Hello World</span>')
  })
})

it('should create a component with properties', function(){
  var Test = component({
    render(props) {
      return dom('span', null, [props.text])
    }
  })
  var app = scene(Test)
  app.setProps({ text: '<NAME>' })
  mount(app, function(el){
    assert.equal(el.innerHTML, '<span>Hello World</span>')
  })
})

it('should remove from the DOM', function () {
  var Test = component(HelloWorld);
  var container = div();
  var renderer = render(scene(Test), container);
  renderer.remove();
  assert.equal(container.innerHTML, '')
  assert.deepEqual(renderer.entities, {})
  assert.deepEqual(renderer.elements, {})
  assert.deepEqual(renderer.children, {})
})

it('should compose components', function(){
  var Inner = component(HelloWorld);
  var Composed = component({
    render: function(props, state){
      return dom(Inner);
    }
  });
  mount(scene(Composed), function(el){
    assert.equal(el.innerHTML, '<span>Hello World</span>');
{'fraction_non_alphanumeric': 0.16801853997682503, 'fraction_numerical': 0.0, 'mean_word_length': 4.085419734904271, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, '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': '1730342', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1055, 'n_words': 266}