Skip to content

Commit

Permalink
Updated test cases for design section
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshityagi committed Jan 6, 2016
1 parent 678423d commit 50ec835
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 172 deletions.
81 changes: 0 additions & 81 deletions control/design/app.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,70 +22,6 @@
});
return deferred.promise;
},
getById: function (_id, _tagName) {
var deferred = $q.defer();
if (typeof _id == 'undefined') {
return deferred.reject(new Error({
code: STATUS_CODE.UNDEFINED_ID,
message: STATUS_MESSAGES.UNDEFINED_ID
}));
}
Buildfire.datastore.get(_tagName, function (err, result) {
if (err) {
return deferred.reject(err);
} else if (result) {
return deferred.resolve(result);
}
});
return deferred.promise;
},
insert: function (_item, _tagName) {
var deferred = $q.defer();
if (typeof _item == 'undefined') {
return deferred.reject(new Error({
code: STATUS_CODE.UNDEFINED_DATA,
message: STATUS_MESSAGES.UNDEFINED_DATA
}));
}
if (Array.isArray(_item)) {
return deferred.reject(new Error({
code: STATUS_CODE.ITEM_ARRAY_FOUND,
message: STATUS_MESSAGES.ITEM_ARRAY_FOUND
}));
} else {
Buildfire.datastore.insert(_item, _tagName, false, function (err, result) {
if (err) {
return deferred.reject(err);
} else if (result) {
return deferred.resolve(result);
}
});
}
return deferred.promise;
},
update: function (_id, _item, _tagName) {
var deferred = $q.defer();
if (typeof _id == 'undefined') {
return deferred.reject(new Error({
code: STATUS_CODE.UNDEFINED_ID,
message: STATUS_MESSAGES.UNDEFINED_ID
}));
}
if (typeof _item == 'undefined') {
return deferred.reject(new Error({
code: STATUS_CODE.UNDEFINED_DATA,
message: STATUS_MESSAGES.UNDEFINED_DATA
}));
}
Buildfire.datastore.update(_id, _item, _tagName, function (err, result) {
if (err) {
return deferred.reject(err);
} else if (result) {
return deferred.resolve(result);
}
});
return deferred.promise;
},
save: function (_item, _tagName) {
var deferred = $q.defer();
if (typeof _item == 'undefined') {
Expand All @@ -102,23 +38,6 @@
}
});
return deferred.promise;
},
deleteById: function (_id, _tagName) {
var deferred = $q.defer();
if (typeof _id == 'undefined') {
return deferred.reject(new Error({
code: STATUS_CODE.UNDEFINED_ID,
message: STATUS_MESSAGES.UNDEFINED_ID
}));
}
Buildfire.datastore.delete(_id, _tagName, function (err, result) {
if (err) {
return deferred.reject(err);
} else if (result) {
return deferred.resolve(result);
}
});
return deferred.promise;
}
}
}])
Expand Down
12 changes: 0 additions & 12 deletions test/control/design/app.services.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,9 @@ describe('Unit : youtubePlugin design services', function () {
it('DataStore.get should exist and be an function', function () {
expect(typeof DataStore.get).toEqual('function');
});
it('DataStore.getById should exist and be an function', function () {
expect(typeof DataStore.getById).toEqual('function');
});
it('DataStore.insert should exist and be an function', function () {
expect(typeof DataStore.insert).toEqual('function');
});
it('DataStore.update should exist and be an function', function () {
expect(typeof DataStore.update).toEqual('function');
});
it('DataStore.save should exist and be an function', function () {
expect(typeof DataStore.save).toEqual('function');
});
it('DataStore.deleteById should exist and be an function', function () {
expect(typeof DataStore.deleteById).toEqual('function');
});
});
describe('Unit : ImageLibrary Factory', function () {
var ImageLibrary, Buildfire, imageLib, STATUS_MESSAGES, STATUS_CODE, q;
Expand Down
57 changes: 38 additions & 19 deletions test/control/design/app.spec.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,45 @@
describe('Unit: youtubePlugin design app', function () {
describe('Unit : youtubePlugin design app.js', function () {
describe('Unit: app routes', function () {
beforeEach(module('youtubePluginDesign'));
var location, route, rootScope;
beforeEach(inject(
function( _$location_, _$route_, _$rootScope_ ) {
location = _$location_;
route = _$route_;
rootScope = _$rootScope_;
beforeEach(inject(function (_$location_, _$route_, _$rootScope_) {
location = _$location_;
route = _$route_;
rootScope = _$rootScope_;
}));
describe('Home route', function () {
beforeEach(inject(
function ($httpBackend) {
$httpBackend.expectGET('templates/home.html')
.respond(200);
$httpBackend.expectGET('/')
.respond(200);
}));

describe('Home route', function() {
beforeEach(inject(
function($httpBackend) {
$httpBackend.expectGET('templates/home.html')
.respond(200);
$httpBackend.expectGET('/')
.respond(200);
}));
it('should load the home page on successful load of location path /', function () {
location.path('/');
rootScope.$digest();
expect(route.current.controller).toBe('DesignHomeCtrl')
});
});
});

describe('Unit: getImageUrl filter', function () {
beforeEach(module('youtubePluginDesign'));
var filter;
beforeEach(inject(function (_$filter_) {
filter = _$filter_;
}));

it('should load the home page on successful load of location path /', function() {
location.path('/');
rootScope.$digest();
expect(route.current.controller).toBe('DesignHomeCtrl')
});
it('it should returns resized image url', function () {
var reSizedImage;
reSizedImage = filter('getImageUrl')('https://www.facebook.com/photo.php?fbid=1008284442533844&set=a.359021657460129.98766.100000568920267&type=1&theater', 88, 124, 'resize');
expect(reSizedImage).toEqual('http://s7obnu.cloudimage.io/s/resizenp/88x124/https://www.facebook.com/photo.php?fbid=1008284442533844&set=a.359021657460129.98766.100000568920267&type=1&theater');
});
it('it should pass if "getImageUrl" filter returns cropped image url', function () {
var croppedImage;
croppedImage = filter('getImageUrl')('https://www.facebook.com/photo.php?fbid=1008284442533844&set=a.359021657460129.98766.100000568920267&type=1&theater', 88, 124, 'crop');
expect(croppedImage).toEqual('http://s7obnu.cloudimage.io/s/crop/88x124/https://www.facebook.com/photo.php?fbid=1008284442533844&set=a.359021657460129.98766.100000568920267&type=1&theater');
});
});
});
143 changes: 83 additions & 60 deletions test/control/design/enums.spec.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,94 @@
describe('Unit : youtubePlugin Design Enums', function () {
var TAG_NAMES, STATUS_CODE, STATUS_MESSAGES, CONTENT_TYPE;
beforeEach(module('youtubePluginDesign'));
var TAG_NAMES, STATUS_CODE, STATUS_MESSAGES, CONTENT_TYPE,LAYOUTS;
beforeEach(module('youtubePluginDesign'));

beforeEach(inject(function (_TAG_NAMES_, _STATUS_CODE_, _STATUS_MESSAGES_, _CONTENT_TYPE_) {
TAG_NAMES = _TAG_NAMES_;
STATUS_CODE = _STATUS_CODE_;
STATUS_MESSAGES = _STATUS_MESSAGES_;
CONTENT_TYPE = _CONTENT_TYPE_;
}));
beforeEach(inject(function (_TAG_NAMES_, _STATUS_CODE_, _STATUS_MESSAGES_, _CONTENT_TYPE_,_LAYOUTS_) {
TAG_NAMES = _TAG_NAMES_;
STATUS_CODE = _STATUS_CODE_;
STATUS_MESSAGES = _STATUS_MESSAGES_;
CONTENT_TYPE = _CONTENT_TYPE_;
LAYOUTS = _LAYOUTS_;
}));

describe('Enum : TAG_NAMES', function () {
it('TAG_NAMES should exist and be an object', function () {
expect(typeof TAG_NAMES).toEqual('object');
});
it('TAG_NAMES.YOUTUBE_INFO should exist and equals to "GetInfo"', function () {
expect(TAG_NAMES.YOUTUBE_INFO).toEqual('YouTubeInfo');
});
describe('Enum : TAG_NAMES', function () {
it('TAG_NAMES should exist and be an object', function () {
expect(typeof TAG_NAMES).toEqual('object');
});
it('TAG_NAMES.YOUTUBE_INFO should exist and equals to "GetInfo"', function () {
expect(TAG_NAMES.YOUTUBE_INFO).toEqual('YouTubeInfo');
});
});

describe('Enum : STATUS_CODE', function () {
it('STATUS_CODE should exist and be an object', function () {
expect(typeof STATUS_CODE).toEqual('object');
});
it('STATUS_CODE.INSERTED should exist and equals to "inserted"', function () {
expect(STATUS_CODE.INSERTED).toEqual('inserted');
});
it('STATUS_CODE.UPDATED should exist and equals to "updated"', function () {
expect(STATUS_CODE.UPDATED).toEqual('updated');
});
it('STATUS_CODE.NOT_FOUND should exist and equals to "NOTFOUND"', function () {
expect(STATUS_CODE.NOT_FOUND).toEqual('NOTFOUND');
});
it('STATUS_CODE.UNDEFINED_DATA should exist and equals to "UNDEFINED_DATA"', function () {
expect(STATUS_CODE.UNDEFINED_DATA).toEqual('UNDEFINED_DATA');
});
it('STATUS_CODE.UNDEFINED_OPTIONS should exist and equals to "UNDEFINED_OPTIONS"', function () {
expect(STATUS_CODE.UNDEFINED_OPTIONS).toEqual('UNDEFINED_OPTIONS');
});
it('STATUS_CODE.NOT_FOUND should exist and equals to "UNDEFINED_ID"', function () {
expect(STATUS_CODE.UNDEFINED_ID).toEqual('UNDEFINED_ID');
});
});

describe('Enum : STATUS_CODE', function () {
it('STATUS_CODE should exist and be an object', function () {
expect(typeof STATUS_CODE).toEqual('object');
});
it('STATUS_CODE.INSERTED should exist and equals to "inserted"', function () {
expect(STATUS_CODE.INSERTED).toEqual('inserted');
});
it('STATUS_CODE.UPDATED should exist and equals to "updated"', function () {
expect(STATUS_CODE.UPDATED).toEqual('updated');
});
it('STATUS_CODE.NOT_FOUND should exist and equals to "NOTFOUND"', function () {
expect(STATUS_CODE.NOT_FOUND).toEqual('NOTFOUND');
});
it('STATUS_CODE.UNDEFINED_DATA should exist and equals to "UNDEFINED_DATA"', function () {
expect(STATUS_CODE.UNDEFINED_DATA).toEqual('UNDEFINED_DATA');
});
it('STATUS_CODE.UNDEFINED_OPTIONS should exist and equals to "UNDEFINED_OPTIONS"', function () {
expect(STATUS_CODE.UNDEFINED_OPTIONS).toEqual('UNDEFINED_OPTIONS');
});
it('STATUS_CODE.NOT_FOUND should exist and equals to "UNDEFINED_ID"', function () {
expect(STATUS_CODE.UNDEFINED_ID).toEqual('UNDEFINED_ID');
});
describe('Enum : STATUS_MESSAGES', function () {
it('STATUS_MESSAGES should exist and be an object', function () {
expect(typeof STATUS_MESSAGES).toEqual('object');
});
it('STATUS_MESSAGES.UNDEFINED_DATA should exist and equals to "Undefined data provided"', function () {
expect(STATUS_MESSAGES.UNDEFINED_DATA).toEqual('Undefined data provided');
});
it('STATUS_MESSAGES.UNDEFINED_OPTIONS should exist and equals to "Undefined options provided"', function () {
expect(STATUS_MESSAGES.UNDEFINED_OPTIONS).toEqual('Undefined options provided');
});
it('STATUS_MESSAGES.NOT_FOUND should exist and equals to "Undefined id provided"', function () {
expect(STATUS_MESSAGES.UNDEFINED_ID).toEqual('Undefined id provided');
});
});

describe('Enum : STATUS_MESSAGES', function () {
it('STATUS_MESSAGES should exist and be an object', function () {
expect(typeof STATUS_MESSAGES).toEqual('object');
});
it('STATUS_MESSAGES.UNDEFINED_DATA should exist and equals to "Undefined data provided"', function () {
expect(STATUS_MESSAGES.UNDEFINED_DATA).toEqual('Undefined data provided');
});
it('STATUS_MESSAGES.UNDEFINED_OPTIONS should exist and equals to "Undefined options provided"', function () {
expect(STATUS_MESSAGES.UNDEFINED_OPTIONS).toEqual('Undefined options provided');
});
it('STATUS_MESSAGES.NOT_FOUND should exist and equals to "Undefined id provided"', function () {
expect(STATUS_MESSAGES.UNDEFINED_ID).toEqual('Undefined id provided');
});
describe('Enum : CONTENT_TYPE', function () {
it('CONTENT_TYPE should exist and be an object', function () {
expect(typeof CONTENT_TYPE).toEqual('object');
});
it('CONTENT_TYPE.CHANNEL_FEED should exist and equals to "Channel Feed"', function () {
expect(CONTENT_TYPE.CHANNEL_FEED).toEqual('Channel Feed');
});
it('CONTENT_TYPE.SINGLE_VIDEO should exist and equals to "Single Video"', function () {
expect(CONTENT_TYPE.SINGLE_VIDEO).toEqual('Single Video');
});
});


describe('Enum : CONTENT_TYPE', function () {
it('CONTENT_TYPE should exist and be an object', function () {
expect(typeof CONTENT_TYPE).toEqual('object');
});
it('CONTENT_TYPE.CHANNEL_FEED should exist and equals to "Channel Feed"', function () {
expect(CONTENT_TYPE.CHANNEL_FEED).toEqual('Channel Feed');
});
it('CONTENT_TYPE.SINGLE_VIDEO should exist and equals to "Single Video"', function () {
expect(CONTENT_TYPE.SINGLE_VIDEO).toEqual('Single Video');
});
describe('Unit : Enum LAYOUTS', function () {
it('LAYOUTS should exist and be an object', function () {
expect(typeof LAYOUTS).toEqual('object');
});
it('LAYOUTS.listLayouts should be an array', function () {
expect(Array.isArray(LAYOUTS.listLayouts)).toEqual(true);
});
it('LAYOUTS.listLayouts[0].name should exist and equals to "List_Layout_1"', function () {
expect(LAYOUTS.listLayouts[0].name).toEqual('List_Layout_1');
});
it('LAYOUTS.listLayouts[1].name should exist and equals to "List_Layout_2"', function () {
expect(LAYOUTS.listLayouts[1].name).toEqual('List_Layout_2');
});
it('LAYOUTS.listLayouts[2].name should exist and equals to "List_Layout_3"', function () {
expect(LAYOUTS.listLayouts[2].name).toEqual('List_Layout_3');
});
it('LAYOUTS.listLayouts[3].name should exist and equals to "List_Layout_4"', function () {
expect(LAYOUTS.listLayouts[3].name).toEqual('List_Layout_4');
});
});
});

0 comments on commit 50ec835

Please sign in to comment.