123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- /**
- * Created by robin on 12/11/16.
- */
-
- describe('lu-webapi-crud-dataAccess dbo factory', function() {
- var luWebApiCrudDataAccess;
- var $q;
- var $rootScope;
-
- beforeEach(angular.mock.module('luticate2Utils'));
-
- beforeEach(function () {
- module(function ($provide) {
- $provide.value('luWebApiDataAccess', {
- create: function (entry_point) {
- return {
-
- get: function (url, dataGet, luBusyGroups) {
- var deferred = $q.defer();
- deferred.resolve({
- get: dataGet,
- post: null,
- url: entry_point + url
- });
- return deferred.promise;
- },
-
- post: function (url, dataGet, dataPost, luBusyGroups) {
- var deferred = $q.defer();
- deferred.resolve({
- get: dataGet,
- post: dataPost,
- url: entry_point + url
- });
- return deferred.promise;
- },
-
- put: function (url, dataGet, dataPost, luBusyGroups) {
- var deferred = $q.defer();
- deferred.resolve({
- get: dataGet,
- post: dataPost,
- url: entry_point + url
- });
- return deferred.promise;
- },
-
- delete: function (url, dataGet, dataPost, luBusyGroups) {
- var deferred = $q.defer();
- deferred.resolve({
- get: dataGet,
- post: dataPost,
- url: entry_point + url
- });
- return deferred.promise;
- }
- }
- }
- });
- });
- });
-
- beforeEach(inject(function(_luWebApiCrudDataAccess_, _$q_, _$rootScope_) {
- luWebApiCrudDataAccess = _luWebApiCrudDataAccess_;
- $q = _$q_;
- $rootScope = _$rootScope_;
- }));
-
-
- it('should check that removing fields does not affect dbo', function()
- {
- var dataAccess = luWebApiCrudDataAccess.create('/api/entities/');
-
- dataAccess.defaultDbo = {};
-
- dataAccess.addDbo({
- someText: "42",
- someInt: 42
- }).then(function (data) {
- expect(data).toEqual({
- get: null,
- post: {
- someText: "42",
- someInt: 42
- },
- url: '/api/entities/',
- createdAt: null,
- updatedAt: null
- });
- }, function (error) {
- expect(error).toBeNull();
- });
- $rootScope.$digest();
- });
-
- it('should check that removing fields works', function()
- {
- var dataAccess = luWebApiCrudDataAccess.create('/api/entities/');
-
- dataAccess.defaultDbo = {};
-
- dataAccess.editSingleByIdDbo("xxx-x-x-x-xxx", {
- id: "xxx-x-x-x-xxx",
- someText: "42",
- someInt: 42,
- createdAt: new Date(),
- updatedAt: null,
- toString: function()
- {
- return this.someText;
- }
- }).then(function (data) {
- expect(data).toEqual({
- get: null,
- post: {
- someText: "42",
- someInt: 42
- },
- url: '/api/entities/xxx-x-x-x-xxx',
- createdAt: null,
- updatedAt: null
- });
- }, function (error) {
- expect(error).toBeNull();
- });
- $rootScope.$digest();
- });
-
- });
|