<commit_before>"use strict";

const expect = require('chai').expect;
require('jsdom-global')();
const ChooseBumps = require('./choosebumps');

describe('choose-bumps',function(){
	let cb = ChooseBumps(document.createElement('div'));

	console.log(cb.element);

	it('should return an object (instanceof ChooseBumps)',function(){
		expect(cb).to.satisfy(obj => obj instanceof ChooseBumps);
	});

	describe('element',function(){
		it('should return an HTMLElement',function(){
			expect(cb.element).to.satisfy(obj => obj instanceof HTMLElement);
		});
	})
})<commit_msg>test(general): adding tests for all public functions / properties<commit_after>/*eslint-disable */
"use strict";

const expect = require('chai').expect;
require('jsdom-global')();
const chooseBumps = require('./choosebumps');

describe('choose-bumps',function() {
	let sourceElement = document.createElement('div');
	let cb = chooseBumps(sourceElement);
	let cbSearch = chooseBumps(sourceElement,{
		search: true
	});
	let cbTag = chooseBumps(sourceElement,{
		multiple: true,
		items: ['1','2','3']
	});
	let cbTagSearch = chooseBumps(sourceElement,{
		search: true,
		multiple: true
	});

	it('Initialization: should return an object (instanceof ChooseBumps)',function() {
		expect(cb).to.be.an.instanceOf(chooseBumps);
	});

	describe('Element',function() {
		it('should return same as passed in element',function() {
			expect(cb.element).to.be.equal(sourceElement);
		});
	});

	describe('Items',function() {
		cb.items = ['1','2','3','4'];
		it('should return an array',function() {
			expect(cb.items).to.be.a('array').with.length(4);
		});
	});

	describe('Search',function() {
		it('(non-searchable) should return false',function() {
			expect(cb.search).to.be.false;
		});
		it('(searchable) should return true',function() {
			expect(cbSearch.search).to.be.true;
		});
	});

	describe('Placeholder',function() {
		it('should return a string',function() {
			expect(cb.placeholder).to.be.a('string');
		});
	});

	describe('Multiple',function() {
		it('(non-multiple) should return false',function() {
			expect(cb.multiple).to.be.false;
		});
		it('(multiple) should return true',function() {
			expect(cbTag.multiple).to.be.true;
		});
	});

	describe('Selected',function(){
		it('(non-multiple) should return an object or string',function() {
			cb.select('1');
			expect(cb.selected).to.be.a('string');

			let a = {id: 1};
			let b = {id: 2}
			cb.items = [a,b];
			cb.select({id: 2});
			expect(cb.selected).to.equal(b);
		});
		it('(multiple) should return an array',function() {
			cbTag.select('1');
			expect(cbTag.selected).to.be.a('array').with.length(1);
		});
	});

	describe('All templates',function() {
		it('should return a string',function() {
			expect(cb.template).to.be.a('string');
			expect(cb.tagtemplate).to.be.a('string');
			expect(cb.selectedtemplate).to.be.a('string');
		})
	});

	describe('Searchfields',function() {
		it('should return a string',function() {
			expect(cb.searchfields).to.be.a('string');
		})
	});

	describe('onSelect',function() {
		it('should trigger',function(done) {
			cb.items = [1,2,3];
			cb.onselect = function(item){
				expect(item).to.be.equal(2);
				done();
			};
			cb.select(2);
		});
	})
});
{'fraction_non_alphanumeric': 0.20556414219474498, 'fraction_numerical': 0.005873261205564142, 'mean_word_length': 4.788908765652952, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5256317', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1076, 'n_words': 184}