neo.mjs 2.3.17 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/apps/covid/Util.mjs +1 -3
- package/apps/covid/view/GalleryContainer.mjs +2 -3
- package/apps/covid/view/GalleryContainerController.mjs +1 -5
- package/apps/covid/view/HelixContainer.mjs +2 -3
- package/apps/covid/view/HelixContainerController.mjs +1 -4
- package/apps/covid/view/MainContainerController.mjs +0 -7
- package/apps/covid/view/MainContainerModel.mjs +0 -1
- package/apps/covid/view/TableContainer.mjs +2 -3
- package/apps/covid/view/TableContainerController.mjs +0 -3
- package/apps/covid/view/WorldMapComponent.mjs +1 -2
- package/apps/covid/view/WorldMapContainerController.mjs +0 -2
- package/apps/covid/view/country/Gallery.mjs +0 -2
- package/apps/covid/view/country/Helix.mjs +0 -3
- package/apps/covid/view/mapboxGl/Container.mjs +1 -1
- package/apps/covid/view/mapboxGl/ContainerController.mjs +1 -6
- package/apps/krausest/TableCollection.mjs +0 -1
- package/apps/krausest/view/MainComponent.mjs +2 -3
- package/apps/krausest/view/MainComponentController.mjs +0 -1
- package/apps/krausest/view/TableComponent.mjs +2 -4
- package/apps/realworld/api/Article.mjs +1 -4
- package/apps/realworld/api/Base.mjs +0 -5
- package/apps/realworld/api/Favorite.mjs +1 -3
- package/apps/realworld/api/Profile.mjs +1 -3
- package/apps/realworld/view/HeaderComponent.mjs +1 -2
- package/apps/realworld/view/HomeComponent.mjs +2 -11
- package/apps/realworld/view/MainContainerController.mjs +0 -13
- package/apps/realworld/view/article/CommentComponent.mjs +3 -5
- package/apps/realworld/view/article/Component.mjs +2 -7
- package/apps/realworld/view/article/CreateCommentComponent.mjs +3 -7
- package/apps/realworld/view/article/CreateComponent.mjs +3 -3
- package/apps/realworld/view/article/PreviewComponent.mjs +3 -5
- package/apps/realworld/view/article/TagListComponent.mjs +3 -7
- package/apps/realworld/view/user/ProfileComponent.mjs +2 -8
- package/apps/realworld/view/user/SettingsComponent.mjs +3 -7
- package/apps/realworld/view/user/SignUpComponent.mjs +2 -3
- package/apps/realworld2/api/Article.mjs +1 -4
- package/apps/realworld2/api/Base.mjs +0 -5
- package/apps/realworld2/api/Favorite.mjs +1 -3
- package/apps/realworld2/api/Profile.mjs +1 -3
- package/apps/realworld2/view/HeaderToolbarController.mjs +1 -2
- package/apps/realworld2/view/HomeContainer.mjs +1 -2
- package/apps/realworld2/view/MainContainerController.mjs +1 -14
- package/apps/realworld2/view/article/Gallery.mjs +1 -3
- package/apps/realworld2/view/article/GalleryContainer.mjs +1 -2
- package/apps/realworld2/view/article/Helix.mjs +1 -3
- package/apps/realworld2/view/article/HelixContainer.mjs +3 -5
- package/apps/realworld2/view/article/PreviewComponent.mjs +3 -5
- package/apps/realworld2/view/article/TagListComponent.mjs +3 -7
- package/apps/realworld2/view/user/LoginFormContainer.mjs +3 -4
- package/apps/sharedcovid/Util.mjs +1 -3
- package/apps/sharedcovid/view/GalleryContainer.mjs +2 -3
- package/apps/sharedcovid/view/GalleryContainerController.mjs +1 -5
- package/apps/sharedcovid/view/HelixContainer.mjs +2 -3
- package/apps/sharedcovid/view/HelixContainerController.mjs +1 -4
- package/apps/sharedcovid/view/MainContainerController.mjs +12 -16
- package/apps/sharedcovid/view/MainContainerModel.mjs +0 -1
- package/apps/sharedcovid/view/TableContainer.mjs +2 -3
- package/apps/sharedcovid/view/TableContainerController.mjs +0 -3
- package/apps/sharedcovid/view/WorldMapComponent.mjs +1 -2
- package/apps/sharedcovid/view/WorldMapContainerController.mjs +0 -2
- package/apps/sharedcovid/view/country/Gallery.mjs +0 -2
- package/apps/sharedcovid/view/country/Helix.mjs +0 -3
- package/apps/sharedcovid/view/mapboxGl/Container.mjs +2 -3
- package/apps/sharedcovid/view/mapboxGl/ContainerController.mjs +1 -5
- package/apps/shareddialog/view/MainContainerController.mjs +0 -18
- package/apps/shareddialog2/view/MainContainerController.mjs +1 -2
- package/apps/website/data/blog.json +13 -0
- package/apps/website/view/MainContainerController.mjs +0 -4
- package/docs/app/view/ContentTabContainer.mjs +2 -2
- package/docs/app/view/MainContainer.mjs +2 -2
- package/docs/app/view/classdetails/SourceViewComponent.mjs +2 -2
- package/docs/app/view/classdetails/TutorialComponent.mjs +2 -2
- package/docs/tutorials/02_ClassSystem.html +3 -3
- package/docs/tutorials/02_ClassSystem.md +2 -2
- package/docs/tutorials/09_TodoList_version1.html +8 -8
- package/examples/ConfigurationViewport.mjs +0 -4
- package/examples/calendar/basic/MainContainerController.mjs +0 -1
- package/examples/calendar/weekview/MainContainer.mjs +2 -2
- package/examples/component/coronaGallery/CountryGallery.mjs +1 -4
- package/examples/component/coronaGallery/MainContainer.mjs +2 -4
- package/examples/component/coronaHelix/CountryHelix.mjs +0 -4
- package/examples/component/coronaHelix/MainContainer.mjs +2 -4
- package/examples/component/gallery/MainContainer.mjs +2 -4
- package/examples/component/helix/MainContainer.mjs +2 -4
- package/examples/component/splitter/MainContainer.mjs +0 -2
- package/examples/core/config/MainContainer.mjs +3 -5
- package/examples/dialog/MainContainer.mjs +3 -7
- package/examples/list/animate/MainContainer.mjs +2 -2
- package/examples/model/advanced/MainContainerController.mjs +0 -12
- package/examples/model/dialog/EditUserDialogController.mjs +1 -3
- package/examples/model/dialog/MainContainerController.mjs +1 -2
- package/examples/model/extendedClass/MainContainerController.mjs +0 -7
- package/examples/model/inline/MainContainerController.mjs +0 -7
- package/examples/model/inlineNoModel/MainContainerController.mjs +1 -6
- package/examples/model/multiWindow/EditUserDialogController.mjs +1 -3
- package/examples/model/multiWindow/MainContainerController.mjs +1 -3
- package/examples/model/multiWindow/ViewportController.mjs +3 -5
- package/examples/model/nestedData/MainContainerController.mjs +1 -8
- package/examples/tab/container/MainContainer.mjs +1 -6
- package/examples/todoList/version1/MainComponent.mjs +3 -3
- package/examples/todoList/version2/MainContainer.mjs +3 -3
- package/examples/todoList/version2/TodoList.mjs +1 -1
- package/examples/tree/MainContainer.mjs +0 -2
- package/package.json +7 -7
- package/src/Main.mjs +9 -18
- package/src/Neo.mjs +26 -26
- package/src/button/Menu.mjs +0 -1
- package/src/button/Split.mjs +2 -6
- package/src/calendar/store/Events.mjs +0 -1
- package/src/calendar/view/DayComponent.mjs +0 -1
- package/src/calendar/view/EditEventContainer.mjs +2 -9
- package/src/calendar/view/MainContainer.mjs +2 -17
- package/src/calendar/view/MainContainerModel.mjs +2 -4
- package/src/calendar/view/SettingsContainer.mjs +2 -6
- package/src/calendar/view/YearComponent.mjs +3 -14
- package/src/calendar/view/calendars/Container.mjs +0 -1
- package/src/calendar/view/calendars/EditContainer.mjs +2 -7
- package/src/calendar/view/calendars/List.mjs +0 -5
- package/src/calendar/view/month/Component.mjs +3 -17
- package/src/calendar/view/settings/GeneralContainer.mjs +0 -3
- package/src/calendar/view/settings/MonthContainer.mjs +0 -3
- package/src/calendar/view/settings/WeekContainer.mjs +0 -5
- package/src/calendar/view/settings/YearContainer.mjs +0 -3
- package/src/calendar/view/week/Component.mjs +3 -22
- package/src/calendar/view/week/EventDragZone.mjs +1 -6
- package/src/calendar/view/week/TimeAxisComponent.mjs +2 -3
- package/src/calendar/view/week/plugin/DragDrop.mjs +2 -12
- package/src/calendar/view/week/plugin/EventResizable.mjs +0 -3
- package/src/collection/Base.mjs +3 -22
- package/src/collection/Filter.mjs +0 -1
- package/src/collection/Sorter.mjs +0 -3
- package/src/component/Base.mjs +14 -3
- package/src/component/Chip.mjs +2 -4
- package/src/component/Circle.mjs +2 -20
- package/src/component/DateSelector.mjs +4 -21
- package/src/component/Gallery.mjs +2 -14
- package/src/component/Helix.mjs +2 -16
- package/src/component/Splitter.mjs +3 -8
- package/src/component/mwc/Button.mjs +2 -2
- package/src/component/mwc/TextField.mjs +2 -3
- package/src/component/wrapper/AmChart.mjs +1 -1
- package/src/component/wrapper/MapboxGL.mjs +0 -5
- package/src/container/Base.mjs +1 -7
- package/src/container/Panel.mjs +2 -5
- package/src/controller/Application.mjs +2 -3
- package/src/controller/Base.mjs +2 -3
- package/src/controller/Component.mjs +3 -6
- package/src/core/Base.mjs +26 -3
- package/src/core/Compare.mjs +0 -1
- package/src/core/IdGenerator.mjs +2 -4
- package/src/core/Observable.mjs +0 -3
- package/src/core/Util.mjs +0 -1
- package/src/core/_export.mjs +1 -2
- package/src/data/RecordFactory.mjs +1 -6
- package/src/data/Store.mjs +2 -12
- package/src/data/connection/Xhr.mjs +0 -6
- package/src/dialog/Base.mjs +5 -24
- package/src/draggable/DragProxyComponent.mjs +3 -5
- package/src/draggable/DragZone.mjs +2 -8
- package/src/draggable/DropZone.mjs +3 -9
- package/src/draggable/list/DragZone.mjs +3 -9
- package/src/draggable/tab/header/toolbar/SortZone.mjs +1 -3
- package/src/draggable/toolbar/DragZone.mjs +3 -7
- package/src/draggable/toolbar/SortZone.mjs +1 -8
- package/src/draggable/tree/DragZone.mjs +1 -4
- package/src/filter/BooleanContainer.mjs +0 -1
- package/src/filter/NumberContainer.mjs +0 -2
- package/src/filter/ToggleOperatorsButton.mjs +3 -5
- package/src/form/Container.mjs +0 -2
- package/src/form/Fieldset.mjs +0 -1
- package/src/form/field/Base.mjs +0 -2
- package/src/form/field/CheckBox.mjs +2 -7
- package/src/form/field/Color.mjs +2 -5
- package/src/form/field/Date.mjs +2 -6
- package/src/form/field/Display.mjs +2 -3
- package/src/form/field/Picker.mjs +1 -12
- package/src/form/field/Range.mjs +2 -3
- package/src/form/field/Select.mjs +24 -22
- package/src/form/field/Text.mjs +3 -20
- package/src/form/field/Time.mjs +2 -9
- package/src/form/field/trigger/Base.mjs +2 -4
- package/src/form/field/trigger/Clear.mjs +0 -3
- package/src/form/field/trigger/CopyToClipboard.mjs +0 -3
- package/src/form/field/trigger/Picker.mjs +0 -1
- package/src/form/field/trigger/SpinDown.mjs +0 -1
- package/src/form/field/trigger/SpinUp.mjs +0 -1
- package/src/form/field/trigger/SpinUpDown.mjs +0 -1
- package/src/form/field/trigger/Time.mjs +2 -3
- package/src/grid/Container.mjs +3 -6
- package/src/grid/header/Toolbar.mjs +1 -5
- package/src/list/Base.mjs +2 -2
- package/src/list/Color.mjs +0 -3
- package/src/list/Component.mjs +0 -3
- package/src/list/plugin/Animate.mjs +3 -6
- package/src/main/DomAccess.mjs +9 -24
- package/src/main/DomEvents.mjs +44 -77
- package/src/main/addon/AmCharts.mjs +3 -12
- package/src/main/addon/AnalyticsByGoogle.mjs +3 -4
- package/src/main/addon/CloneNode.mjs +0 -2
- package/src/main/addon/Cookie.mjs +0 -3
- package/src/main/addon/DragDrop.mjs +2 -11
- package/src/main/addon/HighlightJS.mjs +3 -7
- package/src/main/addon/MapboxGL.mjs +4 -16
- package/src/main/addon/Markdown.mjs +3 -3
- package/src/main/addon/Mwc.mjs +0 -2
- package/src/main/addon/Siesta.mjs +2 -3
- package/src/main/addon/Stylesheet.mjs +2 -6
- package/src/main/addon/WindowPosition.mjs +3 -8
- package/src/main/draggable/sensor/Mouse.mjs +2 -6
- package/src/main/draggable/sensor/Touch.mjs +2 -6
- package/src/main/mixin/DeltaUpdates.mjs +0 -8
- package/src/main/mixin/TouchDomEvents.mjs +1 -7
- package/src/manager/Base.mjs +0 -2
- package/src/manager/Component.mjs +2 -5
- package/src/manager/DomEvent.mjs +1 -6
- package/src/manager/Focus.mjs +0 -7
- package/src/manager/Instance.mjs +2 -3
- package/src/manager/Store.mjs +0 -4
- package/src/menu/List.mjs +4 -18
- package/src/model/Component.mjs +2 -3
- package/src/plugin/Base.mjs +2 -3
- package/src/plugin/Resizable.mjs +4 -15
- package/src/selection/CircleModel.mjs +1 -5
- package/src/selection/DateSelectorModel.mjs +1 -9
- package/src/selection/GalleryModel.mjs +0 -9
- package/src/selection/HelixModel.mjs +0 -9
- package/src/selection/ListModel.mjs +0 -8
- package/src/selection/Model.mjs +0 -8
- package/src/selection/menu/ListModel.mjs +0 -2
- package/src/selection/table/CellColumnModel.mjs +2 -6
- package/src/selection/table/CellColumnRowModel.mjs +2 -6
- package/src/selection/table/CellModel.mjs +0 -8
- package/src/selection/table/CellRowModel.mjs +2 -8
- package/src/selection/table/ColumnModel.mjs +0 -6
- package/src/selection/table/RowModel.mjs +0 -5
- package/src/tab/Container.mjs +0 -6
- package/src/tab/Strip.mjs +1 -3
- package/src/tab/header/Button.mjs +1 -2
- package/src/tab/header/Toolbar.mjs +0 -1
- package/src/table/Container.mjs +2 -10
- package/src/table/View.mjs +0 -4
- package/src/table/header/Button.mjs +2 -8
- package/src/table/header/Toolbar.mjs +1 -2
- package/src/tree/List.mjs +0 -4
- package/src/util/Css.mjs +0 -1
- package/src/util/Date.mjs +0 -2
- package/src/util/Function.mjs +0 -2
- package/src/util/HashHistory.mjs +0 -3
- package/src/util/KeyNavigation.mjs +0 -5
- package/src/{core → util}/Logger.mjs +7 -19
- package/src/util/Matrix.mjs +0 -3
- package/src/util/VDom.mjs +0 -5
- package/src/util/_export.mjs +2 -1
- package/src/vdom/Helper.mjs +0 -3
- package/src/vdom/VNode.mjs +0 -1
- package/src/worker/App.mjs +2 -9
- package/src/worker/Base.mjs +2 -8
- package/src/worker/Canvas.mjs +0 -2
- package/src/worker/Manager.mjs +3 -5
- package/src/worker/Message.mjs +0 -1
- package/src/worker/mixin/RemoteMethodAccess.mjs +0 -3
- package/test/siesta/siesta.js +2 -1
- package/test/siesta/tests/ClassConfigsAndFields.mjs +307 -0
- package/test/siesta/tests/ClassSystem.mjs +1 -1
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import Neo from '../../../src/Neo.mjs';
|
|
2
|
+
import * as core from '../../../src/core/_export.mjs';
|
|
3
|
+
|
|
4
|
+
class TestClass extends core.Base {
|
|
5
|
+
fieldA = 1;
|
|
6
|
+
fieldB = 2;
|
|
7
|
+
|
|
8
|
+
static getConfig() {return {
|
|
9
|
+
className: 'Neo.TestClass',
|
|
10
|
+
configA_ : 3,
|
|
11
|
+
configB_ : 4
|
|
12
|
+
}}
|
|
13
|
+
|
|
14
|
+
beforeSetConfigA(value) {
|
|
15
|
+
return this.fieldA + value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
beforeSetConfigB(value) {
|
|
19
|
+
return this.fieldB + value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Neo.applyClassConfig(TestClass);
|
|
24
|
+
|
|
25
|
+
StartTest(t => {
|
|
26
|
+
t.it('Default class fields inside constructors', t => {
|
|
27
|
+
t.diag("Default class");
|
|
28
|
+
|
|
29
|
+
class CtorTest {
|
|
30
|
+
fieldA = 1;
|
|
31
|
+
fieldB = 2;
|
|
32
|
+
|
|
33
|
+
constructor() {
|
|
34
|
+
t.isStrict(this.fieldA, 1, 'fieldA equals ' + 1);
|
|
35
|
+
t.isStrict(this.fieldB, 2, 'fieldB equals ' + 2);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
new CtorTest();
|
|
40
|
+
|
|
41
|
+
t.diag("Default class extension");
|
|
42
|
+
|
|
43
|
+
class CtorTestExtension extends CtorTest {
|
|
44
|
+
fieldA = 3;
|
|
45
|
+
fieldB = 4;
|
|
46
|
+
|
|
47
|
+
constructor() {
|
|
48
|
+
super();
|
|
49
|
+
|
|
50
|
+
t.isStrict(this.fieldA, 3, 'fieldA equals ' + 3);
|
|
51
|
+
t.isStrict(this.fieldB, 4, 'fieldB equals ' + 4);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
new CtorTestExtension();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
t.it('Neo default class fields inside constructors', t => {
|
|
59
|
+
t.diag("Neo default class");
|
|
60
|
+
|
|
61
|
+
class NeoCtorTest extends core.Base {
|
|
62
|
+
fieldA = 1;
|
|
63
|
+
fieldB = 2;
|
|
64
|
+
|
|
65
|
+
construct(config) {
|
|
66
|
+
super.construct(config);
|
|
67
|
+
|
|
68
|
+
let me = this,
|
|
69
|
+
extension = me.extension;
|
|
70
|
+
|
|
71
|
+
t.isStrict(me.fieldA, extension ? 3 : 1, 'fieldA equals ' + (extension ? 3 : 1));
|
|
72
|
+
t.isStrict(me.fieldB, extension ? 4 : 2, 'fieldB equals ' + (extension ? 4 : 2));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
Neo.applyClassConfig(NeoCtorTest);
|
|
77
|
+
|
|
78
|
+
Neo.create(NeoCtorTest);
|
|
79
|
+
|
|
80
|
+
t.diag("Neo default class extension");
|
|
81
|
+
|
|
82
|
+
class NeoCtorTestExtension extends NeoCtorTest {
|
|
83
|
+
extension = true; // flag for the base ctor tests
|
|
84
|
+
fieldA = 3;
|
|
85
|
+
fieldB = 4;
|
|
86
|
+
|
|
87
|
+
construct(config) {
|
|
88
|
+
super.construct(config);
|
|
89
|
+
|
|
90
|
+
t.isStrict(this.fieldA, 3, 'fieldA equals ' + 3);
|
|
91
|
+
t.isStrict(this.fieldB, 4, 'fieldB equals ' + 4);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Neo.create(NeoCtorTestExtension);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
t.it('Default class fields', t => {
|
|
99
|
+
t.diag("Testing class fields");
|
|
100
|
+
|
|
101
|
+
class DefaultTestClass {
|
|
102
|
+
fieldA = 1;
|
|
103
|
+
fieldB = 2;
|
|
104
|
+
_configA = 3;
|
|
105
|
+
_configB = 4;
|
|
106
|
+
|
|
107
|
+
get configA() {
|
|
108
|
+
return this._configA;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
set configA(value) {
|
|
112
|
+
this._configA = this.fieldA + value;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get configB() {
|
|
116
|
+
return this._configB;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
set configB(value) {
|
|
120
|
+
this._configB = this.fieldB + value;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
constructor(config) {
|
|
124
|
+
Object.assign(this, config);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const instance = new DefaultTestClass({
|
|
129
|
+
fieldA : 5,
|
|
130
|
+
configA: 6,
|
|
131
|
+
configB: 7,
|
|
132
|
+
fieldB : 8
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// not consistent
|
|
136
|
+
t.isStrict(instance.configA, 11, 'configA equals 11'); // 5 + 6 => new value of fieldA + new value of configA
|
|
137
|
+
t.isStrict(instance.configB, 9, 'configB equals 9'); // 7 + 2 => old value of fieldB + new value of configB
|
|
138
|
+
t.isStrict(instance.fieldA, 5, 'fieldA equals 5');
|
|
139
|
+
t.isStrict(instance.fieldB, 8, 'fieldB equals 8');
|
|
140
|
+
|
|
141
|
+
t.diag('Reversed order');
|
|
142
|
+
|
|
143
|
+
const instance2 = new DefaultTestClass({
|
|
144
|
+
fieldB : 8, // reversed order
|
|
145
|
+
configB: 7,
|
|
146
|
+
configA: 6,
|
|
147
|
+
fieldA : 5
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// not consistent
|
|
151
|
+
t.isStrict(instance2.configA, 7, 'configA equals 7'); // 5 + 6 => old value of fieldA + new value of configA
|
|
152
|
+
t.isStrict(instance2.configB, 15, 'configB equals 15'); // 8 + 7 => new value of fieldB + new value of configB
|
|
153
|
+
t.isStrict(instance2.fieldA, 5, 'fieldA equals 5');
|
|
154
|
+
t.isStrict(instance2.fieldB, 8, 'fieldB equals 8');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
t.it('Class based class configs and fields', t => {
|
|
158
|
+
t.diag("Testing class based values");
|
|
159
|
+
|
|
160
|
+
const instance = Neo.create({
|
|
161
|
+
className: 'Neo.TestClass'
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
t.isStrict(instance.configA, 4, 'configA equals 4'); // 1 + 3
|
|
165
|
+
t.isStrict(instance.configB, 6, 'configB equals 6'); // 2 + 4
|
|
166
|
+
t.isStrict(instance.fieldA, 1, 'fieldA equals 1');
|
|
167
|
+
t.isStrict(instance.fieldB, 2, 'fieldB equals 2');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
t.it('Instance based class configs and fields', t => {
|
|
171
|
+
t.diag("Testing values which got set on instance level");
|
|
172
|
+
|
|
173
|
+
const instance = Neo.create({
|
|
174
|
+
className: 'Neo.TestClass',
|
|
175
|
+
fieldA : 5,
|
|
176
|
+
configA : 6,
|
|
177
|
+
configB : 7,
|
|
178
|
+
fieldB : 8
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
t.isStrict(instance.configA, 11, 'configA equals 11'); // 5 + 6
|
|
182
|
+
t.isStrict(instance.configB, 15, 'configB equals 15'); // 8 + 7
|
|
183
|
+
t.isStrict(instance.fieldA, 5, 'fieldA equals 5');
|
|
184
|
+
t.isStrict(instance.fieldB, 8, 'fieldB equals 8');
|
|
185
|
+
|
|
186
|
+
t.diag('Reversed order');
|
|
187
|
+
|
|
188
|
+
const instance2 = Neo.create({
|
|
189
|
+
className: 'Neo.TestClass',
|
|
190
|
+
fieldB : 8, // reversed order
|
|
191
|
+
configB : 7,
|
|
192
|
+
configA : 6,
|
|
193
|
+
fieldA : 5
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
t.isStrict(instance2.configA, 11, 'configA equals 11'); // 5 + 6
|
|
197
|
+
t.isStrict(instance2.configB, 15, 'configB equals 15'); // 8 + 7
|
|
198
|
+
t.isStrict(instance2.fieldA, 5, 'fieldA equals 5');
|
|
199
|
+
t.isStrict(instance2.fieldB, 8, 'fieldB equals 8');
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
t.it('Dynamically changed class configs and fields', t => {
|
|
203
|
+
t.diag("Testing instance.set()");
|
|
204
|
+
|
|
205
|
+
const instance = Neo.create({
|
|
206
|
+
className: 'Neo.TestClass'
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
instance.set({
|
|
210
|
+
fieldA : 5,
|
|
211
|
+
configA: 6,
|
|
212
|
+
configB: 7,
|
|
213
|
+
fieldB : 8
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
t.isStrict(instance.configA, 11, 'configA equals 11'); // 5 + 6
|
|
217
|
+
t.isStrict(instance.configB, 15, 'configB equals 15'); // 8 + 7
|
|
218
|
+
t.isStrict(instance.fieldA, 5, 'fieldA equals 5');
|
|
219
|
+
t.isStrict(instance.fieldB, 8, 'fieldB equals 8');
|
|
220
|
+
|
|
221
|
+
t.diag('Reversed order');
|
|
222
|
+
|
|
223
|
+
const instance2 = Neo.create({
|
|
224
|
+
className: 'Neo.TestClass'
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
instance2.set({
|
|
228
|
+
fieldB : 8, // reversed order
|
|
229
|
+
configB: 7,
|
|
230
|
+
configA: 6,
|
|
231
|
+
fieldA : 5
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
t.isStrict(instance2.configA, 11, 'configA equals 11'); // 5 + 6
|
|
235
|
+
t.isStrict(instance2.configB, 15, 'configB equals 15'); // 8 + 7
|
|
236
|
+
t.isStrict(instance2.fieldA, 5, 'fieldA equals 5');
|
|
237
|
+
t.isStrict(instance2.fieldB, 8, 'fieldB equals 8');
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
t.it('Advanced configs and fields example', t => {
|
|
241
|
+
class AdvancedClass extends core.Base {
|
|
242
|
+
fieldA = 2;
|
|
243
|
+
fieldB = 1;
|
|
244
|
+
|
|
245
|
+
static getConfig() {return {
|
|
246
|
+
configA_: 0,
|
|
247
|
+
configB_: 0,
|
|
248
|
+
configC_: 0
|
|
249
|
+
}}
|
|
250
|
+
|
|
251
|
+
afterSetConfigA(value, oldValue) {
|
|
252
|
+
let me = this,
|
|
253
|
+
sum = me.fieldA === 1 ? 21 : 6;
|
|
254
|
+
|
|
255
|
+
t.isStrict(me.configA + me.configB + me.configC + me.fieldA + me.fieldB, sum, `sum equals ${sum}`);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
afterSetConfigC(value, oldValue) {
|
|
259
|
+
let me = this,
|
|
260
|
+
sum = me.fieldA === 1 ? 21 : 6;
|
|
261
|
+
|
|
262
|
+
t.isStrict(me.configA + me.configB + me.configC + me.fieldA + me.fieldB, sum, `sum equals ${sum}`);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
beforeSetConfigA(value) {
|
|
266
|
+
return this.fieldA + value;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
beforeSetConfigB(value) {
|
|
270
|
+
let me = this,
|
|
271
|
+
sum = me.fieldA === 1 ? 21 : 6;
|
|
272
|
+
|
|
273
|
+
t.isStrict(me.configA + me.configB + me.configC + me.fieldA + me.fieldB, sum, `sum equals ${sum}`);
|
|
274
|
+
|
|
275
|
+
return value;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
beforeSetConfigC(value) {
|
|
279
|
+
return this.fieldB + value;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
Neo.applyClassConfig(AdvancedClass);
|
|
284
|
+
|
|
285
|
+
let instance = Neo.create(AdvancedClass);
|
|
286
|
+
|
|
287
|
+
instance.set({
|
|
288
|
+
fieldA : 1,
|
|
289
|
+
configA: 2,
|
|
290
|
+
configB: 3,
|
|
291
|
+
configC: 4,
|
|
292
|
+
fieldB : 5
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
t.diag('Reversed order');
|
|
296
|
+
|
|
297
|
+
let instance2 = Neo.create(AdvancedClass);
|
|
298
|
+
|
|
299
|
+
instance2.set({
|
|
300
|
+
fieldB : 5,
|
|
301
|
+
configC: 4,
|
|
302
|
+
configB: 3,
|
|
303
|
+
configA: 2,
|
|
304
|
+
fieldA : 1
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
});
|