1 |
|
2 |
|
3 |
|
4 | process.chdir('./app');
|
5 |
|
6 | var assert = require('assert')
|
7 | ,Kernel = require('../kernel/kernel.js')
|
8 | ,krnl = new Kernel({ foo : 'bar' })
|
9 | ,beating = false;
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | assert.strictEqual(krnl.config.foo, 'bar');
|
15 | console.log(krnl.utility.ansi('green', '[ OK ]') + ' config merge');
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | var cls = krnl.include(krnl.appdir + '/models/dummy');
|
21 | assert.ok(typeof cls.new === 'function');
|
22 | assert.ok(typeof cls.singleton === 'function');
|
23 | assert.ok(typeof cls.extends === 'function');
|
24 | assert.ok(typeof cls.module === 'function');
|
25 | assert.ok(typeof cls.prototype === 'object');
|
26 | assert.ok(typeof cls.context === 'object');
|
27 | console.log(krnl.utility.ansi('green', '[ OK ]') + ' kernel include');
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | var obj = cls.new();
|
33 | assert.ok(obj.kernel instanceof Kernel);
|
34 | console.log(krnl.utility.ansi('green', '[ OK ]') + ' kernel bind');
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | var Instanceinc = krnl.include(krnl.kerneldir + '/instance')
|
40 | ,Instance = Instanceinc.module
|
41 | ,inst = Instanceinc.singleton()
|
42 | ,cls = inst.model('dummy');
|
43 |
|
44 | assert.ok(typeof cls.new === 'function');
|
45 | assert.ok(typeof cls.singleton === 'function');
|
46 | assert.ok(typeof cls.extends === 'function');
|
47 | assert.ok(typeof cls.module === 'function');
|
48 | assert.ok(typeof cls.prototype === 'object');
|
49 | assert.ok(typeof cls.context === 'object');
|
50 | console.log(krnl.utility.ansi('green', '[ OK ]') + ' instance include');
|
51 |
|
52 | var obj = cls.new();
|
53 | assert.ok(obj.instance instanceof Instance);
|
54 | console.log(krnl.utility.ansi('green', '[ OK ]') + ' instance bind');
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | krnl.once(krnl.HEARTBEAT, function() {
|
60 | beating = true;
|
61 | });
|
62 | setTimeout(function() {
|
63 | assert.ok(beating);
|
64 | console.log(krnl.utility.ansi('green', '[ OK ]') + ' heartbeat');
|
65 | krnl.shutdown();
|
66 | }, 1500);
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | krnl.once(krnl.OFFLINE, function() {
|
72 | beating = false;
|
73 | });
|
74 | setTimeout(function() {
|
75 | assert.ok(!beating);
|
76 | console.log(krnl.utility.ansi('green', '[ OK ]') + ' shutdown');
|
77 | }, 5000); |
\ | No newline at end of file |