import { setupScratch, teardown, sortAttributes } from '../../../test/_util/helpers';
import React, { isValidElement } from '../../src';
import { h as preactH } from 'preact';

describe('jsx', () => {

	/** @type {HTMLDivElement} */
	let scratch;

	beforeEach(() => {
		scratch = setupScratch();
	});

	afterEach(() => {
		teardown(scratch);
	});

	it('should render react-style', () => {
		let jsx = (
			<div className="foo bar" data-foo="bar">
				<span id="some_id">inner!</span>
				{ ['a', 'b'] }
			</div>
		);

		expect(jsx.props).to.have.property('className', 'foo bar');

		React.render(jsx, scratch);
		expect(sortAttributes(scratch.innerHTML)).to.equal(sortAttributes('<div class="foo bar" data-foo="bar"><span id="some_id">inner!</span>ab</div>'));
	});

	describe('isValidElement', () => {
		it('should check return false for invalid arguments', () => {
			expect(isValidElement(null)).to.equal(false);
			expect(isValidElement(false)).to.equal(false);
			expect(isValidElement(true)).to.equal(false);
			expect(isValidElement('foo')).to.equal(false);
			expect(isValidElement(123)).to.equal(false);
		});

		it('should detect a preact vnode', () => {
			expect(isValidElement(preactH('div'))).to.equal(true);
		});

		it('should detect a compat vnode', () => {
			expect(isValidElement(React.createElement('div'))).to.equal(true);
		});
	});
});

@@ -28,24 +28,8 @@
 down
-, sortAttributes
  %7D f
@@ -598,31 +598,16 @@
 %09expect(
-sortAttributes(
 scratch.
@@ -616,17 +616,16 @@
 nerHTML)
-)
 .to.equa
@@ -630,23 +630,8 @@
 ual(
-sortAttributes(
 '%3Cdi
@@ -705,17 +705,16 @@
 %3C/div%3E')
-)
 ;%0A%09%7D);%0A%0A

Remove sortAttributes from jsx tests