UNPKG

@eclipse-glsp/graph

Version:

The typescript implementation of the GLSP graphical model (GModel)

68 lines 3.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /******************************************************************************** * Copyright (c) 2024 EclipseSource and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ const protocol_1 = require("@eclipse-glsp/protocol"); const chai_1 = require("chai"); const galignable_1 = require("./galignable"); const glabel_1 = require("./glabel"); const gnode_1 = require("./gnode"); describe('GAlignable Tests', () => { describe('isGAlignable function', () => { it('should return true for a GAlignable element', () => { const gLabelElement = new glabel_1.GLabelBuilder(glabel_1.GLabel) // .type(protocol_1.DefaultTypes.LABEL) // .build(); const result = (0, galignable_1.isGAlignable)(gLabelElement); (0, chai_1.expect)(result).to.be.true; }); it('should return false for a non-GAlignable element', () => { const gNodeElement = new gnode_1.GNodeBuilder(gnode_1.GNode) // .position(100, 50) // .size(50, 15) // .type(protocol_1.DefaultTypes.NODE) // .build(); const result = (0, galignable_1.isGAlignable)(gNodeElement); (0, chai_1.expect)(result).to.be.false; }); }); describe('GAlignableBuilder alignment function', () => { it('should set alignment using a point object', () => { const builder = new glabel_1.GLabelBuilder(glabel_1.GLabel); galignable_1.GAlignableBuilder.alignment(builder, { x: 45, y: 90 }); (0, chai_1.expect)(builder['proxy'].alignment).to.deep.equal({ x: 45, y: 90 }); }); it('should set alignment using x and y parameters', () => { let builder = new glabel_1.GLabelBuilder(glabel_1.GLabel); galignable_1.GAlignableBuilder.alignment(builder, 8, 16); (0, chai_1.expect)(builder['proxy'].alignment).to.deep.equal({ x: 8, y: 16 }); builder = new glabel_1.GLabelBuilder(glabel_1.GLabel); galignable_1.GAlignableBuilder.alignment(builder, 12, 0); (0, chai_1.expect)(builder['proxy'].alignment).to.deep.equal({ x: 12, y: 0 }); }); it('should set alignment from point object if y is provided too', () => { const builder = new glabel_1.GLabelBuilder(glabel_1.GLabel); galignable_1.GAlignableBuilder.alignment(builder, { x: 17, y: 71 }, 15); (0, chai_1.expect)(builder['proxy'].alignment).to.deep.equal({ x: 17, y: 71 }); }); it('should default y to 0 if y is not provided', () => { const builder = new glabel_1.GLabelBuilder(glabel_1.GLabel); galignable_1.GAlignableBuilder.alignment(builder, 77); (0, chai_1.expect)(builder['proxy'].alignment).to.deep.equal({ x: 77, y: 0 }); }); }); }); //# sourceMappingURL=galignable.spec.js.map