bpm 1.0.0.beta.5 → 1.0.0.beta.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/TODO.md +18 -17
- data/lib/bpm/pipeline/generated_asset.rb +64 -41
- data/lib/bpm/pipeline/plugin_context.rb +24 -0
- data/lib/bpm/pipeline/transport_processor.rb +3 -3
- data/lib/bpm/pipeline.rb +2 -1
- data/lib/bpm/project.rb +7 -1
- data/lib/bpm/version.rb +1 -1
- data/lib/bpm.rb +1 -0
- data/spec/fixtures/projects/minitest/minitest.json +4 -2
- data/spec/fixtures/projects/minitest/packages/uglyduck/minifier/main.js +3 -2
- data/spec/fixtures/projects/minitrans/lib/main.js +3 -0
- data/spec/fixtures/projects/minitrans/minitrans.json +25 -0
- data/spec/fixtures/projects/minitrans/packages/transport/lib/main.js +1 -0
- data/spec/fixtures/projects/minitrans/packages/transport/package.json +21 -0
- data/spec/fixtures/projects/minitrans/packages/transport/transports/wrapper.js +6 -0
- data/spec/fixtures/projects/minitrans/packages/uglyduck/lib/main.js +3 -0
- data/spec/fixtures/projects/minitrans/packages/uglyduck/minifier/main.js +6 -0
- data/spec/fixtures/projects/minitrans/packages/uglyduck/package.json +21 -0
- data/spec/fixtures/projects/transporter/packages/transport/transports/wrapper.js +2 -2
- data/spec/plugins/minifier_spec.rb +2 -2
- data/spec/plugins/transport_spec.rb +38 -0
- metadata +41 -56
- data/backbone/LICENSE +0 -22
- data/backbone/README +0 -25
- data/backbone/Rakefile +0 -42
- data/backbone/backbone-0.5.1.bpkg +0 -0
- data/backbone/examples/backbone-localstorage.js +0 -84
- data/backbone/examples/todos/destroy.png +0 -0
- data/backbone/examples/todos/index.html +0 -87
- data/backbone/examples/todos/todos.css +0 -311
- data/backbone/examples/todos/todos.js +0 -258
- data/backbone/index.html +0 -2606
- data/backbone/index.js +0 -1
- data/backbone/lib/backbone.js +0 -1149
- data/backbone/lib/index.js +0 -1
- data/backbone/package.json +0 -14
- data/backbone/test/collection.js +0 -345
- data/backbone/test/events.js +0 -70
- data/backbone/test/model.coffee +0 -43
- data/backbone/test/model.js +0 -424
- data/backbone/test/noconflict.js +0 -12
- data/backbone/test/router.js +0 -116
- data/backbone/test/speed.js +0 -45
- data/backbone/test/sync.js +0 -133
- data/backbone/test/test-zepto.html +0 -30
- data/backbone/test/test.html +0 -31
- data/backbone/test/vendor/jquery-1.5.js +0 -8176
- data/backbone/test/vendor/jslitmus.js +0 -649
- data/backbone/test/vendor/json2.js +0 -481
- data/backbone/test/vendor/qunit.css +0 -196
- data/backbone/test/vendor/qunit.js +0 -1364
- data/backbone/test/vendor/underscore-1.1.6.js +0 -807
- data/backbone/test/vendor/zepto-0.6.js +0 -692
- data/backbone/test/view.js +0 -137
data/backbone/test/model.js
DELETED
@@ -1,424 +0,0 @@
|
|
1
|
-
$(document).ready(function() {
|
2
|
-
|
3
|
-
module("Backbone.Model");
|
4
|
-
|
5
|
-
// Variable to catch the last request.
|
6
|
-
window.lastRequest = null;
|
7
|
-
|
8
|
-
window.originalSync = Backbone.sync;
|
9
|
-
|
10
|
-
// Stub out Backbone.request...
|
11
|
-
Backbone.sync = function() {
|
12
|
-
lastRequest = _.toArray(arguments);
|
13
|
-
};
|
14
|
-
|
15
|
-
var attrs = {
|
16
|
-
id : '1-the-tempest',
|
17
|
-
title : "The Tempest",
|
18
|
-
author : "Bill Shakespeare",
|
19
|
-
length : 123
|
20
|
-
};
|
21
|
-
|
22
|
-
var proxy = Backbone.Model.extend();
|
23
|
-
var doc = new proxy(attrs);
|
24
|
-
|
25
|
-
var klass = Backbone.Collection.extend({
|
26
|
-
url : function() { return '/collection'; }
|
27
|
-
});
|
28
|
-
|
29
|
-
var collection = new klass();
|
30
|
-
collection.add(doc);
|
31
|
-
|
32
|
-
test("Model: initialize", function() {
|
33
|
-
var Model = Backbone.Model.extend({
|
34
|
-
initialize: function() {
|
35
|
-
this.one = 1;
|
36
|
-
equals(this.collection, collection);
|
37
|
-
}
|
38
|
-
});
|
39
|
-
var model = new Model({}, {collection: collection});
|
40
|
-
equals(model.one, 1);
|
41
|
-
equals(model.collection, collection);
|
42
|
-
});
|
43
|
-
|
44
|
-
test("Model: initialize with attributes and options", function() {
|
45
|
-
var Model = Backbone.Model.extend({
|
46
|
-
initialize: function(attributes, options) {
|
47
|
-
this.one = options.one;
|
48
|
-
}
|
49
|
-
});
|
50
|
-
var model = new Model({}, {one: 1});
|
51
|
-
equals(model.one, 1);
|
52
|
-
});
|
53
|
-
|
54
|
-
test("Model: url", function() {
|
55
|
-
equals(doc.url(), '/collection/1-the-tempest');
|
56
|
-
doc.collection.url = '/collection/';
|
57
|
-
equals(doc.url(), '/collection/1-the-tempest');
|
58
|
-
doc.collection = null;
|
59
|
-
var failed = false;
|
60
|
-
try {
|
61
|
-
doc.url();
|
62
|
-
} catch (e) {
|
63
|
-
failed = true;
|
64
|
-
}
|
65
|
-
equals(failed, true);
|
66
|
-
doc.collection = collection;
|
67
|
-
});
|
68
|
-
|
69
|
-
test("Model: url when using urlRoot, and uri encoding", function() {
|
70
|
-
var Model = Backbone.Model.extend({
|
71
|
-
urlRoot: '/collection'
|
72
|
-
});
|
73
|
-
var model = new Model();
|
74
|
-
equals(model.url(), '/collection');
|
75
|
-
model.set({id: '+1+'});
|
76
|
-
equals(model.url(), '/collection/%2B1%2B');
|
77
|
-
});
|
78
|
-
|
79
|
-
test("Model: clone", function() {
|
80
|
-
attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
|
81
|
-
a = new Backbone.Model(attrs);
|
82
|
-
b = a.clone();
|
83
|
-
equals(a.get('foo'), 1);
|
84
|
-
equals(a.get('bar'), 2);
|
85
|
-
equals(a.get('baz'), 3);
|
86
|
-
equals(b.get('foo'), a.get('foo'), "Foo should be the same on the clone.");
|
87
|
-
equals(b.get('bar'), a.get('bar'), "Bar should be the same on the clone.");
|
88
|
-
equals(b.get('baz'), a.get('baz'), "Baz should be the same on the clone.");
|
89
|
-
a.set({foo : 100});
|
90
|
-
equals(a.get('foo'), 100);
|
91
|
-
equals(b.get('foo'), 1, "Changing a parent attribute does not change the clone.");
|
92
|
-
});
|
93
|
-
|
94
|
-
test("Model: isNew", function() {
|
95
|
-
attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
|
96
|
-
a = new Backbone.Model(attrs);
|
97
|
-
ok(a.isNew(), "it should be new");
|
98
|
-
attrs = { 'foo': 1, 'bar': 2, 'baz': 3, 'id': -5 };
|
99
|
-
a = new Backbone.Model(attrs);
|
100
|
-
ok(!a.isNew(), "any defined ID is legal, negative or positive");
|
101
|
-
attrs = { 'foo': 1, 'bar': 2, 'baz': 3, 'id': 0 };
|
102
|
-
a = new Backbone.Model(attrs);
|
103
|
-
ok(!a.isNew(), "any defined ID is legal, including zero");
|
104
|
-
ok( new Backbone.Model({ }).isNew(), "is true when there is no id");
|
105
|
-
ok(!new Backbone.Model({ 'id': 2 }).isNew(), "is false for a positive integer");
|
106
|
-
ok(!new Backbone.Model({ 'id': -5 }).isNew(), "is false for a negative integer");
|
107
|
-
});
|
108
|
-
|
109
|
-
test("Model: get", function() {
|
110
|
-
equals(doc.get('title'), 'The Tempest');
|
111
|
-
equals(doc.get('author'), 'Bill Shakespeare');
|
112
|
-
});
|
113
|
-
|
114
|
-
test("Model: escape", function() {
|
115
|
-
equals(doc.escape('title'), 'The Tempest');
|
116
|
-
doc.set({audience: 'Bill & Bob'});
|
117
|
-
equals(doc.escape('audience'), 'Bill & Bob');
|
118
|
-
doc.set({audience: 'Tim > Joan'});
|
119
|
-
equals(doc.escape('audience'), 'Tim > Joan');
|
120
|
-
doc.set({audience: 10101});
|
121
|
-
equals(doc.escape('audience'), '10101');
|
122
|
-
doc.unset('audience');
|
123
|
-
equals(doc.escape('audience'), '');
|
124
|
-
});
|
125
|
-
|
126
|
-
test("Model: has", function() {
|
127
|
-
attrs = {};
|
128
|
-
a = new Backbone.Model(attrs);
|
129
|
-
equals(a.has("name"), false);
|
130
|
-
_([true, "Truth!", 1, false, '', 0]).each(function(value) {
|
131
|
-
a.set({'name': value});
|
132
|
-
equals(a.has("name"), true);
|
133
|
-
});
|
134
|
-
a.unset('name');
|
135
|
-
equals(a.has('name'), false);
|
136
|
-
_([null, undefined]).each(function(value) {
|
137
|
-
a.set({'name': value});
|
138
|
-
equals(a.has("name"), false);
|
139
|
-
});
|
140
|
-
});
|
141
|
-
|
142
|
-
test("Model: set and unset", function() {
|
143
|
-
attrs = {id: 'id', foo: 1, bar: 2, baz: 3};
|
144
|
-
a = new Backbone.Model(attrs);
|
145
|
-
var changeCount = 0;
|
146
|
-
a.bind("change:foo", function() { changeCount += 1; });
|
147
|
-
a.set({'foo': 2});
|
148
|
-
ok(a.get('foo')== 2, "Foo should have changed.");
|
149
|
-
ok(changeCount == 1, "Change count should have incremented.");
|
150
|
-
a.set({'foo': 2}); // set with value that is not new shouldn't fire change event
|
151
|
-
ok(a.get('foo')== 2, "Foo should NOT have changed, still 2");
|
152
|
-
ok(changeCount == 1, "Change count should NOT have incremented.");
|
153
|
-
|
154
|
-
a.unset('foo');
|
155
|
-
ok(a.get('foo')== null, "Foo should have changed");
|
156
|
-
ok(changeCount == 2, "Change count should have incremented for unset.");
|
157
|
-
|
158
|
-
a.unset('id');
|
159
|
-
equals(a.id, undefined, "Unsetting the id should remove the id property.");
|
160
|
-
});
|
161
|
-
|
162
|
-
test("Model: multiple unsets", function() {
|
163
|
-
var i = 0;
|
164
|
-
var counter = function(){ i++; };
|
165
|
-
var model = new Backbone.Model({a: 1});
|
166
|
-
model.bind("change:a", counter);
|
167
|
-
model.set({a: 2});
|
168
|
-
model.unset('a');
|
169
|
-
model.unset('a');
|
170
|
-
equals(i, 2, 'Unset does not fire an event for missing attributes.');
|
171
|
-
});
|
172
|
-
|
173
|
-
test("Model: using a non-default id attribute.", function() {
|
174
|
-
var MongoModel = Backbone.Model.extend({idAttribute : '_id'});
|
175
|
-
var model = new MongoModel({id: 'eye-dee', _id: 25, title: 'Model'});
|
176
|
-
equals(model.get('id'), 'eye-dee');
|
177
|
-
equals(model.id, 25);
|
178
|
-
model.unset('_id');
|
179
|
-
equals(model.id, undefined);
|
180
|
-
});
|
181
|
-
|
182
|
-
test("Model: set an empty string", function() {
|
183
|
-
var model = new Backbone.Model({name : "Model"});
|
184
|
-
model.set({name : ''});
|
185
|
-
equals(model.get('name'), '');
|
186
|
-
});
|
187
|
-
|
188
|
-
test("Model: clear", function() {
|
189
|
-
var changed;
|
190
|
-
var model = new Backbone.Model({name : "Model"});
|
191
|
-
model.bind("change:name", function(){ changed = true; });
|
192
|
-
model.clear();
|
193
|
-
equals(changed, true);
|
194
|
-
equals(model.get('name'), undefined);
|
195
|
-
});
|
196
|
-
|
197
|
-
test("Model: defaults", function() {
|
198
|
-
var Defaulted = Backbone.Model.extend({
|
199
|
-
defaults: {
|
200
|
-
"one": 1,
|
201
|
-
"two": 2
|
202
|
-
}
|
203
|
-
});
|
204
|
-
var model = new Defaulted({two: null});
|
205
|
-
equals(model.get('one'), 1);
|
206
|
-
equals(model.get('two'), null);
|
207
|
-
Defaulted = Backbone.Model.extend({
|
208
|
-
defaults: function() {
|
209
|
-
return {
|
210
|
-
"one": 3,
|
211
|
-
"two": 4
|
212
|
-
};
|
213
|
-
}
|
214
|
-
});
|
215
|
-
var model = new Defaulted({two: null});
|
216
|
-
equals(model.get('one'), 3);
|
217
|
-
equals(model.get('two'), null);
|
218
|
-
});
|
219
|
-
|
220
|
-
test("Model: change, hasChanged, changedAttributes, previous, previousAttributes", function() {
|
221
|
-
var model = new Backbone.Model({name : "Tim", age : 10});
|
222
|
-
equals(model.changedAttributes(), false);
|
223
|
-
model.bind('change', function() {
|
224
|
-
ok(model.hasChanged('name'), 'name changed');
|
225
|
-
ok(!model.hasChanged('age'), 'age did not');
|
226
|
-
ok(_.isEqual(model.changedAttributes(), {name : 'Rob'}), 'changedAttributes returns the changed attrs');
|
227
|
-
equals(model.previous('name'), 'Tim');
|
228
|
-
ok(_.isEqual(model.previousAttributes(), {name : "Tim", age : 10}), 'previousAttributes is correct');
|
229
|
-
});
|
230
|
-
model.set({name : 'Rob'}, {silent : true});
|
231
|
-
equals(model.hasChanged(), true);
|
232
|
-
equals(model.hasChanged('name'), true);
|
233
|
-
model.change();
|
234
|
-
equals(model.get('name'), 'Rob');
|
235
|
-
});
|
236
|
-
|
237
|
-
test("Model: change with options", function() {
|
238
|
-
var value;
|
239
|
-
var model = new Backbone.Model({name: 'Rob'});
|
240
|
-
model.bind('change', function(model, options) {
|
241
|
-
value = options.prefix + model.get('name');
|
242
|
-
});
|
243
|
-
model.set({name: 'Bob'}, {silent: true});
|
244
|
-
model.change({prefix: 'Mr. '});
|
245
|
-
equals(value, 'Mr. Bob');
|
246
|
-
model.set({name: 'Sue'}, {prefix: 'Ms. '});
|
247
|
-
equals(value, 'Ms. Sue');
|
248
|
-
});
|
249
|
-
|
250
|
-
test("Model: change after initialize", function () {
|
251
|
-
var changed = 0;
|
252
|
-
var attrs = {id: 1, label: 'c'};
|
253
|
-
var obj = new Backbone.Model(attrs);
|
254
|
-
obj.bind('change', function() { changed += 1; });
|
255
|
-
obj.set(attrs);
|
256
|
-
equals(changed, 0);
|
257
|
-
});
|
258
|
-
|
259
|
-
test("Model: save within change event", function () {
|
260
|
-
var model = new Backbone.Model({firstName : "Taylor", lastName: "Swift"});
|
261
|
-
model.bind('change', function () {
|
262
|
-
model.save();
|
263
|
-
ok(_.isEqual(lastRequest[1], model));
|
264
|
-
});
|
265
|
-
model.set({lastName: 'Hicks'});
|
266
|
-
});
|
267
|
-
|
268
|
-
test("Model: save", function() {
|
269
|
-
doc.save({title : "Henry V"});
|
270
|
-
equals(lastRequest[0], 'update');
|
271
|
-
ok(_.isEqual(lastRequest[1], doc));
|
272
|
-
});
|
273
|
-
|
274
|
-
test("Model: fetch", function() {
|
275
|
-
doc.fetch();
|
276
|
-
ok(lastRequest[0], 'read');
|
277
|
-
ok(_.isEqual(lastRequest[1], doc));
|
278
|
-
});
|
279
|
-
|
280
|
-
test("Model: destroy", function() {
|
281
|
-
doc.destroy();
|
282
|
-
equals(lastRequest[0], 'delete');
|
283
|
-
ok(_.isEqual(lastRequest[1], doc));
|
284
|
-
});
|
285
|
-
|
286
|
-
test("Model: non-persisted destroy", function() {
|
287
|
-
attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
|
288
|
-
a = new Backbone.Model(attrs);
|
289
|
-
a.sync = function() { throw "should not be called"; };
|
290
|
-
ok(a.destroy(), "non-persisted model should not call sync");
|
291
|
-
});
|
292
|
-
|
293
|
-
test("Model: validate", function() {
|
294
|
-
var lastError;
|
295
|
-
var model = new Backbone.Model();
|
296
|
-
model.validate = function(attrs) {
|
297
|
-
if (attrs.admin) return "Can't change admin status.";
|
298
|
-
};
|
299
|
-
model.bind('error', function(model, error) {
|
300
|
-
lastError = error;
|
301
|
-
});
|
302
|
-
var result = model.set({a: 100});
|
303
|
-
equals(result, model);
|
304
|
-
equals(model.get('a'), 100);
|
305
|
-
equals(lastError, undefined);
|
306
|
-
result = model.set({admin: true}, {silent: true});
|
307
|
-
equals(lastError, undefined);
|
308
|
-
equals(model.get('admin'), true);
|
309
|
-
result = model.set({a: 200, admin: true});
|
310
|
-
equals(result, false);
|
311
|
-
equals(model.get('a'), 100);
|
312
|
-
equals(lastError, "Can't change admin status.");
|
313
|
-
});
|
314
|
-
|
315
|
-
test("Model: validate on unset and clear", function() {
|
316
|
-
var error;
|
317
|
-
var model = new Backbone.Model({name: "One"});
|
318
|
-
model.validate = function(attrs) {
|
319
|
-
if ("name" in attrs) {
|
320
|
-
if (!attrs.name) {
|
321
|
-
error = true;
|
322
|
-
return "No thanks.";
|
323
|
-
}
|
324
|
-
}
|
325
|
-
};
|
326
|
-
model.set({name: "Two"});
|
327
|
-
equals(model.get('name'), 'Two');
|
328
|
-
equals(error, undefined);
|
329
|
-
model.unset('name');
|
330
|
-
equals(error, true);
|
331
|
-
equals(model.get('name'), 'Two');
|
332
|
-
model.clear();
|
333
|
-
equals(model.get('name'), 'Two');
|
334
|
-
delete model.validate;
|
335
|
-
model.clear();
|
336
|
-
equals(model.get('name'), undefined);
|
337
|
-
});
|
338
|
-
|
339
|
-
test("Model: validate with error callback", function() {
|
340
|
-
var lastError, boundError;
|
341
|
-
var model = new Backbone.Model();
|
342
|
-
model.validate = function(attrs) {
|
343
|
-
if (attrs.admin) return "Can't change admin status.";
|
344
|
-
};
|
345
|
-
var callback = function(model, error) {
|
346
|
-
lastError = error;
|
347
|
-
};
|
348
|
-
model.bind('error', function(model, error) {
|
349
|
-
boundError = true;
|
350
|
-
});
|
351
|
-
var result = model.set({a: 100}, {error: callback});
|
352
|
-
equals(result, model);
|
353
|
-
equals(model.get('a'), 100);
|
354
|
-
equals(lastError, undefined);
|
355
|
-
equals(boundError, undefined);
|
356
|
-
result = model.set({a: 200, admin: true}, {error: callback});
|
357
|
-
equals(result, false);
|
358
|
-
equals(model.get('a'), 100);
|
359
|
-
equals(lastError, "Can't change admin status.");
|
360
|
-
equals(boundError, undefined);
|
361
|
-
});
|
362
|
-
|
363
|
-
test("Model: defaults always extend attrs (#459)", function() {
|
364
|
-
var Defaulted = Backbone.Model.extend({
|
365
|
-
defaults: {one: 1},
|
366
|
-
initialize : function(attrs, opts) {
|
367
|
-
equals(attrs.one, 1);
|
368
|
-
}
|
369
|
-
});
|
370
|
-
var providedattrs = new Defaulted({});
|
371
|
-
var emptyattrs = new Defaulted();
|
372
|
-
});
|
373
|
-
|
374
|
-
test("Model: Inherit class properties", function() {
|
375
|
-
var Parent = Backbone.Model.extend({
|
376
|
-
instancePropSame: function() {},
|
377
|
-
instancePropDiff: function() {}
|
378
|
-
}, {
|
379
|
-
classProp: function() {}
|
380
|
-
});
|
381
|
-
var Child = Parent.extend({
|
382
|
-
instancePropDiff: function() {}
|
383
|
-
});
|
384
|
-
|
385
|
-
var adult = new Parent;
|
386
|
-
var kid = new Child;
|
387
|
-
|
388
|
-
equals(Child.classProp, Parent.classProp);
|
389
|
-
notEqual(Child.classProp, undefined);
|
390
|
-
|
391
|
-
equals(kid.instancePropSame, adult.instancePropSame);
|
392
|
-
notEqual(kid.instancePropSame, undefined);
|
393
|
-
|
394
|
-
notEqual(Child.prototype.instancePropDiff, Parent.prototype.instancePropDiff);
|
395
|
-
notEqual(Child.prototype.instancePropDiff, undefined);
|
396
|
-
});
|
397
|
-
|
398
|
-
test("Model: Nested change events don't clobber previous attributes", function() {
|
399
|
-
var A = Backbone.Model.extend({
|
400
|
-
initialize: function() {
|
401
|
-
this.bind("change:state", function(a, newState) {
|
402
|
-
equals(a.previous('state'), undefined);
|
403
|
-
equals(newState, 'hello');
|
404
|
-
// Fire a nested change event.
|
405
|
-
this.set({ other: "whatever" });
|
406
|
-
});
|
407
|
-
}
|
408
|
-
});
|
409
|
-
|
410
|
-
var B = Backbone.Model.extend({
|
411
|
-
initialize: function() {
|
412
|
-
this.get("a").bind("change:state", function(a, newState) {
|
413
|
-
equals(a.previous('state'), undefined);
|
414
|
-
equals(newState, 'hello');
|
415
|
-
});
|
416
|
-
}
|
417
|
-
});
|
418
|
-
|
419
|
-
a = new A();
|
420
|
-
b = new B({a: a});
|
421
|
-
a.set({state: 'hello'});
|
422
|
-
});
|
423
|
-
|
424
|
-
});
|
data/backbone/test/noconflict.js
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
$(document).ready(function() {
|
2
|
-
|
3
|
-
module("Backbone.noConflict");
|
4
|
-
|
5
|
-
test('Backbone.noConflict', function() {
|
6
|
-
var noconflictBackbone = Backbone.noConflict();
|
7
|
-
equals(window.Backbone, undefined, 'Returned window.Backbone');
|
8
|
-
window.Backbone = noconflictBackbone;
|
9
|
-
equals(window.Backbone, noconflictBackbone, 'Backbone is still pointing to the original Backbone');
|
10
|
-
});
|
11
|
-
|
12
|
-
});
|
data/backbone/test/router.js
DELETED
@@ -1,116 +0,0 @@
|
|
1
|
-
$(document).ready(function() {
|
2
|
-
|
3
|
-
module("Backbone.Router");
|
4
|
-
|
5
|
-
var Router = Backbone.Router.extend({
|
6
|
-
|
7
|
-
routes: {
|
8
|
-
"search/:query": "search",
|
9
|
-
"search/:query/p:page": "search",
|
10
|
-
"splat/*args/end": "splat",
|
11
|
-
"*first/complex-:part/*rest": "complex",
|
12
|
-
":entity?*args": "query",
|
13
|
-
"*anything": "anything"
|
14
|
-
},
|
15
|
-
|
16
|
-
initialize : function(options) {
|
17
|
-
this.testing = options.testing;
|
18
|
-
},
|
19
|
-
|
20
|
-
search : function(query, page) {
|
21
|
-
this.query = query;
|
22
|
-
this.page = page;
|
23
|
-
},
|
24
|
-
|
25
|
-
splat : function(args) {
|
26
|
-
this.args = args;
|
27
|
-
},
|
28
|
-
|
29
|
-
complex : function(first, part, rest) {
|
30
|
-
this.first = first;
|
31
|
-
this.part = part;
|
32
|
-
this.rest = rest;
|
33
|
-
},
|
34
|
-
|
35
|
-
query : function(entity, args) {
|
36
|
-
this.entity = entity;
|
37
|
-
this.queryArgs = args;
|
38
|
-
},
|
39
|
-
|
40
|
-
anything : function(whatever) {
|
41
|
-
this.anything = whatever;
|
42
|
-
}
|
43
|
-
|
44
|
-
});
|
45
|
-
|
46
|
-
Backbone.history = null;
|
47
|
-
var router = new Router({testing: 101});
|
48
|
-
|
49
|
-
Backbone.history.interval = 9;
|
50
|
-
Backbone.history.start({pushState: false});
|
51
|
-
|
52
|
-
test("Router: initialize", function() {
|
53
|
-
equals(router.testing, 101);
|
54
|
-
});
|
55
|
-
|
56
|
-
asyncTest("Router: routes (simple)", 2, function() {
|
57
|
-
window.location.hash = 'search/news';
|
58
|
-
setTimeout(function() {
|
59
|
-
equals(router.query, 'news');
|
60
|
-
equals(router.page, undefined);
|
61
|
-
start();
|
62
|
-
}, 10);
|
63
|
-
});
|
64
|
-
|
65
|
-
asyncTest("Router: routes (two part)", 2, function() {
|
66
|
-
window.location.hash = 'search/nyc/p10';
|
67
|
-
setTimeout(function() {
|
68
|
-
equals(router.query, 'nyc');
|
69
|
-
equals(router.page, '10');
|
70
|
-
start();
|
71
|
-
}, 10);
|
72
|
-
});
|
73
|
-
|
74
|
-
test("Router: routes via navigate", 2, function() {
|
75
|
-
Backbone.history.navigate('search/manhattan/p20', true);
|
76
|
-
equals(router.query, 'manhattan');
|
77
|
-
equals(router.page, '20');
|
78
|
-
});
|
79
|
-
|
80
|
-
asyncTest("Router: routes (splats)", function() {
|
81
|
-
window.location.hash = 'splat/long-list/of/splatted_99args/end';
|
82
|
-
setTimeout(function() {
|
83
|
-
equals(router.args, 'long-list/of/splatted_99args');
|
84
|
-
start();
|
85
|
-
}, 10);
|
86
|
-
});
|
87
|
-
|
88
|
-
asyncTest("Router: routes (complex)", 3, function() {
|
89
|
-
window.location.hash = 'one/two/three/complex-part/four/five/six/seven';
|
90
|
-
setTimeout(function() {
|
91
|
-
equals(router.first, 'one/two/three');
|
92
|
-
equals(router.part, 'part');
|
93
|
-
equals(router.rest, 'four/five/six/seven');
|
94
|
-
start();
|
95
|
-
}, 10);
|
96
|
-
});
|
97
|
-
|
98
|
-
asyncTest("Router: routes (query)", 2, function() {
|
99
|
-
window.location.hash = 'mandel?a=b&c=d';
|
100
|
-
setTimeout(function() {
|
101
|
-
equals(router.entity, 'mandel');
|
102
|
-
equals(router.queryArgs, 'a=b&c=d');
|
103
|
-
start();
|
104
|
-
}, 10);
|
105
|
-
});
|
106
|
-
|
107
|
-
asyncTest("Router: routes (anything)", 1, function() {
|
108
|
-
window.location.hash = 'doesnt-match-a-route';
|
109
|
-
setTimeout(function() {
|
110
|
-
equals(router.anything, 'doesnt-match-a-route');
|
111
|
-
start();
|
112
|
-
window.location.hash = '';
|
113
|
-
}, 10);
|
114
|
-
});
|
115
|
-
|
116
|
-
});
|
data/backbone/test/speed.js
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
(function(){
|
2
|
-
|
3
|
-
var object = {};
|
4
|
-
_.extend(object, Backbone.Events);
|
5
|
-
var fn = function(){};
|
6
|
-
|
7
|
-
JSLitmus.test('Events: bind + unbind', function() {
|
8
|
-
object.bind("event", fn);
|
9
|
-
object.unbind("event", fn);
|
10
|
-
});
|
11
|
-
|
12
|
-
object.bind('test:trigger', fn);
|
13
|
-
|
14
|
-
JSLitmus.test('Events: trigger', function() {
|
15
|
-
object.trigger('test:trigger');
|
16
|
-
});
|
17
|
-
|
18
|
-
object.bind('test:trigger2', fn);
|
19
|
-
object.bind('test:trigger2', fn);
|
20
|
-
|
21
|
-
JSLitmus.test('Events: trigger 2, passing 5 args', function() {
|
22
|
-
object.trigger('test:trigger2', 1, 2, 3, 4, 5);
|
23
|
-
});
|
24
|
-
|
25
|
-
var model = new Backbone.Model;
|
26
|
-
|
27
|
-
JSLitmus.test('Model: set Math.random()', function() {
|
28
|
-
model.set({number: Math.random()});
|
29
|
-
});
|
30
|
-
|
31
|
-
var eventModel = new Backbone.Model;
|
32
|
-
eventModel.bind('change', fn);
|
33
|
-
|
34
|
-
JSLitmus.test('Model: set rand() with an event', function() {
|
35
|
-
eventModel.set({number: Math.random()});
|
36
|
-
});
|
37
|
-
|
38
|
-
var keyModel = new Backbone.Model;
|
39
|
-
keyModel.bind('change:number', fn);
|
40
|
-
|
41
|
-
JSLitmus.test('Model: set rand() with an attribute observer', function() {
|
42
|
-
keyModel.set({number: Math.random()});
|
43
|
-
});
|
44
|
-
|
45
|
-
})();
|