|
|
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 |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
const mutationFromString = mutationAdapter(xml); |
|
|
t.deepEqual(mutationFromString, expectedMutation); |
|
|
t.end(); |
|
|
}); |
|
|
|