<commit_before>var h = require('virtual-dom/h');
var patch = require('virtual-dom/patch');
var diff = require('virtual-dom/diff');
var createElement = require('./test-tools/createElement');
var propertyType = require('./test-tools/propertyType');
var test = require('./test-tools/test')('The model');

var model = require('../module/model');

var virtualMock =
  h('bare-select', {attributes: {
    value: 'a',
    unfolded: '',
    unchanged: 'unchanged',
  }})
;
var virtualUpdate =
  h('bare-select', {attributes: {
    value: 'b',
    disabled: '',
    unchanged: 'unchanged',
  }})
;
var mock = createElement(virtualMock);

test('The API is in good shape.', function(is) {
  is.equal(
    typeof model,
    'function',
    'is a constructor function'
  );

  var modelInstance = model(mock);

  is.ok(
    Object.isFrozen(modelInstance),
    'returning a frozen object, and inside:'
  );

  is.deepEqual(
    modelInstance.patches && Object.keys(modelInstance.patches)
      .map(propertyType(modelInstance.patches))
    ,
    [
      {property: 'emit', type: 'function'},
    ],
    '• an input channel `patches`'
  );

  is.deepEqual(
    modelInstance.updates && Object.keys(modelInstance.updates)
      .map(propertyType(modelInstance.updates))
    ,
    [
      {property: 'on', type: 'function'},
      {property: 'when', type: 'function'},
    ],
    '• a cacheable output channel `updates` with error handling'
  );

  is.end();
});

test('The channel `updates` works alright.', {timeout: 2000}, function(is) {
  var modelInstance = model(mock);
  var firstRun = true;
  var valueState;

  is.plan(16);

  var justCalled = true;<commit_msg>Update test<commit_after>var h = require('virtual-dom/h');
var patch = require('virtual-dom/patch');
var diff = require('virtual-dom/diff');
var createElement = require('./test-tools/createElement');
var propertyType = require('./test-tools/propertyType');
var test = require('./test-tools/test')('The model');

var model = require('../module/model');

var virtualMock =
  h('bare-select', {attributes: {
    value: 'a',
    unfolded: '',
    unchanged: 'unchanged',
  }})
;
var virtualUpdate =
  h('bare-select', {attributes: {
    value: 'b',
    disabled: '',
    unchanged: 'unchanged',
  }})
;
var mock = createElement(virtualMock);

test('The API is in good shape.', function(is) {
  is.equal(
    typeof model,
    'function',
    'is a constructor function'
  );

  var modelInstance = model(mock);

  is.ok(
    Object.isFrozen(modelInstance),
    'returning a frozen object, and inside:'
  );

  is.deepEqual(
    modelInstance.patches && Object.keys(modelInstance.patches)
      .map(propertyType(modelInstance.patches))
    ,
    [
      {property: 'emit', type: 'function'},
    ],
    '• an input channel `patches`'
  );

  is.deepEqual(
    modelInstance.updates && Object.keys(modelInstance.updates)
      .map(propertyType(modelInstance.updates))
    ,
    [
      {property: 'on', type: 'function'},
      {property: 'when', type: 'function'},
    ],
    '• a cacheable output channel `updates`'
  );

  is.end();
});

test('The channel `updates` works alright.', {timeout: 2000}, function(is) {
  var modelInstance = model(mock);
  var firstRun = true;
  var valueState;

  is.plan(16);

  var justCalled = true;
{'fraction_non_alphanumeric': 0.16747868453105969, 'fraction_numerical': 0.0036540803897685747, 'mean_word_length': 3.493844049247606, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4770893', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1047, 'n_words': 245}