<commit_before><!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
	<title>cosmoz-omnitable boolean test</title>

	<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
	<script src="../../web-component-tester/browser.js"></script>
	<script src="../../test-fixture/test-fixture-mocha.js"></script>
	<script src="./helpers/utils.js"></script>

	<link rel="import" href="../../test-fixture/test-fixture.html">
	<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
	<link rel="import" href="../cosmoz-omnitable.html">
	<link rel="import" href="../cosmoz-omnitable-columns.html">
	<link rel="import" href="../demo/table-demo-behavior.html">
</head>
<body>
	<test-fixture id="basic">
		<template>
			<cosmoz-omnitable id="omnitable" class="flex" selection-enabled>
				<cosmoz-omnitable-column-boolean name="boolean" value-path="boolean">
				</cosmoz-omnitable-column-boolean>
			</cosmoz-omnitable>
		</template>
	</test-fixture>

	<script>
	(function () {
		'use strict';

		const domType = getDomType();

		suite('basic' + domType, () => {
			let omnitable,
				column,
				data;

			setup(done => {

				data = [
					{ boolean: true },
					{ boolean: false },
					{ null: true },
					{ boolean: 'invalid' },
					{ boolean: 'true' }
				];
				omnitable = setupOmnitableFixture('basic', data, o => {
					column = o.columns[0];
					done();
				});
			});

			test('initializes boolean column', () => {
				assert.equal(column.is, 'cosmoz-omnitable-column-boolean');
			});

			test('_getDefaultFilter is null', () => {
				assert.isNull(column.filter);
			});

			test('_textFilterChanged updates filter', () => {
				assert.isNull(column.filter);
				column._textFilterChanged('true');
				assert.isTrue(column.filter);
			});

			test('_textFilterChanged updates filter as false', () => {
				assert.isNull(column.filter);
				column._textFilterChanged('false');
				assert.isFalse(column.filter);
			});

			test('_textFilterChanged updates filter as null', done => {
				column.filter = 'true';
				column._filterChangedFromAbove = false;
				column._textFilterChanged();
				assert.isNull(column.filter);
				done();
			});

			test('filterChanged observer converts boolean to string', () => {
				column.filter = true;
				assert.equal(column._textFilter, 'true');
				column.filter = false;
				assert.equal(column._textFilter, 'false');
			});

			test('getString uses this.valuePath as default', () => {
				assert.equal(column.getString(data[0]), 'True');
				assert.equal(column.getString(data[1]), 'False');
			});

			test('_computeSelected returns boolean to number', () => {
				assert.equal(column._computeSelected(data[0]), 0);
				assert.equal(column._computeSelected(data[1]), 1);
			});

			test('_valueChanged updates _valuePath', done => {
				const item = {boolean: false},
					el = document.createElement('div');
				el.selected = 'true';
				el.addEventListener('click', e => {
					column._valueChanged(e);
					assert.equal(item.boolean, true);
					done();
				});
				const e = new Event('click');
				e.model = {};
				e.model.item = item;
				el.dispatchEvent(e);
			});

			test('_valueChanged does not update _valuePath if value is equal to oldValue', done => {
				const item = {boolean: true},
					el = document.createElement('div');
				el.selected = 'true';
				el.addEventListener('click', e => {
					column._valueChanged(e);
					assert.equal(item.boolean, true);
					done();
				});
				const e = new Event('click');
				e.model = {};
				e.model.item = item;
				el.dispatchEvent(e);
			});

			test('_serializeFilter handles null', () => {
				assert.isNull(column._serializeFilter(null));
			});

			test('_serializeFilter handles undefined', () => {
				assert.isNull(column._serializeFilter(undefined));
			});

			test('_serializeFilter handles empty string', () => {
				assert.isNull(column._serializeFilter(''));
			});

			test('_serializeFilter handles boolean true', () => {
				assert.equal(column._serializeFilter(true), 'true');
			});

			test('_serializeFilter handles boolean false', () => {
				assert.equal(column._serializeFilter(false), 'false');
			});

			test('_deserializeFilter handles null', () => {
				assert.isNull(column._deserializeFilter(null));
			});

			test('_deserializeFilter handles undefined', () => {
				assert.isNull(column._deserializeFilter(undefined));
			});

			test('_deserializeFilter handles empty string', () => {
				assert.isNull(column._deserializeFilter(''));
			});

			test('_deserializeFilter handles true string', () => {
				assert.isTrue(column._deserializeFilter('true'));
			});

			test('_deserializeFilter handles false string', () => {
				assert.isFalse(column._deserializeFilter('false'));
			});

			test('_deserializeFilter handles invalid string', () => {
				assert.isNull(column._deserializeFilter('some invalid string'));
			});
		});
	})();
	</script>
</html>
<commit_msg>Boolean column, fix to follow column data updates after table has been rendered, more test fixes.<commit_after><!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
	<title>cosmoz-omnitable boolean test</title>

	<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
	<script src="../../web-component-tester/browser.js"></script>
	<script src="../../test-fixture/test-fixture-mocha.js"></script>
	<script src="./helpers/utils.js"></script>

	<link rel="import" href="../../test-fixture/test-fixture.html">
	<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
	<link rel="import" href="../cosmoz-omnitable.html">
	<link rel="import" href="../cosmoz-omnitable-columns.html">
	<link rel="import" href="../demo/table-demo-behavior.html">
</head>
<body>
	<test-fixture id="basic">
		<template>
			<cosmoz-omnitable id="omnitable" class="flex" selection-enabled>
				<cosmoz-omnitable-column-boolean name="boolean" value-path="boolean">
				</cosmoz-omnitable-column-boolean>
			</cosmoz-omnitable>
		</template>
	</test-fixture>

	<script>
	(function () {
		'use strict';

		const domType = getDomType();

		suite('basic' + domType, () => {
			let omnitable,
				column,
				data;

			setup(done => {

				data = [
					{ boolean: true },
					{ boolean: false },
					{ null: true },
					{ boolean: 'invalid' },
					{ boolean: 'true' }
				];
				omnitable = setupOmnitableFixture('basic', data, o => {
					column = o.columns[0];
					done();
				});
			});

			test('initializes boolean column', () => {
				assert.equal(column.is, 'cosmoz-omnitable-column-boolean');
			});

			test('_getDefaultFilter is null', () => {
				assert.isNull(column.filter);
			});

			test('_textFilterChanged updates filter', () => {
				assert.isNull(column.filter);
				column._textFilterChanged('true');
				assert.isTrue(column.filter);
			});

			test('_textFilterChanged updates filter as false', () => {
				assert.isNull(column.filter);
				column._textFilterChanged('false');
				assert.isFalse(column.filter);
			});

			test('_textFilterChanged updates filter as null', done => {
				column.filter = 'true';
				column._filterChangedFromAbove = false;
				column._textFilterChanged();
				assert.isNull(column.filter);
				done();
			});

			test('filterChanged observer converts boolean to string', () => {
				column.filter = true;
				assert.equal(column._textFilter, 'true');
				column.filter = false;
				assert.equal(column._textFilter, 'false');
			});

			test('getString uses this.valuePath as default', () => {
				assert.equal(column.getString(data[0]), 'True');
				assert.equal(column.getString(data[1]), 'False');
			});

			test('_computeSelected returns boolean to number', () => {
				assert.equal(column._computeSelected(data[0]), 0);
				assert.equal(column._computeSelected(data[1]), 1);
			});

			test('_valueChanged updates _valuePath', done => {
				const item = {boolean: false},
					el = document.createElement('div');
				el.selected = 0;
				el.addEventListener('click', e => {
					column._valueChanged(e);
					assert.equal(item.boolean, true);
					done();
				});
				const e = new Event('click');
				e.model = {};
				e.model.item = item;
				el.dispatchEvent(e);
			});

			test('_valueChanged does not update _valuePath if value is equal to oldValue', done => {
				const item = {boolean: true},
					el = document.createElement('div');
				el.selected = 0;
				el.addEventListener('click', e => {
					column._valueChanged(e);
					assert.equal(item.boolean, true);
					done();
				});
				const e = new Event('click');
				e.model = {};
				e.model.item = item;
				el.dispatchEvent(e);
			});

			test('_serializeFilter handles null', () => {
				assert.isNull(column._serializeFilter(null));
			});

			test('_serializeFilter handles undefined', () => {
				assert.isNull(column._serializeFilter(undefined));
			});

			test('_serializeFilter handles empty string', () => {
				assert.isNull(column._serializeFilter(''));
			});

			test('_serializeFilter handles boolean true', () => {
				assert.equal(column._serializeFilter(true), 'true');
			});

			test('_serializeFilter handles boolean false', () => {
				assert.equal(column._serializeFilter(false), 'false');
			});

			test('_deserializeFilter handles null', () => {
				assert.isNull(column._deserializeFilter(null));
			});

			test('_deserializeFilter handles undefined', () => {
				assert.isNull(column._deserializeFilter(undefined));
			});

			test('_deserializeFilter handles empty string', () => {
				assert.isNull(column._deserializeFilter(''));
			});

			test('_deserializeFilter handles true string', () => {
				assert.isTrue(column._deserializeFilter('true'));
			});

			test('_deserializeFilter handles false string', () => {
				assert.isFalse(column._deserializeFilter('false'));
			});

			test('_deserializeFilter handles invalid string', () => {
				assert.isNull(column._deserializeFilter('some invalid string'));
			});
		});
	})();
	</script>
</html>

{'fraction_non_alphanumeric': 0.18266771591579775, 'fraction_numerical': 0.0025575447570332483, 'mean_word_length': 3.6276741010468823, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 121, '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': '3347021', 'n_tokens_mistral': 3807, 'n_tokens_neox': 3103, 'n_words': 557}