<commit_before>import composeQuery from './composeQuery';

describe('composeQuery', () => {
	it('composes correct query one simple word', () => {
		expect(
			composeQuery('set' )
		).toEqual(
			'https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.ldoceonline.com%2Fdictionary%2Fset%22'
		)
	});

	it('composes correct query for word with space', () => {
		expect(
			composeQuery('fire alarm')
		).toEqual(
			'https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.ldoceonline.com%2Fdictionary%2Ffire-alarm%22'
		)
	});
	
	it('composes correct query for word with slash', () => {
		expect(
			composeQuery('put/set pen to paper')
		).toEqual(
			'https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.ldoceonline.com%2Fdictionary%2Fput-set-pen-to-paper%22'
		)
	});

	it('composes correct query for word with apostrophe', () => {
		expect(
			composeQuery('set somebody’s teeth on edge')
		).toEqual(
			'https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.ldoceonline.com%2Fdictionary%2Fset-somebody-s-teeth-on-edge%22'
		)
	});

	it('composes correct query for word with exclamation mark', () => {
		expect(
			composeQuery('that does it!')
		).toEqual(
			'https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.ldoceonline.com%2Fdictionary%2Fthat-does-it%22'
		)
	});

	it('composes correct query for word with question mark', () => {
		expect(
			composeQuery('what can I do you for?')
		).toEqual(
			'https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.ldoceonline.com%2Fdictionary%2Fwhat-can-i-do-you-for%22'
		)
	});

	it('composes correct query for word with parenthesis', () => {
		expect(
			composeQuery('a closed set (of something)')
		).toEqual(
			'https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.ldoceonline.com%2Fdictionary%2Fa-closed-set-of-something%22'
		)
	});

	it('composes correct query for word with uppercase symbols', () => {
		expect(
			composeQuery('catch/get some Z’s')
		).toEqual(
			'https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.ldoceonline.com%2Fdictionary%2Fcatch-get-some-z-s%22'
		)
	});

	it('composes correct query for word with dots, double spaces and spaces in the end after removing symbols', () => {
		expect(
			composeQuery('not ... but rather ...')
		).toEqual(
			'https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.ldoceonline.com%2Fdictionary%2Fnot-but-rather%22'
		)
	});

	it('composes correct query for word with commas', () => {
		expect(
			composeQuery('I don’t want to sound/be ..., but ...')
		).toEqual(
			'https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.ldoceonline.com%2Fdictionary%2Fi-don-t-want-to-sound-be-but%22'<commit_msg>refactor: composeQuery test<commit_after>import composeQuery from './composeQuery';

const beforeWord = 'https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.ldoceonline.com%2Fdictionary%2F';
const afterWord = '%22';
const addFrame = word => `${beforeWord}${word}${afterWord}`

describe('composeQuery', () => {
	it('composes correct query one simple word', () => {
		expect(
			composeQuery('set')
		).toEqual(
			addFrame('set')
		)
	});

	it('composes correct query for word with space', () => {
		expect(
			composeQuery('fire alarm')
		).toEqual(
			addFrame('fire-alarm')
		)
	});
	
	it('composes correct query for word with slash', () => {
		expect(
			composeQuery('put/set pen to paper')
		).toEqual(
			addFrame('put-set-pen-to-paper')
		)
	});

	it('composes correct query for word with apostrophe', () => {
		expect(
			composeQuery('set somebody’s teeth on edge')
		).toEqual(
			addFrame('set-somebody-s-teeth-on-edge')
		)
	});

	it('composes correct query for word with exclamation mark', () => {
		expect(
			composeQuery('that does it!')
		).toEqual(
			addFrame('that-does-it')
		)
	});

	it('composes correct query for word with question mark', () => {
		expect(
			composeQuery('what can I do you for?')
		).toEqual(
			addFrame('what-can-i-do-you-for')
		)
	});

	it('composes correct query for word with parenthesis', () => {
		expect(
			composeQuery('a closed set (of something)')
		).toEqual(
			addFrame('a-closed-set-of-something')
		)
	});

	it('composes correct query for word with uppercase symbols', () => {
		expect(
			composeQuery('catch/get some Z’s')
		).toEqual(
			addFrame('catch-get-some-z-s')
		)
	});

	it('composes correct query for word with dots, double spaces and spaces in the end after removing symbols', () => {
		expect(
			composeQuery('not ... but rather ...')
		).toEqual(
			addFrame('not-but-rather')
		)
	});

	it('composes correct query for word with commas', () => {
		expect(
			composeQuery('I don’t want to sound/be ..., but ...')
		).toEqual(
			addFrame('i-don-t-want-to-sound-be-but')
{'fraction_non_alphanumeric': 0.1779434250764526, 'fraction_numerical': 0.04415137614678899, 'mean_word_length': 4.485324947589098, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, 'https://': 11, 'lorem ipsum': 0, 'www.': 11, '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': '2129750', 'n_tokens_mistral': 2278, 'n_tokens_neox': 2013, 'n_words': 321}