Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Dirty Flag for HTMLInputElement.value #913

Merged
merged 11 commits into from
Sep 1, 2020
Prev Previous commit
Next Next commit
add a test
  • Loading branch information
samouri committed Aug 26, 2020
commit 400f7f129c4801c111ad50ccd3167efb41391411
38 changes: 38 additions & 0 deletions src/test/document/hydrateNode.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import anyTest, { TestInterface } from 'ava';
import { createTestingDocument } from '../DocumentCreation';
import { TransferrableKeys } from '../../transfer/TransferrableKeys';
import { NodeType, HydrateableNode, HTML_NAMESPACE } from '../../transfer/TransferrableNodes';
import { Document } from '../../worker-thread/dom/Document';

const test = anyTest as TestInterface<{
document: Document;
}>;

test.beforeEach((t) => {
const document = createTestingDocument();
t.context = { document };
});

test('supports hydrating a node with a value attribute', (t) => {
const { document } = t.context;

let { node, strings } = getHydratableInputNode(0, 'startingValue');
const hydratedNode = document[TransferrableKeys.hydrateNode](strings, node);
t.is(hydratedNode.value, 'startingValue');
});

function getHydratableInputNode(index: number, value: string): { node: HydrateableNode; strings: Array<string> } {
const strings = ['input', '', HTML_NAMESPACE, 'value', value];
return {
node: {
[TransferrableKeys.index]: index,
[TransferrableKeys.transferred]: 0,
[TransferrableKeys.nodeType]: NodeType.ELEMENT_NODE,
[TransferrableKeys.localOrNodeName]: 0,
[TransferrableKeys.textContent]: 1,
[TransferrableKeys.attributes]: [[2, 3, 4]],
[TransferrableKeys.childNodes]: [],
},
strings,
};
}