|
@@ -37,6 +37,28 @@ describe('lu-webapi-crud-business factory', function() {
|
37
|
37
|
}
|
38
|
38
|
});
|
39
|
39
|
}
|
|
40
|
+ else if (id == 3) {
|
|
41
|
+ deferred.resolve({
|
|
42
|
+ id: id,
|
|
43
|
+ name: "Test.2",
|
|
44
|
+ obj: {
|
|
45
|
+ value: 4242
|
|
46
|
+ },
|
|
47
|
+ createdAt: "2016-12-27T05:00:00-05:00",
|
|
48
|
+ updatedAt: null
|
|
49
|
+ });
|
|
50
|
+ }
|
|
51
|
+ else if (id == 4) {
|
|
52
|
+ deferred.resolve({
|
|
53
|
+ id: id,
|
|
54
|
+ name: "Test.2",
|
|
55
|
+ obj: {
|
|
56
|
+ value: 4242
|
|
57
|
+ },
|
|
58
|
+ createdAt: "2016-12-27T05:00:00-05:00",
|
|
59
|
+ updatedAt: "2016-12-28T05:00:00-05:00"
|
|
60
|
+ });
|
|
61
|
+ }
|
40
|
62
|
return deferred.promise;
|
41
|
63
|
},
|
42
|
64
|
getMultiple: function (orderBy, filter, page, perPage, luBusyGroups) {
|
|
@@ -226,4 +248,60 @@ describe('lu-webapi-crud-business factory', function() {
|
226
|
248
|
});
|
227
|
249
|
$rootScope.$digest();
|
228
|
250
|
});
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+ it('should convert createdAt into Date', function()
|
|
254
|
+ {
|
|
255
|
+ var business = luWebApiCrudBusiness.create(fakeDataAccess);
|
|
256
|
+ business.defaultDbo = {
|
|
257
|
+ id: null,
|
|
258
|
+ name: "",
|
|
259
|
+ createdAt: null,
|
|
260
|
+ updatedAt: null,
|
|
261
|
+ dummyFunction: function () {
|
|
262
|
+ return '_' + this.name + '_';
|
|
263
|
+ }
|
|
264
|
+ };
|
|
265
|
+
|
|
266
|
+ var id = 3;
|
|
267
|
+ business.getSingleById(id, null).then(function (data) {
|
|
268
|
+ expect(data.id).toEqual(id);
|
|
269
|
+ expect(data.name).toEqual("Test.2");
|
|
270
|
+ expect(data.dummyFunction).not.toBeNull();
|
|
271
|
+ expect(data.dummyFunction()).toEqual("_Test.2_");
|
|
272
|
+ expect(data.createdAt).toEqual(new Date("2016-12-27T05:00:00-05:00"));
|
|
273
|
+ expect(data.updatedAt).toBeNull();
|
|
274
|
+ }, function (error) {
|
|
275
|
+ expect(error).toBeNull();
|
|
276
|
+ });
|
|
277
|
+ $rootScope.$digest();
|
|
278
|
+ });
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+ it('should convert createdAt and updatedAt into Date', function()
|
|
282
|
+ {
|
|
283
|
+ var business = luWebApiCrudBusiness.create(fakeDataAccess);
|
|
284
|
+ business.defaultDbo = {
|
|
285
|
+ id: null,
|
|
286
|
+ name: "",
|
|
287
|
+ createdAt: null,
|
|
288
|
+ updatedAt: null,
|
|
289
|
+ dummyFunction: function () {
|
|
290
|
+ return '_' + this.name + '_';
|
|
291
|
+ }
|
|
292
|
+ };
|
|
293
|
+
|
|
294
|
+ var id = 4;
|
|
295
|
+ business.getSingleById(id, null).then(function (data) {
|
|
296
|
+ expect(data.id).toEqual(id);
|
|
297
|
+ expect(data.name).toEqual("Test.2");
|
|
298
|
+ expect(data.dummyFunction).not.toBeNull();
|
|
299
|
+ expect(data.dummyFunction()).toEqual("_Test.2_");
|
|
300
|
+ expect(data.createdAt).toEqual(new Date("2016-12-27T05:00:00-05:00"));
|
|
301
|
+ expect(data.updatedAt).toEqual(new Date("2016-12-28T05:00:00-05:00"));
|
|
302
|
+ }, function (error) {
|
|
303
|
+ expect(error).toBeNull();
|
|
304
|
+ });
|
|
305
|
+ $rootScope.$digest();
|
|
306
|
+ });
|
229
|
307
|
});
|