mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-01-12 07:12:54 +01:00
Initial commit
Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com> Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com> Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com> Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com> Co-Authored-By: Johan <4934465+joolsus@users.noreply.github.com> Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com> Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
This commit is contained in:
47
packages/noodl-editor/tests/project/projectvalidator.js
Normal file
47
packages/noodl-editor/tests/project/projectvalidator.js
Normal file
@@ -0,0 +1,47 @@
|
||||
var ProjectValidator = require('@noodl-utils/projectvalidator');
|
||||
|
||||
// Project settings
|
||||
describe('Project validator', function () {
|
||||
it('can validate missing components', function () {
|
||||
const proj = {};
|
||||
|
||||
const validator = new ProjectValidator();
|
||||
validator.validate(proj);
|
||||
expect(validator.hasErrors()).toBe(true);
|
||||
expect(validator.errors[0].msg).toBe('Project is missing name');
|
||||
expect(validator.errors[1].msg).toBe('Project is missing components');
|
||||
});
|
||||
|
||||
it('can validate dangling connections and fix', function () {
|
||||
const proj = {
|
||||
name: 'C',
|
||||
components: [
|
||||
{
|
||||
name: 'A',
|
||||
graph: {
|
||||
roots: [],
|
||||
connections: [
|
||||
{
|
||||
fromId: 'a',
|
||||
fromProperty: 'hej',
|
||||
toId: 'b',
|
||||
toProperty: 'hej'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const validator = new ProjectValidator();
|
||||
validator.validate(proj);
|
||||
expect(validator.hasErrors()).toBe(true);
|
||||
expect(validator.errors[0].msg).toBe('Dangling connection at A missing source missing target ');
|
||||
|
||||
validator.fix();
|
||||
validator.clearErrors();
|
||||
validator.validate(proj);
|
||||
expect(validator.hasErrors()).toBe(false);
|
||||
expect(proj.components[0].graph.connections.length).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user