Jenny Kang has uploaded a new change for review. Change subject: Added some more unit tests ......................................................................
Added some more unit tests More unit tests have been added for ObjectUtils and Resource Change-Id: I0d3771f318040a110817621db46130a78227e6d7 Bug-Url: https://bugzilla.redhat.com/?????? Signed-off-by: Jenny Kang <[email protected]> --- M frontend/ovirtjs/src/test/unit/ObjectUtilSpec.js A frontend/ovirtjs/src/test/unit/ResourceSpec.js 2 files changed, 45 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/26/34326/1 diff --git a/frontend/ovirtjs/src/test/unit/ObjectUtilSpec.js b/frontend/ovirtjs/src/test/unit/ObjectUtilSpec.js index fba0b96..f0fe5ce 100644 --- a/frontend/ovirtjs/src/test/unit/ObjectUtilSpec.js +++ b/frontend/ovirtjs/src/test/unit/ObjectUtilSpec.js @@ -3,14 +3,32 @@ var ObjectUtil = System.get('../../src/main/utils').ObjectUtil; describe('computeDiff', function () { - - it('should work', function () { + it('should work with plain objects', function () { var original = { foo: 1, bar: 2 }; var modified = { foo: 2, bar: 2, baz: 3 }; var diff = ObjectUtil.computeDiff(original, modified); expect(diff).toEqual({ foo: 2, baz: 3 }); }); + it('should return null given identical objects', function(){ + var original = {foo: 1, bar: 'hello'}; + var modified = {foo: 1, bar: 'hello'}; + var diff = ObjectUtil.computeDiff(original, modified); + expect(diff).toEqual(null); + + }); + + it('should work with opaque objects', function(){ + var original = [1, 2, 3]; + var modified = [5]; + var diff = ObjectUtil.computeDiff(original, modified); + expect(diff).toEqual([5]); + + + modified = [1, 2, 3]; + diff = ObjectUtil.computeDiff(original, modified); + expect(diff).toEqual(null); + }); }); }); diff --git a/frontend/ovirtjs/src/test/unit/ResourceSpec.js b/frontend/ovirtjs/src/test/unit/ResourceSpec.js new file mode 100644 index 0000000..9bd0625 --- /dev/null +++ b/frontend/ovirtjs/src/test/unit/ResourceSpec.js @@ -0,0 +1,25 @@ +var Resource = System.get('../../src/main/resources').Resource; + +describe('Response', function(){ + it('should setup response correctly from given data', function() { + var resource = Resource.fromData({ + id: 'test', + href: '/api' + }); + + expect(resource.apiContextPath).toEqual('/api'); + + expect(resource.data.href).toEqual('/api'); + expect(resource.data.id).toEqual('test'); + + expect(resource.originalData).toEqual(resource.data); + + var updateOperation = resource.update(); + expect(updateOperation.httpParams.method).toEqual('PUT'); + expect(updateOperation.httpParams.url.slice(-4)).toEqual('/api'); + + var deleteOperation = resource.delete(); + expect(deleteOperation.httpParams.method).toEqual('DELETE'); + expect(deleteOperation.httpParams.url.slice(-4)).toEqual('/api'); + }); +}); -- To view, visit http://gerrit.ovirt.org/34326 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0d3771f318040a110817621db46130a78227e6d7 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Jenny Kang <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
