mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 15:02:52 -05:00
27 lines
903 B
JavaScript
27 lines
903 B
JavaScript
|
const test = require('tap').test;
|
||
|
|
||
|
const mutationAdapter = require('../../src/engine/mutation-adapter');
|
||
|
|
||
|
test('spec', t => {
|
||
|
t.type(mutationAdapter, 'function');
|
||
|
t.end();
|
||
|
});
|
||
|
|
||
|
test('convert DOM to Scratch object', t => {
|
||
|
const testStringRaw = '"arbitrary" & \'complicated\' test string';
|
||
|
const testStringEscaped = '\\"arbitrary\\" & 'complicated' test string';
|
||
|
const xml = `<mutation blockInfo="{"text":"${testStringEscaped}"}"></mutation>`;
|
||
|
const expectedMutation = {
|
||
|
tagName: 'mutation',
|
||
|
children: [],
|
||
|
blockInfo: {
|
||
|
text: testStringRaw
|
||
|
}
|
||
|
};
|
||
|
|
||
|
// TODO: do we want to test passing a DOM node to `mutationAdapter`? Node.js doesn't have built-in DOM support...
|
||
|
const mutationFromString = mutationAdapter(xml);
|
||
|
t.deepEqual(mutationFromString, expectedMutation);
|
||
|
t.end();
|
||
|
});
|