Skip to content

Commit 6c7022c

Browse files
committed
Add tests
1 parent 0de37da commit 6c7022c

File tree

3 files changed

+71
-23
lines changed

3 files changed

+71
-23
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,18 @@ With System Runtime your components really behave the way you designed them.
125125
Clone the repository:
126126

127127
```sh
128-
# Clone the repository
129128
$ git clone https://github.com/design-first/system-runtime.git
130-
# Go to the repository
131-
$ cd system-runtime
132129
```
133130

134-
Once you have cloned the repository:
131+
Once you have cloned the repository, install the dependencies:
135132

136133
```sh
137-
# install dependencies
138134
$ npm i
139135
```
140136

141137
#### Build
142138

143-
To build System Runtime:
139+
Then build System Runtime:
144140

145141
```sh
146142
$ npm run build

test/module/db-spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@ describe('a db module', function () {
8282
expect(result1.length + result2.length).toBe(0);
8383
});
8484

85+
it('can export the database', function () {
86+
var result = null;
87+
88+
result = db.exportSystem();
89+
90+
expect(result).toBeDefined();
91+
});
92+
93+
94+
it('can apply a filter on the export', function () {
95+
var result = null;
96+
97+
result = db.exportSystem({ 'schemas': { 'name': 'Person' } })
98+
99+
expect(result).toBeDefined();
100+
});
101+
85102
it('can init the database', function () {
86103
var result = null;
87104

test/runtime/component-spec.js

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ describe('a component', function () {
1212
metamodel.schema({
1313
'_name': 'Person',
1414
'_inherit': ['_Component'],
15-
'children': 'collection',
1615
'firstName': 'property',
1716
'lastName': 'property',
17+
'address': 'property',
18+
'likes': 'property',
19+
'children': 'collection',
1820
'father': 'link',
19-
'adress': 'property',
2021
'moving': 'event'
2122
});
2223

@@ -41,13 +42,19 @@ describe('a component', function () {
4142
'mandatory': true,
4243
'default': ''
4344
},
45+
'likes': {
46+
'type': 'array',
47+
'readOnly': false,
48+
'mandatory': false,
49+
'default': []
50+
},
4451
'father': {
4552
'type': 'Person',
4653
'readOnly': false,
4754
'mandatory': false,
4855
'default': {}
4956
},
50-
'adress': {
57+
'address': {
5158
'type': 'string',
5259
'readOnly': false,
5360
'mandatory': false,
@@ -79,16 +86,17 @@ describe('a component', function () {
7986
var Person = runtime.require('Person');
8087
var yoda = new Person({
8188
'firstName': 'Yoda',
82-
'lastName': 'Master'
89+
'lastName': 'Master',
90+
'likes': ['teaching']
8391
});
8492

8593
yoda.on('moving', function () {
86-
this.adress('Dagobah');
94+
this.address('Dagobah');
8795
});
8896
yoda.moving();
8997

9098
setTimeout(function () {
91-
expect(yoda.adress()).toBe('Dagobah');
99+
expect(yoda.address()).toBe('Dagobah');
92100
done();
93101
}, 1);
94102
});
@@ -101,14 +109,14 @@ describe('a component', function () {
101109
});
102110

103111
yoda.on('moving', function () {
104-
this.adress('Dagobah');
112+
this.address('Dagobah');
105113
});
106114
yoda.off('moving');
107115

108116
yoda.moving();
109117

110118
setTimeout(function () {
111-
expect(yoda.adress()).toBe('');
119+
expect(yoda.address()).toBe('');
112120
done();
113121
}, 1);
114122
});
@@ -121,14 +129,14 @@ describe('a component', function () {
121129
});
122130

123131
yoda2.on('moving', function () {
124-
this.adress('Dagobah');
132+
this.address('Dagobah');
125133
});
126134
yoda2.off();
127135

128136
yoda2.moving();
129137

130138
setTimeout(function () {
131-
expect(yoda2.adress()).toBe('');
139+
expect(yoda2.address()).toBe('');
132140
done();
133141
}, 1);
134142
});
@@ -141,15 +149,15 @@ describe('a component', function () {
141149
});
142150

143151
var behaviorId = yoda3.on('moving', function () {
144-
this.adress('Dagobah');
152+
this.address('Dagobah');
145153
});
146154

147155
yoda3.require(behaviorId).destroy();
148156

149157
yoda3.moving();
150158

151159
setTimeout(function () {
152-
expect(yoda3.adress()).toBe('');
160+
expect(yoda3.address()).toBe('');
153161
done();
154162
}, 1);
155163
});
@@ -162,13 +170,13 @@ describe('a component', function () {
162170
})
163171

164172
yoda.on('lastName', function (val) {
165-
this.adress('Dagobah');
173+
this.address('Dagobah');
166174
});
167175

168176
yoda.lastName('Grand Jedi Master');
169177

170178
setTimeout(function () {
171-
expect(yoda.adress()).toBe('Dagobah');
179+
expect(yoda.address()).toBe('Dagobah');
172180
done();
173181
}, 1);
174182
});
@@ -181,15 +189,15 @@ describe('a component', function () {
181189
})
182190

183191
yoda.on('lastName', function (val) {
184-
this.adress('Dagobah');
192+
this.address('Dagobah');
185193
});
186194

187195
yoda.off('lastName');
188196

189197
yoda.lastName('Grand Jedi Master');
190198

191199
setTimeout(function () {
192-
expect(yoda.adress()).toBe('');
200+
expect(yoda.address()).toBe('');
193201
done();
194202
}, 1);
195203
});
@@ -357,7 +365,21 @@ describe('a component', function () {
357365
expect(anakin.children().pop().id()).toBe(luke.id());
358366
});
359367

360-
it('can add a item of a collection with push', function () {
368+
it('can remove an item of an array property with pop', function () {
369+
var Person = runtime.require('Person');
370+
371+
var luke = new Person({
372+
'firstName': 'Luke',
373+
'lastName': 'Skywalker',
374+
'likes': ['saying noooooo!']
375+
});
376+
377+
luke.likes().pop();
378+
379+
expect(luke.likes().length).toBe(0);
380+
});
381+
382+
it('can add an item of a collection with push', function () {
361383
var Person = runtime.require('Person');
362384

363385
var luke = new Person({
@@ -375,6 +397,19 @@ describe('a component', function () {
375397
expect(anakin.children(0).id()).toBe(luke.id());
376398
});
377399

400+
it('can add an item of an array property with push', function () {
401+
var Person = runtime.require('Person');
402+
403+
var luke = new Person({
404+
'firstName': 'Luke',
405+
'lastName': 'Skywalker'
406+
});
407+
408+
luke.likes().push('saying nooooooo!');
409+
410+
expect(luke.likes().length).toBe(1);
411+
});
412+
378413
it('can clear a collection with api', function () {
379414
var Person = runtime.require('Person');
380415

0 commit comments

Comments
 (0)