forked from canjs/can-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core_test.js
78 lines (66 loc) · 1.67 KB
/
core_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
var QUnit = require("steal-qunit");
var connect = require("./can-connect");
var set = require("can-set-legacy");
QUnit.module("can-connect/core test",{
beforeEach: function(assert) {
}
});
QUnit.test("Determine .id() from queryLogic (#82)", function(assert) {
var queryLogic = new set.Algebra(
set.comparators.id("_id")
);
var connection = connect([],{
queryLogic: queryLogic
});
assert.equal( connection.id({_id: "foo"}), "foo", "got id from queryLogic");
assert.equal( connection.id({_id: 1}), 1, "got id from queryLogic");
});
QUnit.test("Everything available at can-connect/all", function(assert) {
var all = require("./all");
var expectedBehaviors = [
'cacheRequests',
'constructor',
'constructorCallbacksOnce',
'constructorStore',
'dataCallbacks',
'dataCallbacksCache',
'dataCombineRequests',
'dataLocalStorageCache',
'dataMemoryCache',
'dataParse',
'dataUrl',
'fallThroughCache',
'realTime',
'superMap',
'baseMap',
];
expectedBehaviors.forEach(function(behaviorName){
assert.ok(all[behaviorName], 'behavior in place: ' + behaviorName);
});
});
QUnit.test("queryLogic falls", function(assert) {
var algebra = {};
var connection = connect([{
methodThatChecksAlgebra: function(){
assert.equal(this.queryLogic, algebra);
}
}],
{
algebra: algebra
});
connection.methodThatChecksAlgebra();
connection = connect([{
methodThatChecksAlgebra: function(){
assert.equal(this.queryLogic, algebra);
}
}],
{
queryLogic: algebra
});
connection.methodThatChecksAlgebra();
/*
var connection = connect([
,
base],
);*/
});