Skip to content

Commit

Permalink
chore: Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
gonfunko committed Nov 13, 2024
1 parent 9eef1a5 commit 4130a48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 41 deletions.
10 changes: 7 additions & 3 deletions tests/mocha/contextmenu_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ suite('Context Menu', function () {
});

test('callback with xml state creates block', function () {
const xmlField = Variables.generateVariableFieldDom(
this.forLoopBlock.getField('VAR').getVariable(),
);
const variable = this.forLoopBlock.getField('VAR').getVariable();
const xmlField = document.createElement('field');
xmlField.setAttribute('name', 'VAR');
xmlField.setAttribute('id', variable.getId());
xmlField.setAttribute('variabletype', variable.getType());
xmlField.textContent = variable.getName();

const xmlBlock = xmlUtils.createElement('block');
xmlBlock.setAttribute('type', 'variables_get');
xmlBlock.appendChild(xmlField);
Expand Down
38 changes: 0 additions & 38 deletions tests/mocha/xml_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,42 +888,4 @@ suite('XML', function () {
});
});
});
suite('generateVariableFieldDom', function () {
test('Case Sensitive', function () {
const varId = 'testId';
const type = 'testType';
const name = 'testName';

const mockVariableModel = {
type: type,
name: name,
getId: function () {
return varId;
},
getName: function () {
return name;
},
getType: function () {
return type;
},
};

const generatedXml = Blockly.Xml.domToText(
Blockly.Variables.generateVariableFieldDom(mockVariableModel),
);
const expectedXml =
'<field xmlns="https://developers.google.com/blockly/xml"' +
' name="VAR"' +
' id="' +
varId +
'"' +
' variabletype="' +
type +
'"' +
'>' +
name +
'</field>';
assert.equal(generatedXml, expectedXml);
});
});
});

0 comments on commit 4130a48

Please sign in to comment.