import { evaluateXPathToString } from 'fontoxpath';
import * as slimdom from 'slimdom';

describe('overzealous caching', () => {

	let documentNode;
	beforeEach(() => {
		documentNode = new slimdom.Document();
	});

	it('does not cache this stuff', () => {
		evaluateXPathToString([
		'let $makeHash := function ($node as node(), $makeHash as function(*)) as xs:string {',
		'	if ($node/self::element()) then',
		'		if ($node/self::add or $node/self::delete) then',
		'			string-join($node/node()/$makeHash(., $makeHash))',
		'		 else',
		'			("<" || node-name($node) || " " || string-join($node/@*/(node-name(.) || "=" || . ), " ") || ">" || string-join($node/node()!$makeHash(., $makeHash)) || "</" || node-name($node) || ">")',
		'	 else if ($node/self::processing-instruction()) then',
		'     	""',
		'	else',
		'        string($node)',
		'}',
		'return $makeHash(., $makeHash)',
		].join('\n'),
							 documentNode);
	});
});
