mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-01-12 07:12:54 +01:00
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>
83 lines
2.1 KiB
JavaScript
83 lines
2.1 KiB
JavaScript
const { ProjectModel } = require('@noodl-models/projectmodel');
|
|
|
|
describe('Expanded ports tests', function () {
|
|
beforeEach(() => {
|
|
ProjectModel.instance = ProjectModel.fromJSON(getProject());
|
|
});
|
|
|
|
xit('can get correct ports after load', function () {
|
|
var ports = ProjectModel.instance.findNodeWithId('EP-1').getPorts();
|
|
expect(ports.length).toBe(3);
|
|
expect(ports[1]).toEqual({
|
|
name: 'Affe.A',
|
|
index: 101,
|
|
plug: 'input',
|
|
type: 'number'
|
|
});
|
|
expect(ports[2]).toEqual({
|
|
name: 'Affe.B',
|
|
index: 102,
|
|
plug: 'input',
|
|
type: 'number'
|
|
});
|
|
});
|
|
|
|
xit('can react to param changes', function () {
|
|
ProjectModel.instance.findNodeWithId('EP-1').setParameter('Affe.A', 'something');
|
|
|
|
var ports = ProjectModel.instance.findNodeWithId('EP-1').getPorts();
|
|
expect(ports.length).toBe(2);
|
|
expect(ports[1]).toEqual({
|
|
name: 'Affe.A',
|
|
index: 101,
|
|
plug: 'input',
|
|
type: 'number'
|
|
});
|
|
});
|
|
|
|
xit('can rename ports and parameters are copied', function () {
|
|
ProjectModel.instance.findNodeWithId('EP-2').setParameter('Bosse.A', 'grr');
|
|
|
|
ProjectModel.instance.findNodeWithId('EP-2').renamePortWithName('Bosse', 'Oscar');
|
|
|
|
expect(ProjectModel.instance.findNodeWithId('EP-2').parameters['Oscar.A']).toBe('grr');
|
|
expect(ProjectModel.instance.findNodeWithId('EP-2').parameters['Bosse.A']).toBe(undefined);
|
|
});
|
|
|
|
function getProject() {
|
|
return {
|
|
components: [
|
|
{
|
|
name: 'comp1',
|
|
graph: {
|
|
roots: [
|
|
{
|
|
type: 'ExpandPorts',
|
|
id: 'EP-1',
|
|
ports: [
|
|
{
|
|
type: 'number',
|
|
name: 'Affe',
|
|
plug: 'input'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
type: 'ExpandPorts',
|
|
id: 'EP-2',
|
|
ports: [
|
|
{
|
|
type: 'number',
|
|
name: 'Bosse',
|
|
plug: 'input'
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
};
|
|
}
|
|
});
|