-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.start.js
113 lines (105 loc) · 2.92 KB
/
karma.start.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Setup global test variables
var dsLocalForageAdapter, Profile, User, Post, Comment, datastore;
assert.equalObjects = function (a, b, m) {
assert.deepEqual(JSON.parse(JSON.stringify(a)), JSON.parse(JSON.stringify(b)), m || 'Objects should be equal!');
};
// Helper globals
var fail = function (msg) {
if (msg instanceof Error) {
console.log(msg.stack);
} else {
assert.equal('should not reach this!: ' + msg, 'failure');
}
};
var TYPES_EXCEPT_STRING = [123, 123.123, null, undefined, {}, [], true, false, function () {
}];
var TYPES_EXCEPT_STRING_OR_ARRAY = [123, 123.123, null, undefined, {}, true, false, function () {
}];
var TYPES_EXCEPT_STRING_OR_OBJECT = [123, 123.123, null, undefined, [], true, false, function () {
}];
var TYPES_EXCEPT_STRING_OR_NUMBER_OBJECT = [null, undefined, [], true, false, function () {
}];
var TYPES_EXCEPT_ARRAY = ['string', 123, 123.123, null, undefined, {}, true, false, function () {
}];
var TYPES_EXCEPT_STRING_OR_NUMBER = [null, undefined, {}, [], true, false, function () {
}];
var TYPES_EXCEPT_STRING_OR_ARRAY_OR_NUMBER = [null, undefined, {}, true, false, function () {
}];
var TYPES_EXCEPT_NUMBER = ['string', null, undefined, {}, [], true, false, function () {
}];
var TYPES_EXCEPT_OBJECT = ['string', 123, 123.123, null, undefined, true, false, function () {
}];
var TYPES_EXCEPT_BOOLEAN = ['string', 123, 123.123, null, undefined, {}, [], function () {
}];
var TYPES_EXCEPT_FUNCTION = ['string', 123, 123.123, null, undefined, {}, [], true, false];
// Setup before each test
beforeEach(function (done) {
localforage.clear(function () {
var JSData;
try {
JSData = require('js-data');
} catch (e) {
}
if (!JSData) {
try {
JSData = window.JSData;
} catch (e) {
}
}
datastore = new JSData.DS();
Profile = datastore.defineResource({
name: 'profile'
});
User = datastore.defineResource({
name: 'user',
relations: {
hasMany: {
post: {
localField: 'posts',
foreignKey: 'post'
}
},
hasOne: {
profile: {
localField: 'profile',
localKey: 'profileId'
}
}
}
});
Post = datastore.defineResource({
name: 'post',
relations: {
belongsTo: {
user: {
localField: 'user',
localKey: 'userId'
}
},
hasMany: {
comment: {
localField: 'comments',
foreignKey: 'postId'
}
}
}
});
Comment = datastore.defineResource({
name: 'comment',
relations: {
belongsTo: {
post: {
localField: 'post',
localKey: 'postId'
},
user: {
localField: 'user',
localKey: 'userId'
}
}
}
});
dsLocalForageAdapter = new DSLocalForageAdapter();
done();
});
});