<commit_before>/**
 * @file Vdom module - test
 * @author StefanoMagrassi <<EMAIL>>
 */

// Imports
// -------
import test from 'tape';
import imageHelper from './helpers/image';
import virtualdom from '../../lib/virtualdom';
import {CONTAINER_CLASS} from '../../lib/virtualdom';

// Tests
// -----
test('virtualdom.render() renders a puzzle-pieces tree', function(t) {
  t.plan(3);

  imageHelper('vdom1', function() {
    let image = this;
    let data  = {
      image: image,
      rows: 2,
      cols: 2,
      pairs: [
        [{row:0, col:0, width:100, height:100, x:0, y:0},{position:0, bgX:0, bgY:0}],
        [{row:0, col:1, width:100, height:100, x:100, y:0},{position:1, bgX:-100, bgY:0}],
        [{row:1, col:0, width:100, height:100, x:0, y:-100},{position:2, bgX:0, bgY:-100}],
        [{row:1, col:1, width:100, height:100, x:-100, y:-100},{position:3, bgX:-100, bgY:-100}]
      ]
    };
    let vdom     = virtualdom();
    let rendered = vdom.render(data);

    let actual = rendered.tagName.toLowerCase();
    let expect = 'div';
    t.equal(actual, expect, 'tagName should be "div"');

    actual = rendered.properties.className;
    expect = CONTAINER_CLASS.substring(1);
    t.equal(actual, expect, 'className should be equal to CONTAINER_CLASS const');

    actual = rendered.children.length;
    expect = data.rows * data.cols;
    t.equal(actual, expect, 'number of pieces should be rows * columns');
  });

  t.timeoutAfter(10 * 1000);
});<commit_msg>tests -> virtualdom<commit_after>/**
 * @file Vdom module - test
 * @author StefanoMagrassi <<EMAIL>>
 */

// Imports
// -------
import test from 'tape';
import imageHelper from './helpers/image';
import virtualdom from '../../lib/virtualdom';
import {CONTAINER_CLASS} from '../../lib/virtualdom';

// Tests
// -----
test('Lib: virtualdom', t => {
  imageHelper('vdom1', function() {
    const image = this;
    const data  = {
      image: image,
      rows: 2,
      cols: 2,
      pairs: [
        [{row:0, col:0, width:100, height:100, x:0, y:0},{position:0, bgX:0, bgY:0}],
        [{row:0, col:1, width:100, height:100, x:100, y:0},{position:1, bgX:-100, bgY:0}],
        [{row:1, col:0, width:100, height:100, x:0, y:-100},{position:2, bgX:0, bgY:-100}],
        [{row:1, col:1, width:100, height:100, x:-100, y:-100},{position:3, bgX:-100, bgY:-100}]
      ]
    };
    const vdom     = virtualdom();
    const rendered = vdom.render(data);

    t.test('render() -> tag', st => {
      const actual = rendered.tagName.toLowerCase();
      const expect = 'div';

      st.equal(actual, expect, 'tagName should be "div"');
      st.end();
    });

    t.test('render() -> class', st => {
      const actual = rendered.properties.className;
      const expect = CONTAINER_CLASS.substring(1);

      st.equal(actual, expect, 'className should be equal to CONTAINER_CLASS const');
      st.end();
    });

    t.test('render() -> length', st => {
      const actual = rendered.children.length;
      const expect = data.rows * data.cols;

      st.equal(actual, expect, 'number of pieces should be rows * columns');
      st.end();
    });

    t.end();
  });

  t.timeoutAfter(60 * 1000);
});
{'fraction_non_alphanumeric': 0.1952755905511811, 'fraction_numerical': 0.049448818897637796, 'mean_word_length': 2.854368932038835, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '1655292', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1097, 'n_words': 266}