Files
cocos-engine/tests/core/test-component.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

39 lines
1.2 KiB
JavaScript

largeModule('Component', SetupEngine);
test('Inheritance of editor properties', function () {
var base = cc.Class({
extends: cc.Component,
editor: {
inspector: 'jare.html',
icon: 'guo.png',
executeInEditMode: true,
playOnFocus: true,
}
});
var child = cc.Class({
extends: base
});
ok(!child._inspector, 'should not inherit inspector from base component');
ok(!child._icon, 'should not inherit icon from base component');
strictEqual(child._executeInEditMode, true, 'should inherit executeInEditMode from base component');
strictEqual(child._playOnFocus, true, 'should inherit playOnFocus from base component');
});
test('_isOnLoadCalled', function () {
var Comp = cc.Class({
extends: cc.Component,
onLoad: function () {
this.updateSprite();
},
updateSprite: function () {
equal(!!this._isOnLoadCalled, false, 'it should be false during onLoad');
},
});
var node = new cc.Node();
cc.director.getScene().addChild(node);
var comp = node.addComponent(Comp);
equal(!!comp._isOnLoadCalled, true, 'it should be true after onLoad');
});