Files
cocos-engine/tests/ui/test-widget.js
pandamicro 1380e46c34 Unittest (#4973)
* unit test for ts

* Fix ts-jest warnings

* Remove puppeteer for now

* fix physics define and jest config for windows

* Replace Node ref with INode ref

* Fix ci issue

* Fix

* tweak

* tweak

* Fix vscode launcher

* now physics framework export all physics component (#28)

* tweaks
2019-07-25 17:15:20 +08:00

29 lines
838 B
JavaScript

module('cc.Widget', SetupEngine);
test('updateAlignment', function () {
var scene = cc.director.getScene();
var dummyCanvas = new cc.Node();
dummyCanvas.width = 960;
dummyCanvas.parent = scene;
var parent = new cc.Node();
var parentWidget = parent.addComponent(cc.Widget);
parent.parent = dummyCanvas;
var child = new cc.Node();
var childWidget = child.addComponent(cc.Widget);
child.parent = parent;
parentWidget.isAlignLeft = true;
parentWidget.isAlignRight = true;
parentWidget.left = 0;
parentWidget.right = 0;
childWidget.isAlignLeft = true;
childWidget.isAlignRight = true;
childWidget.left = 0;
childWidget.right = 0;
childWidget.updateAlignment();
strictEqual(child.width, 960, 'child size should be updated even if parent size also diry');
});