Skip to content

Commit

Permalink
Merge 1a7e0e5 into 1ddcf1b
Browse files Browse the repository at this point in the history
  • Loading branch information
aarranz committed Mar 18, 2020
2 parents 1ddcf1b + 1a7e0e5 commit f75a087
Show file tree
Hide file tree
Showing 27 changed files with 1,325 additions and 241 deletions.
2 changes: 2 additions & 0 deletions src/GruntFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ var WirecloudFiles = [
'wirecloud/platform/static/js/wirecloud/LogManager.js',
'wirecloud/commons/static/js/wirecloud/Task.js',
'wirecloud/commons/static/js/wirecloud/ui/Draggable.js',
'wirecloud/commons/static/js/wirecloud/ui/ResizeHandle.js',
'wirecloud/commons/static/js/wirecloud/ui/MACSearch.js',
'wirecloud/commons/static/js/wirecloud/ui/WindowMenu.js',
'wirecloud/commons/static/js/wirecloud/ui/AlertWindowMenu.js',
Expand All @@ -126,6 +127,7 @@ var WirecloudFiles = [
'wirecloud/platform/static/js/wirecloud/wiring/KeywordSuggestion.js',
'wirecloud/platform/static/js/wirecloud/wiring/Operator.js',
'wirecloud/platform/static/js/wirecloud/ui/WidgetViewDraggable.js',
'wirecloud/platform/static/js/wirecloud/ui/WidgetViewResizeHandle.js',
'wirecloud/platform/static/js/wirecloud/ui/WidgetView.js',
'wirecloud/platform/static/js/wirecloud/ui/WiringEditor.js',
'wirecloud/platform/static/js/wirecloud/ui/WiringEditor/Behaviour.js',
Expand Down
20 changes: 20 additions & 0 deletions src/js_tests/wirecloud/WidgetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@

describe("Wirecloud.Widget", function () {

beforeAll(() => {
spyOn(console, "log");
spyOn(console, "info");
});

// TODO
beforeEach(() => {
Wirecloud.PropertyCommiter = jasmine.createSpy("PropertyCommiter").and.returnValue({
Expand Down Expand Up @@ -1191,6 +1196,9 @@

it("should allow to modify all the position properties", () => {
const new_position = {
anchor: "bottom-left",
relx: false,
rely: true,
x: 1,
y: 2,
z: 3
Expand All @@ -1203,13 +1211,19 @@
it("should ignore extra properties", () => {
const new_position = {
extra: 123,
anchor: "bottom-left",
relx: true,
rely: false,
x: 1,
y: 2,
z: 3
};
expect(widget.setPosition(new_position)).toBe(widget);

expect(widget.position).toEqual({
anchor: "bottom-left",
relx: true,
rely: false,
x: 1,
y: 2,
z: 3
Expand Down Expand Up @@ -1239,6 +1253,8 @@

it("should allow to modify all the shape properties", () => {
const new_shape = {
relwidth: true,
relheight: true,
width: 2,
height: 3
};
Expand All @@ -1250,12 +1266,16 @@
it("should ignore extra properties", () => {
const new_shape = {
extra: 123,
relwidth: true,
relheight: true,
width: 2,
height: 3
};
expect(widget.setShape(new_shape)).toBe(widget);

expect(widget.shape).toEqual({
relwidth: true,
relheight: true,
width: 2,
height: 3
});
Expand Down
5 changes: 5 additions & 0 deletions src/js_tests/wirecloud/WiringSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

describe("Wiring", function () {

beforeAll(() => {
spyOn(console, "log");
spyOn(console, "info");
});

beforeEach(function () {

spyOn(Wirecloud.wiring, "Operator").and.callFake(function (wiring, meta, data) {
Expand Down
8 changes: 4 additions & 4 deletions src/js_tests/wirecloud/ui/ColumnLayoutSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@

expect(widget1.setShape).toHaveBeenCalledWith({width: 4});
expect(widget2.setShape).toHaveBeenCalledWith({width: 4});
expect(widget2.setPosition).toHaveBeenCalledWith(new Wirecloud.DragboardPosition(0, 1));
expect(widget2.setPosition).toHaveBeenCalledWith({relx: true, x: 0, rely: true, y: 1});
});

it("should move colliding widgets", () => {
Expand Down Expand Up @@ -217,8 +217,8 @@
let widget = createWidgetMock({id: "1", x: 0, y: 0, width: 3, height: 1});
layout.addWidget(widget);
layout.initializeMove(widget, draggable);
layout.moveTemporally(1, 0);
layout.moveTemporally(2, 0);
layout.moveTemporally(200, 0);
layout.moveTemporally(420, 0);
layout.acceptMove();

expect(widget.position).toEqual({x: 1, y: 0});
Expand All @@ -229,7 +229,7 @@
let widget = createWidgetMock({id: "1", x: 0, y: 0, width: 2, height: 1});
layout.addWidget(widget);
layout.initializeMove(widget, draggable);
layout.moveTemporally(10, 0);
layout.moveTemporally(1000, 0);
layout.acceptMove();

expect(widget.position).toEqual({x: 2, y: 0});
Expand Down
53 changes: 52 additions & 1 deletion src/js_tests/wirecloud/ui/DragboardLayoutSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@

});


describe("updatePosition(widget, element)", () => {

it("should update widget css", () => {
Expand All @@ -488,6 +487,58 @@

});

describe("updateShape(widget, element)", () => {

it("should update widget css", () => {
let layout = new ns.DragboardLayout({});
layout.getWidthInPixels = jasmine.createSpy("getWidthInPixels").and.returnValue(10);
layout.getHeightInPixels = jasmine.createSpy("getHeightInPixels").and.returnValue(20);
let widget = {
element: document.createElement('div'),
minimized: false,
shape: {width: 1, height: 3}
};

layout.updateShape(widget, widget.element);

expect(widget.element.style.width).toBe("10px");
expect(widget.element.style.height).toBe("20px");
});

it("should update widget css (minimized)", () => {
let layout = new ns.DragboardLayout({});
layout.getWidthInPixels = jasmine.createSpy("getWidthInPixels").and.returnValue(10);
layout.getHeightInPixels = jasmine.createSpy("getHeightInPixels").and.returnValue(20);
let widget = {
element: document.createElement('div'),
minimized: true,
shape: {width: 1, height: 3}
};

layout.updateShape(widget, widget.element);

expect(widget.element.style.width).toBe("10px");
expect(widget.element.style.height).toBe("");
});

it("should update widget css (null sizes)", () => {
let layout = new ns.DragboardLayout({});
layout.getWidthInPixels = jasmine.createSpy("getWidthInPixels").and.returnValue(null);
layout.getHeightInPixels = jasmine.createSpy("getHeightInPixels").and.returnValue(null);
let widget = {
element: document.createElement('div'),
minimized: false,
shape: {width: 1, height: 3}
};

layout.updateShape(widget, widget.element);

expect(widget.element.style.width).toBe("");
expect(widget.element.style.height).toBe("");
});

});

describe("provides basic implementations of", () => {
["_notifyResizeEvent", "initializeMove", "moveTemporally", "acceptMove", "cancelMove", "disableCursor"].forEach((method) => {
it("", () => {
Expand Down

0 comments on commit f75a087

Please sign in to comment.