ende 0.4.20 → 0.4.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/build/build.css +111 -0
- data/component.json +1 -0
- data/lib/assets/javascripts/aura/extensions/models.js.coffee.erb +4 -13
- data/lib/assets/javascripts/aura/extensions/platform.js.coffee +2 -8
- data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +21 -10
- data/lib/assets/javascripts/aura/extensions/states.js.coffee +25 -27
- data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +28 -23
- data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +21 -34
- data/lib/assets/javascripts/aura/extensions/widget/napable.js.coffee +17 -13
- data/lib/assets/javascripts/config/load_components.js.coffee +5 -7
- data/lib/assets/javascripts/widgets/dialog/main.js.coffee +1 -2
- data/lib/assets/javascripts/widgets/list/presenter.js.coffee +5 -4
- data/lib/assets/javascripts/widgets/support/adapters/olark.js +1 -1
- data/lib/assets/javascripts/widgets/tray/main.js.coffee +16 -22
- data/lib/assets/javascripts/widgets/viewer/main.js.coffee +39 -102
- data/lib/assets/javascripts/widgets/viewer/plugins/scopable.js.coffee +7 -1
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/ende_build.js +5732 -1047
- data/vendor/components/indefinido-indemma/build/development.js +2 -2
- data/vendor/components/indefinido-indemma/build/release.js +9 -4
- data/vendor/components/indefinido-indemma/build/test.js +115 -21916
- data/vendor/components/indefinido-indemma/component.json +0 -1
- data/vendor/components/indefinido-indemma/lib/record/restfulable.js +7 -2
- data/vendor/components/indefinido-indemma/lib/record/validatable.js +2 -2
- data/vendor/components/indefinido-indemma/src/lib/record/persistable.coffee +2 -0
- data/vendor/components/indefinido-indemma/src/lib/record/resource.coffee +3 -2
- data/vendor/components/indefinido-indemma/src/lib/record/restfulable.coffee +16 -4
- data/vendor/components/indefinido-indemma/src/lib/record/validatable.coffee +3 -3
- data/vendor/components/indefinido-observable/.gitignore +15 -0
- data/vendor/components/indefinido-observable/.ruby-gemset +1 -0
- data/vendor/components/indefinido-observable/.ruby-version +1 -0
- data/vendor/components/indefinido-observable/Gemfile +13 -0
- data/vendor/components/indefinido-observable/Guardfile +39 -0
- data/vendor/components/indefinido-observable/History.md +0 -0
- data/vendor/components/indefinido-observable/Readme.md +116 -0
- data/vendor/components/indefinido-observable/build/build.js +14798 -0
- data/vendor/components/indefinido-observable/build/development.js +339 -0
- data/vendor/components/indefinido-observable/build/release.js +14937 -0
- data/vendor/components/indefinido-observable/build/test.js +339 -0
- data/vendor/components/indefinido-observable/component.json +7 -3
- data/vendor/components/indefinido-observable/components/chaijs-chai/component.json +46 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/index.js +1 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/assertion.js +132 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/core/assertions.js +1270 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/error.js +60 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/assert.js +1060 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/expect.js +12 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/should.js +76 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +94 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addMethod.js +37 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addProperty.js +40 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/eql.js +124 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/flag.js +32 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getActual.js +19 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +25 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getMessage.js +49 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getName.js +20 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getPathValue.js +102 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getProperties.js +35 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/index.js +108 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/inspect.js +316 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/objDisplay.js +48 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +51 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +54 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/test.js +26 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/transferFlags.js +44 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/type.js +45 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai.js +79 -0
- data/vendor/components/indefinido-observable/components/cjohansen-sinon/sinon.js +4290 -0
- data/vendor/components/indefinido-observable/components/component-jquery/component.json +14 -0
- data/vendor/components/indefinido-observable/components/component-jquery/index.js +9601 -0
- data/vendor/components/indefinido-observable/components/kapit-observe-shim/component.json +11 -0
- data/vendor/components/indefinido-observable/components/kapit-observe-utils/component.json +13 -0
- data/vendor/components/indefinido-observable/karma.conf.js +92 -0
- data/vendor/components/indefinido-observable/lib/observable.js +9 -19
- data/vendor/components/indefinido-observable/spec/legacy/observable_spec.js +126 -0
- data/vendor/components/indefinido-observable/spec/observable_spec.js +92 -0
- data/vendor/components/indefinido-observable/spec/spec_helper.js +8 -0
- data/vendor/components/indefinido-observable/spec/vendor/accessors_spec.js +63 -0
- data/vendor/components/indefinido-observable/src/lib/adapters/rivets.js.coffee +15 -0
- data/vendor/components/indefinido-observable/src/spec/legacy/observable_spec.coffee +132 -0
- data/vendor/components/indefinido-observable/src/spec/observable_spec.coffee +85 -0
- data/vendor/components/indefinido-observable/src/spec/spec_helper.coffee +5 -0
- data/vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee +59 -0
- data/vendor/components/indefinido-observable/vendor/spec/boot.js +104 -0
- data/vendor/components/indefinido-observable/vendor/spec/jasmine.js +2054 -0
- metadata +60 -8
- data/lib/assets/javascripts/aura/extensions/domain.js.coffee +0 -55
- data/lib/assets/javascripts/aura/extensions/stamps.js.coffee +0 -35
- data/lib/assets/javascripts/aura/extensions/widget/composable.js.coffee +0 -135
- data/lib/assets/javascripts/aura/extensions/widget/flowable.js.coffee +0 -65
- data/lib/assets/javascripts/widgets/attachable/main.js.coffee +0 -77
- /data/{lib/assets/javascripts/aura/extensions/stamps → vendor/assets/javascripts/stampit}/stampit.js +0 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"name": "observe-shim",
|
3
|
+
"version": "0.1.1",
|
4
|
+
"main": "lib/observe-shim.js",
|
5
|
+
"devDependencies": {
|
6
|
+
"mocha": "~1.8.x",
|
7
|
+
"expect": "~0.2.0",
|
8
|
+
"sinon": "http://sinonjs.org/releases/sinon-1.6.0.js"
|
9
|
+
},
|
10
|
+
"repo": "https://raw.github.com/kapit/observe-shim"
|
11
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"name": "observe-utils",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"main": "lib/observe-utils.js",
|
5
|
+
"devDependencies": {
|
6
|
+
"expect": "~0.2.0",
|
7
|
+
"sinon": "http://sinonjs.org/releases/sinon-1.6.0.js",
|
8
|
+
"observe-shim": "https://github.com/KapIT/observe-shim.git",
|
9
|
+
"mocha": "~1.8.1",
|
10
|
+
"es5-shim": "~2.0.8"
|
11
|
+
},
|
12
|
+
"repo": "https://raw.github.com/kapit/observe-utils"
|
13
|
+
}
|
@@ -0,0 +1,92 @@
|
|
1
|
+
// Karma configuration
|
2
|
+
|
3
|
+
module.exports = function(config) {
|
4
|
+
config.set({
|
5
|
+
// base path, that will be used to resolve files and exclude
|
6
|
+
basePath: '',
|
7
|
+
|
8
|
+
// list of files / patterns to load in the browser
|
9
|
+
files: [
|
10
|
+
|
11
|
+
// Test environment
|
12
|
+
//MOCHA, Switch to mocha when not testing ie
|
13
|
+
//MOCHA_ADAPTER,
|
14
|
+
JASMINE,
|
15
|
+
JASMINE_ADAPTER,
|
16
|
+
'components/cjohansen-sinon/sinon.js',
|
17
|
+
|
18
|
+
// Test dependencies
|
19
|
+
'build/test.js',
|
20
|
+
|
21
|
+
// Test Source files
|
22
|
+
'spec/spec_helper.js',
|
23
|
+
'spec/**/*.js'
|
24
|
+
],
|
25
|
+
|
26
|
+
|
27
|
+
// list of files to exclude
|
28
|
+
exclude: [
|
29
|
+
'spec/coverage'
|
30
|
+
],
|
31
|
+
|
32
|
+
// Custom frameworks
|
33
|
+
frameworks: ['jasmine'],
|
34
|
+
|
35
|
+
|
36
|
+
// test results reporter to use
|
37
|
+
// possible values: 'dots', 'progress', 'junit'
|
38
|
+
reporters: ['progress'], // , 'coverage'],
|
39
|
+
|
40
|
+
|
41
|
+
// web server port
|
42
|
+
port: 9876,
|
43
|
+
|
44
|
+
|
45
|
+
// cli runner port
|
46
|
+
runnerPort: 9100,
|
47
|
+
|
48
|
+
|
49
|
+
// enable / disable colors in the output (reporters and logs)
|
50
|
+
colors: true,
|
51
|
+
|
52
|
+
|
53
|
+
// level of logging
|
54
|
+
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
|
55
|
+
logLevel: LOG_INFO,
|
56
|
+
|
57
|
+
|
58
|
+
// enable / disable watching file and executing tests whenever any file changes
|
59
|
+
autoWatch: true,
|
60
|
+
|
61
|
+
|
62
|
+
// Start these browsers, currently available:
|
63
|
+
// - Chrome
|
64
|
+
// - ChromeCanary
|
65
|
+
// - Firefox
|
66
|
+
// - Opera
|
67
|
+
// - Safari (only Mac)
|
68
|
+
// - PhantomJS
|
69
|
+
// - IE (only Windows)
|
70
|
+
browsers: ['Chrome'],
|
71
|
+
|
72
|
+
|
73
|
+
// If browser does not capture in given timeout [ms], kill it
|
74
|
+
captureTimeout: 60000,
|
75
|
+
|
76
|
+
|
77
|
+
// Continuous Integration mode
|
78
|
+
// if true, it capture browsers, run tests and exit
|
79
|
+
singleRun: false,
|
80
|
+
|
81
|
+
// Coverage preprocessors
|
82
|
+
// preprocessors: {
|
83
|
+
// '**/lib/*.js': 'coverage'
|
84
|
+
// },
|
85
|
+
|
86
|
+
// Converage configuration
|
87
|
+
coverageReporter: {
|
88
|
+
type : 'html',
|
89
|
+
dir : 'spec/coverage'
|
90
|
+
}
|
91
|
+
});
|
92
|
+
}
|
@@ -223,31 +223,21 @@ generator = {
|
|
223
223
|
},
|
224
224
|
|
225
225
|
observable_for: function (object) {
|
226
|
-
var toJSON;
|
227
|
-
|
228
226
|
Object.defineProperty(object, 'observed', {
|
229
227
|
configurable: true,
|
230
228
|
enumerable: false,
|
231
229
|
value: {}
|
232
230
|
});
|
233
231
|
|
234
|
-
// TODO
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
// TODO remove underscore dependency
|
244
|
-
// TODO ? move toJSON and observed to other methods
|
245
|
-
json = toJSON.apply(this, arguments);
|
246
|
-
return observable.unobserve(_.omit(json, observable.ignores, ['toJSON', 'observed']));
|
247
|
-
}
|
248
|
-
});
|
249
|
-
|
250
|
-
}
|
232
|
+
// TODO call the current object.toJSON after this method
|
233
|
+
return Object.defineProperty(object, 'toJSON', {
|
234
|
+
enumerable: false,
|
235
|
+
value: function () {
|
236
|
+
// TODO remove underscore dependency
|
237
|
+
return observable.unobserve(_.omit(this, observable.ignores));
|
238
|
+
// old_to_json()
|
239
|
+
}
|
240
|
+
});
|
251
241
|
},
|
252
242
|
|
253
243
|
// TODO improve readability
|
@@ -0,0 +1,126 @@
|
|
1
|
+
var $, observable, root;
|
2
|
+
|
3
|
+
observable = require('observable').mixin;
|
4
|
+
|
5
|
+
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
6
|
+
|
7
|
+
$ = require('jquery');
|
8
|
+
|
9
|
+
describe('observable #()', function() {
|
10
|
+
var object;
|
11
|
+
|
12
|
+
object = null;
|
13
|
+
beforeEach(function() {
|
14
|
+
return object = {
|
15
|
+
property: 'value'
|
16
|
+
};
|
17
|
+
});
|
18
|
+
it('should not have observed property', function() {
|
19
|
+
return expect(object.observed).toBeUndefined();
|
20
|
+
});
|
21
|
+
xit('should let element unsubscribe to property', function() {});
|
22
|
+
describe('#subscribe', function() {
|
23
|
+
var called;
|
24
|
+
|
25
|
+
called = null;
|
26
|
+
beforeEach(function() {
|
27
|
+
object = observable({});
|
28
|
+
called = false;
|
29
|
+
return true;
|
30
|
+
});
|
31
|
+
it('should subscribe to property', function() {
|
32
|
+
var spy;
|
33
|
+
|
34
|
+
spy = sinon.spy();
|
35
|
+
object.subscribe('other', spy);
|
36
|
+
object.other = 'mafagafo';
|
37
|
+
return expect(spy.called).toBe(true);
|
38
|
+
});
|
39
|
+
it('should let multiple function subscriptions to property', function() {
|
40
|
+
var also_also_called, also_called;
|
41
|
+
|
42
|
+
also_called = false;
|
43
|
+
also_also_called = false;
|
44
|
+
object.subscribe('other', function() {
|
45
|
+
return called = true;
|
46
|
+
});
|
47
|
+
object.subscribe('other', function() {
|
48
|
+
return also_called = true;
|
49
|
+
});
|
50
|
+
object.subscribe('other', function() {
|
51
|
+
return also_also_called = true;
|
52
|
+
});
|
53
|
+
object.other = 'mafagafo';
|
54
|
+
expect(called).toBe(true);
|
55
|
+
return expect(also_called).toBe(true);
|
56
|
+
});
|
57
|
+
it('should handle truth comparisons well', function() {
|
58
|
+
var block_called, spy;
|
59
|
+
|
60
|
+
spy = sinon.spy;
|
61
|
+
block_called = false;
|
62
|
+
object.invert = true;
|
63
|
+
object.truthy = true;
|
64
|
+
object.falsey = false;
|
65
|
+
object.subscribe('truthy', spy);
|
66
|
+
object.subscribe('falsey', spy);
|
67
|
+
object.subscribe('invert', spy);
|
68
|
+
block_called = false;
|
69
|
+
if (object.truthy) {
|
70
|
+
block_called = true;
|
71
|
+
}
|
72
|
+
expect(block_called).toBe(true);
|
73
|
+
block_called = false;
|
74
|
+
if (!object.falsey) {
|
75
|
+
block_called = true;
|
76
|
+
}
|
77
|
+
expect(block_called).toBe(true);
|
78
|
+
block_called = false;
|
79
|
+
if (object.invert) {
|
80
|
+
block_called = true;
|
81
|
+
}
|
82
|
+
object.invert = false;
|
83
|
+
block_called = false;
|
84
|
+
if (object.invert === false) {
|
85
|
+
block_called = true;
|
86
|
+
}
|
87
|
+
return expect(block_called).toBe(true);
|
88
|
+
});
|
89
|
+
describe('subscribes to properties of type array', function() {
|
90
|
+
it('should observe objects added to array', function() {
|
91
|
+
var friend, spy;
|
92
|
+
|
93
|
+
spy = sinon.spy();
|
94
|
+
friend = {
|
95
|
+
domo: 1
|
96
|
+
};
|
97
|
+
object.friends = [];
|
98
|
+
object.subscribe('friends', function() {});
|
99
|
+
object.friends = [friend];
|
100
|
+
friend = object.friends[0];
|
101
|
+
expect(friend.domo).toBeDefined();
|
102
|
+
expect(friend.observed).toBeDefined();
|
103
|
+
friend.subscribe('domo', spy);
|
104
|
+
friend.domo = 2;
|
105
|
+
return expect(spy.callCount).toBe(1);
|
106
|
+
});
|
107
|
+
it('should override native methods');
|
108
|
+
return it('should preserve array bindings when setting new array', function() {
|
109
|
+
var spy;
|
110
|
+
|
111
|
+
spy = sinon.spy();
|
112
|
+
object.friends = [];
|
113
|
+
object.subscribe('friends', spy);
|
114
|
+
object.friends.push(1);
|
115
|
+
object.friends = [];
|
116
|
+
object.friends.push(2);
|
117
|
+
expect(object.friends.length).toBe(1);
|
118
|
+
return expect(spy.callCount).toBe(3);
|
119
|
+
});
|
120
|
+
});
|
121
|
+
return it('should create a observed property', function() {});
|
122
|
+
});
|
123
|
+
return xdescribe('#publish', function() {
|
124
|
+
return xit('should let element publish to property', function() {});
|
125
|
+
});
|
126
|
+
});
|
@@ -0,0 +1,92 @@
|
|
1
|
+
var observable, root;
|
2
|
+
|
3
|
+
observable = require('observable').mixin;
|
4
|
+
|
5
|
+
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
6
|
+
|
7
|
+
describe('observable #()', function() {
|
8
|
+
var object;
|
9
|
+
|
10
|
+
if (!root.should) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
object = null;
|
14
|
+
beforeEach(function() {
|
15
|
+
return object = {
|
16
|
+
property: 'value'
|
17
|
+
};
|
18
|
+
});
|
19
|
+
it('should not have observed property', function() {
|
20
|
+
return object.should.not.have.property('observed');
|
21
|
+
});
|
22
|
+
xit('should let element unsubscribe to property', function() {});
|
23
|
+
describe('#subscribe', function() {
|
24
|
+
var called;
|
25
|
+
|
26
|
+
called = null;
|
27
|
+
beforeEach(function() {
|
28
|
+
object = observable({});
|
29
|
+
called = false;
|
30
|
+
return true;
|
31
|
+
});
|
32
|
+
it('should subscribe to property', function() {
|
33
|
+
var spy;
|
34
|
+
|
35
|
+
spy = sinon.spy();
|
36
|
+
object.subscribe('other', spy);
|
37
|
+
object.other = 'mafagafo';
|
38
|
+
return spy.called.should.be["true"];
|
39
|
+
});
|
40
|
+
it('should let multiple function subscriptions to property', function() {
|
41
|
+
var also_called;
|
42
|
+
|
43
|
+
also_called = false;
|
44
|
+
object.subscribe('other', function() {
|
45
|
+
return called = true;
|
46
|
+
});
|
47
|
+
object.subscribe('other', function() {
|
48
|
+
return also_called = true;
|
49
|
+
});
|
50
|
+
object.other = 'mafagafo';
|
51
|
+
called.should.be["true"];
|
52
|
+
return also_called.should.be["true"];
|
53
|
+
});
|
54
|
+
describe('subscribes to properties of type array', function() {
|
55
|
+
it('should observe objects added to array', function() {
|
56
|
+
var friend, spy;
|
57
|
+
|
58
|
+
spy = sinon.spy();
|
59
|
+
friend = {
|
60
|
+
domo: 1
|
61
|
+
};
|
62
|
+
object.friends = [];
|
63
|
+
object.subscribe('friends', function() {});
|
64
|
+
object.friends = [friend];
|
65
|
+
object.friends[0].should.be.eq(friend);
|
66
|
+
friend.should.have.property('observed');
|
67
|
+
friend.subscribe('domo', spy);
|
68
|
+
friend.domo = 2;
|
69
|
+
return spy.callCount.should.be.eq(1);
|
70
|
+
});
|
71
|
+
xit('should override native methods');
|
72
|
+
return it('should preserve array bindings when setting new array', function() {
|
73
|
+
var spy;
|
74
|
+
|
75
|
+
spy = sinon.spy();
|
76
|
+
object.friends = [];
|
77
|
+
object.subscribe('friends', spy);
|
78
|
+
object.friends.push(1);
|
79
|
+
object.friends = [];
|
80
|
+
object.friends.push(2);
|
81
|
+
object.friends.length.should.be.eq(1);
|
82
|
+
return spy.callCount.should.be.eq(3);
|
83
|
+
});
|
84
|
+
});
|
85
|
+
return it('should create a observed property', function() {
|
86
|
+
return object.should.have.property('observed');
|
87
|
+
});
|
88
|
+
});
|
89
|
+
return xdescribe('#publish', function() {
|
90
|
+
return xit('should let element publish to property', function() {});
|
91
|
+
});
|
92
|
+
});
|
@@ -0,0 +1,63 @@
|
|
1
|
+
var $;
|
2
|
+
|
3
|
+
require('observable/vendor/shims/accessors.js');
|
4
|
+
|
5
|
+
$ = require('jquery');
|
6
|
+
|
7
|
+
describe('Object #defineProperty', function() {
|
8
|
+
describe('on dom elements', function() {
|
9
|
+
var object, spy;
|
10
|
+
|
11
|
+
spy = object = null;
|
12
|
+
beforeEach(function() {
|
13
|
+
object = document.createElement('domo');
|
14
|
+
document.body.appendChild(object);
|
15
|
+
return spy = sinon.spy();
|
16
|
+
});
|
17
|
+
it('should define property', function(done) {
|
18
|
+
return Object.defineProperty(object, 'kun', {});
|
19
|
+
});
|
20
|
+
it('should define property getter', function(done) {
|
21
|
+
var getter;
|
22
|
+
|
23
|
+
getter = sinon.stub().returns(42);
|
24
|
+
Object.defineProperty(object, 'kun', {
|
25
|
+
get: getter
|
26
|
+
});
|
27
|
+
expect(object.kun + 1).toBe(43);
|
28
|
+
return expect(getter.called).toBe(true);
|
29
|
+
});
|
30
|
+
return it('should define property setter', function(done) {
|
31
|
+
Object.defineProperty(object, 'kun', {
|
32
|
+
set: spy
|
33
|
+
});
|
34
|
+
object.kun = 10;
|
35
|
+
return expect(spy.calledWith(10)).toBe(true);
|
36
|
+
});
|
37
|
+
});
|
38
|
+
return describe('off dom elements', function() {
|
39
|
+
beforeEach(function() {
|
40
|
+
this.object = {};
|
41
|
+
return this.spy = sinon.spy();
|
42
|
+
});
|
43
|
+
it('should not define property setter', function(done) {
|
44
|
+
var _this = this;
|
45
|
+
|
46
|
+
return expect(function() {
|
47
|
+
return Object.defineProperty(_this.object, 'kun', {
|
48
|
+
set: _this.spy
|
49
|
+
});
|
50
|
+
}).toThrow();
|
51
|
+
});
|
52
|
+
return it('should define property getter', function(done) {
|
53
|
+
var getter;
|
54
|
+
|
55
|
+
getter = sinon.stub().returns(42);
|
56
|
+
Object.defineProperty(this.object, 'kun', {
|
57
|
+
get: getter
|
58
|
+
});
|
59
|
+
expect(this.object.kun + 1).toBe(43);
|
60
|
+
return expect(getter.called).toBe(true);
|
61
|
+
});
|
62
|
+
});
|
63
|
+
});
|
@@ -0,0 +1,15 @@
|
|
1
|
+
exports.adapter =
|
2
|
+
subscribe: (record, attribute_path, callback) ->
|
3
|
+
throw new TypeError 'observable.adapters.rivets.subscribe: No record provided for subscription' unless record?
|
4
|
+
# TODO parse aura widget attributes options, remove, add as a
|
5
|
+
# comentary, and let rivets bindings flow, and remove the if check
|
6
|
+
record.subscribe attribute_path, callback if attribute_path
|
7
|
+
unsubscribe: (record, attribute_path, callback) ->
|
8
|
+
throw new TypeError 'observable.adapters.rivets.unsubscribe: No record provided for subscription' unless record?
|
9
|
+
record.unsubscribe attribute_path, callback
|
10
|
+
read: (record, attribute_path) ->
|
11
|
+
throw new TypeError 'observable.adapters.rivets.read: No record provided for subscription' unless record?
|
12
|
+
record[attribute_path]
|
13
|
+
publish: (record, attribute_path, value) ->
|
14
|
+
throw new TypeError 'observable.adapters.rivets.publish: No record provided for subscription' unless record?
|
15
|
+
record[attribute_path] = value
|
@@ -0,0 +1,132 @@
|
|
1
|
+
observable = require('observable').mixin
|
2
|
+
root = exports ? window
|
3
|
+
$ = require 'jquery'
|
4
|
+
|
5
|
+
describe 'observable #()', ->
|
6
|
+
|
7
|
+
object = null
|
8
|
+
|
9
|
+
beforeEach ->
|
10
|
+
object = property: 'value'
|
11
|
+
|
12
|
+
it 'should not have observed property', ->
|
13
|
+
expect(object.observed).toBeUndefined()
|
14
|
+
|
15
|
+
xit 'should let element unsubscribe to property', ->
|
16
|
+
|
17
|
+
describe '#subscribe', ->
|
18
|
+
called = null
|
19
|
+
|
20
|
+
beforeEach ->
|
21
|
+
object = observable({})
|
22
|
+
called = false
|
23
|
+
true
|
24
|
+
|
25
|
+
it 'should subscribe to property', ->
|
26
|
+
spy = sinon.spy()
|
27
|
+
object.subscribe 'other', spy
|
28
|
+
object.other = 'mafagafo'
|
29
|
+
|
30
|
+
expect(spy.called).toBe true
|
31
|
+
|
32
|
+
|
33
|
+
it 'should let multiple function subscriptions to property', ->
|
34
|
+
also_called = false
|
35
|
+
also_also_called = false
|
36
|
+
|
37
|
+
object.subscribe 'other', -> called = true
|
38
|
+
|
39
|
+
object.subscribe 'other', -> also_called = true
|
40
|
+
|
41
|
+
object.subscribe 'other', -> also_also_called = true
|
42
|
+
|
43
|
+
object.other = 'mafagafo'
|
44
|
+
|
45
|
+
expect(called).toBe true
|
46
|
+
expect(also_called).toBe true
|
47
|
+
|
48
|
+
it 'should handle truth comparisons well', ->
|
49
|
+
spy = sinon.spy
|
50
|
+
block_called = false
|
51
|
+
object.invert = true
|
52
|
+
object.truthy = true
|
53
|
+
object.falsey = false
|
54
|
+
|
55
|
+
object.subscribe 'truthy', spy
|
56
|
+
object.subscribe 'falsey' , spy
|
57
|
+
object.subscribe 'invert', spy
|
58
|
+
|
59
|
+
block_called = false
|
60
|
+
if object.truthy
|
61
|
+
# dump 'truthy'
|
62
|
+
block_called = true
|
63
|
+
|
64
|
+
expect(block_called).toBe true
|
65
|
+
|
66
|
+
block_called = false
|
67
|
+
# dump (object.falsey + '') == 'false'
|
68
|
+
unless object.falsey
|
69
|
+
# dump 'falsey'
|
70
|
+
block_called = true
|
71
|
+
|
72
|
+
expect(block_called).toBe true
|
73
|
+
|
74
|
+
block_called = false
|
75
|
+
if object.invert
|
76
|
+
# dump 'invert'
|
77
|
+
block_called = true
|
78
|
+
|
79
|
+
object.invert = false
|
80
|
+
|
81
|
+
block_called = false
|
82
|
+
if object.invert == false
|
83
|
+
# dump 'inverted'
|
84
|
+
block_called = true
|
85
|
+
|
86
|
+
expect(block_called).toBe true
|
87
|
+
|
88
|
+
|
89
|
+
describe 'subscribes to properties of type array', ->
|
90
|
+
it 'should observe objects added to array', ->
|
91
|
+
spy = sinon.spy()
|
92
|
+
friend = {domo: 1}
|
93
|
+
|
94
|
+
# TODO implement a one time setter to solve this
|
95
|
+
# Specifically on array types
|
96
|
+
# property must be an array before subscribing
|
97
|
+
object.friends = []
|
98
|
+
|
99
|
+
# Remember, you must subscribe to new properties to
|
100
|
+
# turn then into observable ones
|
101
|
+
object.subscribe 'friends', ->
|
102
|
+
|
103
|
+
object.friends = [friend]
|
104
|
+
friend = object.friends[0]
|
105
|
+
|
106
|
+
expect(friend.domo ).toBeDefined()
|
107
|
+
expect(friend.observed).toBeDefined()
|
108
|
+
|
109
|
+
friend.subscribe 'domo', spy
|
110
|
+
friend.domo = 2
|
111
|
+
expect(spy.callCount).toBe 1
|
112
|
+
|
113
|
+
it 'should override native methods'
|
114
|
+
|
115
|
+
it 'should preserve array bindings when setting new array', ->
|
116
|
+
spy = sinon.spy()
|
117
|
+
object.friends = []
|
118
|
+
object.subscribe 'friends', spy
|
119
|
+
|
120
|
+
object.friends.push 1
|
121
|
+
object.friends = []
|
122
|
+
object.friends.push 2
|
123
|
+
|
124
|
+
expect(object.friends.length).toBe 1
|
125
|
+
expect(spy.callCount).toBe 3
|
126
|
+
|
127
|
+
it 'should create a observed property', ->
|
128
|
+
# object.should.have.property 'observed'
|
129
|
+
|
130
|
+
xdescribe '#publish', ->
|
131
|
+
|
132
|
+
xit 'should let element publish to property', ->
|
@@ -0,0 +1,85 @@
|
|
1
|
+
observable = require('observable').mixin
|
2
|
+
root = exports ? window
|
3
|
+
|
4
|
+
describe 'observable #()', ->
|
5
|
+
return unless root.should
|
6
|
+
|
7
|
+
object = null
|
8
|
+
|
9
|
+
beforeEach ->
|
10
|
+
object = property: 'value'
|
11
|
+
|
12
|
+
it 'should not have observed property', ->
|
13
|
+
object.should.not.have.property 'observed'
|
14
|
+
|
15
|
+
xit 'should let element unsubscribe to property', ->
|
16
|
+
|
17
|
+
describe '#subscribe', ->
|
18
|
+
called = null
|
19
|
+
|
20
|
+
beforeEach ->
|
21
|
+
object = observable({})
|
22
|
+
called = false
|
23
|
+
true
|
24
|
+
|
25
|
+
it 'should subscribe to property', ->
|
26
|
+
spy = sinon.spy()
|
27
|
+
object.subscribe 'other', spy
|
28
|
+
|
29
|
+
object.other = 'mafagafo'
|
30
|
+
spy.called.should.be.true
|
31
|
+
|
32
|
+
it 'should let multiple function subscriptions to property', ->
|
33
|
+
also_called = false
|
34
|
+
|
35
|
+
object.subscribe 'other', -> called = true
|
36
|
+
|
37
|
+
object.subscribe 'other', -> also_called = true
|
38
|
+
|
39
|
+
object.other = 'mafagafo'
|
40
|
+
called.should.be.true
|
41
|
+
also_called.should.be.true
|
42
|
+
|
43
|
+
describe 'subscribes to properties of type array', ->
|
44
|
+
it 'should observe objects added to array', ->
|
45
|
+
spy = sinon.spy()
|
46
|
+
friend = {domo: 1}
|
47
|
+
|
48
|
+
# TODO implement a one time setter to solve this
|
49
|
+
# Specifically on array types
|
50
|
+
# property must be an array before subscribing
|
51
|
+
object.friends = []
|
52
|
+
|
53
|
+
# Remember, you must subscribe to new properties to
|
54
|
+
# turn then into observable ones
|
55
|
+
object.subscribe 'friends', ->
|
56
|
+
|
57
|
+
object.friends = [friend]
|
58
|
+
|
59
|
+
object.friends[0].should.be.eq friend
|
60
|
+
friend.should.have.property 'observed'
|
61
|
+
|
62
|
+
friend.subscribe 'domo', spy
|
63
|
+
friend.domo = 2
|
64
|
+
spy.callCount.should.be.eq 1
|
65
|
+
|
66
|
+
xit 'should override native methods'
|
67
|
+
it 'should preserve array bindings when setting new array', ->
|
68
|
+
spy = sinon.spy()
|
69
|
+
object.friends = []
|
70
|
+
object.subscribe 'friends', spy
|
71
|
+
|
72
|
+
object.friends.push 1
|
73
|
+
object.friends = []
|
74
|
+
object.friends.push 2
|
75
|
+
|
76
|
+
object.friends.length.should.be.eq 1
|
77
|
+
spy.callCount.should.be.eq 3
|
78
|
+
|
79
|
+
|
80
|
+
it 'should create a observed property', ->
|
81
|
+
object.should.have.property 'observed'
|
82
|
+
|
83
|
+
xdescribe '#publish', ->
|
84
|
+
|
85
|
+
xit 'should let element publish to property', ->
|