chore: add simple round tripping tests (#6668)

This commit is contained in:
Beka Westberg
2022-12-05 10:30:28 -08:00
committed by GitHub
parent bcdbaa315c
commit 9741cd2530
8 changed files with 131 additions and 12 deletions

View File

@@ -11,6 +11,9 @@ import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown
suite('Procedure Change Return Event', function() {
const DEFAULT_TYPES = null;
const NON_DEFAULT_TYPES = [];
setup(function() {
sharedTestSetup.call(this);
this.workspace = new Blockly.Workspace();
@@ -23,9 +26,6 @@ suite('Procedure Change Return Event', function() {
});
suite('running', function() {
const DEFAULT_TYPES = null;
const NON_DEFAULT_TYPES = [];
setup(function() {
this.createProcedureModel = (id) => {
return new Blockly.procedures.ObservableProcedureModel(
@@ -180,4 +180,18 @@ suite('Procedure Change Return Event', function() {
});
});
});
suite.skip('serialization', function() {
test('events round-trip through JSON', function() {
const model = new Blockly.procedures.ObservableProcedureModel(
this.workspace, 'test name', 'test id');
const origEvent = new Blockly.Events.ProcedureChangeReturn(
this.workspace, model, NON_DEFAULT_TYPES);
const json = origEvent.toJson();
const newEvent = new Blockly.Events.fromJson(json, this.workspace);
chai.assert.deepEqual(newEvent, origEvent);
});
});
});

View File

@@ -145,4 +145,17 @@ suite('Procedure Create Event', function() {
});
});
});
suite.skip('serialization', function() {
test('events round-trip through JSON', function() {
const model = new Blockly.procedures.ObservableProcedureModel(
this.workspace, 'test name', 'test id');
const origEvent = new Blockly.Events.ProcedureCreate(this.workspace, model);
const json = origEvent.toJson();
const newEvent = new Blockly.Events.fromJson(json, this.workspace);
chai.assert.deepEqual(newEvent, origEvent);
});
});
});

View File

@@ -30,8 +30,7 @@ suite('Procedure Delete Event', function() {
};
this.createEventToState = (procedureModel) => {
return new Blockly.Events.ProcedureDelete(
this.workspace, procedureModel);
return new Blockly.Events.ProcedureDelete(this.workspace, procedureModel);
};
});
@@ -146,4 +145,17 @@ suite('Procedure Delete Event', function() {
});
});
});
suite.skip('serialization', function() {
test('events round-trip through JSON', function() {
const model = new Blockly.procedures.ObservableProcedureModel(
this.workspace, 'test name', 'test id');
const origEvent = new Blockly.Events.ProcedureDelete(this.workspace, model);
const json = origEvent.toJson();
const newEvent = new Blockly.Events.fromJson(json, this.workspace);
chai.assert.deepEqual(newEvent, origEvent);
});
});
});

View File

@@ -30,8 +30,7 @@ suite('Procedure Enable Event', function() {
};
this.createEventToState = (procedureModel) => {
return new Blockly.Events.ProcedureEnable(
this.workspace, procedureModel);
return new Blockly.Events.ProcedureEnable(this.workspace, procedureModel);
};
});
@@ -172,4 +171,17 @@ suite('Procedure Enable Event', function() {
});
});
});
suite.skip('serialization', function() {
test('events round-trip through JSON', function() {
const model = new Blockly.procedures.ObservableProcedureModel(
this.workspace, 'test name', 'test id');
const origEvent = new Blockly.Events.ProcedureEnable(this.workspace, model);
const json = origEvent.toJson();
const newEvent = new Blockly.Events.fromJson(json, this.workspace);
chai.assert.deepEqual(newEvent, origEvent);
});
});
});

View File

@@ -32,9 +32,9 @@ suite('Procedure Parameter Create Event', function() {
this.createProcedureAndParameter =
(procName, procId, paramName, paramId) => {
const param = new Blockly.procedures.ObservableParameterModel(
this.workspace, procName, paramId);
this.workspace, paramName, paramId);
const proc = new Blockly.procedures.ObservableProcedureModel(
this.workspace, paramName, procId)
this.workspace, procName, procId)
.insertParameter(param, 0);
return {param, proc};
};
@@ -196,4 +196,22 @@ suite('Procedure Parameter Create Event', function() {
});
});
});
suite.skip('serialization', function() {
test('events round-trip through JSON', function() {
const param = new Blockly.procedures.ObservableParameterModel(
this.workspace, 'test param name', 'test param id');
const model =
new Blockly.procedures.ObservableProcedureModel(
this.workspace, 'test name', 'test id')
.insertParameter(param, 0);
const origEvent = new Blockly.Events.ProcedureParameterCreate(
this.workspace, model);
const json = origEvent.toJson();
const newEvent = new Blockly.Events.fromJson(json, this.workspace);
chai.assert.deepEqual(newEvent, origEvent);
});
});
});

View File

@@ -196,4 +196,22 @@ suite('Procedure Parameter Delete Event', function() {
});
});
});
suite.skip('serialization', function() {
test('events round-trip through JSON', function() {
const param = new Blockly.procedures.ObservableParameterModel(
this.workspace, 'test param name', 'test param id');
const model =
new Blockly.procedures.ObservableProcedureModel(
this.workspace, 'test name', 'test id')
.insertParameter(param, 0);
const origEvent = new Blockly.Events.ProcedureParameterDelete(
this.workspace, model);
const json = origEvent.toJson();
const newEvent = new Blockly.Events.fromJson(json, this.workspace);
chai.assert.deepEqual(newEvent, origEvent);
});
});
});

View File

@@ -203,4 +203,22 @@ suite('Procedure Parameter Rename Event', function() {
});
});
});
suite.skip('serialization', function() {
test('events round-trip through JSON', function() {
const param = new Blockly.procedures.ObservableParameterModel(
this.workspace, 'test param name', 'test param id');
const model =
new Blockly.procedures.ObservableProcedureModel(
this.workspace, 'test name', 'test id')
.insertParameter(param, 0);
const origEvent = new Blockly.Events.ProcedureParameterDelete(
this.workspace, model);
const json = origEvent.toJson();
const newEvent = new Blockly.Events.fromJson(json, this.workspace);
chai.assert.deepEqual(newEvent, origEvent);
});
});
});

View File

@@ -11,6 +11,9 @@ import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown
suite('Procedure Rename Event', function() {
const DEFAULT_NAME = 'default';
const NON_DEFAULT_NAME = 'non-default';
setup(function() {
sharedTestSetup.call(this);
this.workspace = new Blockly.Workspace();
@@ -23,9 +26,6 @@ suite('Procedure Rename Event', function() {
});
suite('running', function() {
const DEFAULT_NAME = 'default';
const NON_DEFAULT_NAME = 'non-default';
setup(function() {
this.createProcedureModel = (id) => {
return new Blockly.procedures.ObservableProcedureModel(
@@ -168,4 +168,18 @@ suite('Procedure Rename Event', function() {
});
});
});
suite.skip('serialization', function() {
test('events round-trip through JSON', function() {
const model = new Blockly.procedures.ObservableProcedureModel(
this.workspace, 'test name', 'test id');
const origEvent = new Blockly.Events.ProcedureRename(
this.workspace, model, NON_DEFAULT_NAME);
const json = origEvent.toJson();
const newEvent = new Blockly.Events.fromJson(json, this.workspace);
chai.assert.deepEqual(newEvent, origEvent);
});
});
});