Added: rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/category_resources.spec URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/category_resources.spec?rev=1508141&view=auto ============================================================================== --- rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/category_resources.spec (added) +++ rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/category_resources.spec Mon Jul 29 17:18:19 2013 @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * 'License'); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +describe('Category Resources', function(){ + var mockBackend, category; + + beforeEach(module('common.resources')); + + beforeEach(function(){ + //A function to compare objects which resources return + this.addMatchers({ + toEqualData: function(expected) { + return angular.equals(this.actual, expected); + } + }); + }); + + beforeEach(inject(function(_$httpBackend_, Category){ + mockBackend = _$httpBackend_; + category = Category; + })); + + describe('Category get all', function(){ + it('returns a list of all categories', function(){ + var mockDataResponse = [{id: 1, text: 'fake category', createdUserId: 3, createdDate: '01121990', lastModifiedUserId: 3, lastModifiedDate: '01122000'}, + {id: 2, text: 'another fake category', createdUserId: 1, createdDate: '01121990', lastModifiedUserId: 5, lastModifiedDate: '01122000'}]; + + mockBackend.expectGET('/categories'). + respond({meta: {}, data: mockDataResponse}); + + var categories = category.query(); + + mockBackend.flush(); + + expect(categories).toEqualData(mockDataResponse) + }) + }); + + describe('Category get by ID and update', function(){ + it('returns a single category and updates correctly', function(){ + var mockDataResponse = {id: 1, text: 'fake category', createdUserId: 3, createdDate: '01121990', lastModifiedUserId: 3, lastModifiedDate: '01122000'}; + var mockPostData = {id: 1, text: 'fake category change', createdUserId: 3, createdDate: '01121990', lastModifiedUserId: 3, lastModifiedDate: '01122000'}; + + mockBackend.expectGET('/categories/1'). + respond({meta: {}, data: mockDataResponse}); + + var categories = category.get({id: 1}); + + mockBackend.flush(); + + expect(categories).toEqualData(mockDataResponse) + + mockBackend.expectPOST('/categories/1', mockPostData). + respond({meta: {}, data: mockPostData}); + + categories.text = 'fake category change'; + + categories.$save(); + + mockBackend.flush() + + expect(categories).toEqualData(mockPostData); + }) + }); + + describe('post a new Cateogry', function(){ + it('saves a new category correctly', function(){ + var mockDataResponse = {id: 1, text: 'fake category', createdUserId: 3, createdDate: '01121990', lastModifiedUserId: 3, lastModifiedDate: '01122000'}; + var mockDataResponse2 = {id: 2, text: 'fake category', createdUserId: 3, createdDate: '01121990', lastModifiedUserId: 3, lastModifiedDate: '01122000'}; + var mockPostData = {text: 'fake category', createdUserId: 3, createdDate: '01121990', lastModifiedUserId: 3, lastModifiedDate: '01122000'}; + + mockBackend.expectPOST('/categories', mockPostData). + respond({meta: {}, data: mockDataResponse}); + + mockBackend.expectPOST('/categories', mockPostData). + respond({meta: {}, data: mockDataResponse2}); + + var categories = category.save(mockPostData); + var categories2 = category.save(mockPostData); + + mockBackend.flush(); + + expect(categories).toEqualData(mockDataResponse); + expect(categories2).toEqualData(mockDataResponse2); + }) + }); + +})
Added: rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/page_resources.spec URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/page_resources.spec?rev=1508141&view=auto ============================================================================== --- rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/page_resources.spec (added) +++ rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/page_resources.spec Mon Jul 29 17:18:19 2013 @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * 'License'); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +describe('Page Resources', function(){ + var mockBackend, page; + + beforeEach(module('common.resources')); + + beforeEach(function(){ + //A function to compare objects which resources return + this.addMatchers({ + toEqualData: function(expected) { + return angular.equals(this.actual, expected); + } + }); + }); + + beforeEach(inject(function(_$httpBackend_, Page){ + mockBackend = _$httpBackend_; + page = Page; + })); + + describe('Page get all', function(){ + it('returns a list of all pages', function(){ + var mockDataResponse = [{id: 1, name: 'portal page', ownerId: 3, pageType: '2_col', pageLayoutCode: 1}, + {id: 2, name: 'profile page', ownerId: 6, pageType: '2_col', pageLayoutCode: 3}]; + + mockBackend.expectGET('/pages'). + respond({meta: {}, data: mockDataResponse}); + + var pages = page.query(); + + mockBackend.flush(); + + expect(pages).toEqualData(mockDataResponse) + }) + }); + + describe('Page get by id and update', function(){ + it('returns a single page and updates correctly', function(){ + var mockDataResponse = {id: 1, name: 'portal page', ownerId: 3, pageType: '2_col', pageLayoutCode: 1}; + var mockPostData = {id: 1, name: 'portal page update', ownerId: 3, pageType: '2_col', pageLayoutCode: 1}; + + mockBackend.expectGET('/pages/1'). + respond({meta: {}, data: mockDataResponse}); + + var pages = page.get({id: 1}); + + mockBackend.flush(); + + expect(pages).toEqualData(mockDataResponse); + + mockBackend.expectPOST('/pages/1', mockPostData). + respond({meta: {}, data: mockPostData}); + + pages.name = 'portal page update'; + + pages.$save(); + + mockBackend.flush(); + + expect(pages).toEqualData(mockPostData); + }) + }); + + describe('post a new Page', function(){ + it('creates a new page correctly', function(){ + var mockDataResponse = {id: 1, name: 'portal page', ownerId: 3, pageType: '2_col', pageLayoutCode: 1}; + var mockDataResponse2 = {id: 2, name: 'portal page', ownerId: 3, pageType: '2_col', pageLayoutCode: 1}; + var mockPostData = {name: 'portal page', ownerId: 3, pageType: '2_col', pageLayoutCode: 1}; + + mockBackend.expectPOST('/pages', mockPostData). + respond({meta: {}, data: mockDataResponse}); + + mockBackend.expectPOST('/pages', mockPostData). + respond({meta: {}, data: mockDataResponse2}); + + var pages = page.save(mockPostData); + var pages2 = page.save(mockPostData); + + mockBackend.flush(); + + expect(pages).toEqualData(mockDataResponse); + expect(pages2).toEqualData(mockDataResponse2); + }) + }); + +}) Added: rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/person_resources.spec URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/person_resources.spec?rev=1508141&view=auto ============================================================================== --- rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/person_resources.spec (added) +++ rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/person_resources.spec Mon Jul 29 17:18:19 2013 @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * 'License'); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +describe('Person Resources', function(){ + var mockBackend, person, friend; + + beforeEach(module('common.resources')); + + beforeEach(function(){ + //A function to compare objects which resources return + this.addMatchers({ + toEqualData: function(expected) { + return angular.equals(this.actual, expected); + } + }); + }); + + beforeEach(inject(function(_$httpBackend_, Person, Friend){ + mockBackend = _$httpBackend_; + person = Person; + friend = Friend; + })); + + //Testing person resources + + describe('Person get all', function(){ + it('returns a list of all people', function(){ + var mockDataResponse = [{id: 1, username: 'dgornstein', displayName: 'Dan', email: '[email protected]', aboutMe: 'A blurb about me.', preferredName: 'Danny'}, + {id: 1, username: 'jdoe', displayName: 'John', email: '[email protected]', aboutMe: 'You enjoy myself.', preferredName: 'Johnny'}]; + + mockBackend.expectGET('/people'). + respond({meta: {}, data: mockDataResponse}); + + var people = person.query(); + + mockBackend.flush(); + + expect(people).toEqualData(mockDataResponse) + }) + }); + + describe('Person get by id and update', function(){ + it('returns a single person and updates correctly', function(){ + var mockDataResponse = {id: 1, username: 'dgornstein', displayName: 'Dan', email: '[email protected]', aboutMe: 'A blurb about me.', preferredName: 'Danny'}; + var mockPostData = {id: 1, username: 'dgornstein', displayName: 'Daniel', email: '[email protected]', aboutMe: 'A blurb about me.', preferredName: 'Danny'}; + + mockBackend.expectGET('/people/1'). + respond({meta: {}, data: mockDataResponse}); + + var people = person.get({id: 1}); + + mockBackend.flush(); + + expect(people).toEqualData(mockDataResponse) + + mockBackend.expectPOST('/people/1', mockPostData). + respond({meta: {}, data: mockPostData}); + + people.displayName = 'Daniel'; + + people.$save(); + + mockBackend.flush(); + + expect(people).toEqualData(mockPostData); + + }) + }); + + describe('post a new Person', function(){ + it('creates a new person correctly', function(){ + var mockDataResponse = {id: 1, username: 'dgornstein', displayName: 'Dan', email: '[email protected]', aboutMe: 'A blurb about me.', preferredName: 'Danny'}; + var mockDataResponse2 = {id: 2, username: 'dgornstein', displayName: 'Dan', email: '[email protected]', aboutMe: 'A blurb about me.', preferredName: 'Danny'}; + var mockPostData = {username: 'dgornstein', displayName: 'Dan', email: '[email protected]', aboutMe: 'A blurb about me.', preferredName: 'Danny'}; + + mockBackend.expectPOST('/people', mockPostData). + respond({meta: {}, data: mockDataResponse}); + + mockBackend.expectPOST('/people', mockPostData). + respond({meta: {}, data: mockDataResponse2}); + + var people = person.save(mockPostData); + var people2 = person.save(mockPostData); + + mockBackend.flush(); + + expect(people).toEqualData(mockDataResponse); + expect(people2).toEqualData(mockDataResponse2); + }) + }); + + //Testing person's friends resources + + describe("Person's friends get all", function(){ + it('returns a list of all friends of a person', function(){ + var mockDataResponse = [{id: 1, username: 'dgornstein', displayName: 'Dan', email: '[email protected]', aboutMe: 'A blurb about me.', preferredName: 'Danny'}, + {id: 1, username: 'jdoe', displayName: 'John', email: '[email protected]', aboutMe: 'You enjoy myself.', preferredName: 'Johnny'}]; + + mockBackend.expectGET('/people/3/friends'). + respond({meta: {}, data: mockDataResponse}); + + var friends = friend.query({personId: 3}); + + mockBackend.flush(); + + expect(friends).toEqualData(mockDataResponse) + }) + }); + + describe("Person's friends get by id", function(){ + it('returns a single friend correctly', function(){ + var mockDataResponse = {id: 1, username: 'dgornstein', displayName: 'Dan', email: '[email protected]', aboutMe: 'A blurb about me.', preferredName: 'Danny'}; + + mockBackend.expectGET('/people/3/friends/1'). + respond({meta: {}, data: mockDataResponse}); + + var friends = friend.get({personId: 3, id: 1}); + + mockBackend.flush(); + + expect(friends).toEqualData(mockDataResponse); + }) + }); + + //TODO: Test making a new relationship between two people so they are friends + + + //TODO: Test requests of persons once we know what the object will look like. +}) Added: rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/region_resources.spec URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/region_resources.spec?rev=1508141&view=auto ============================================================================== --- rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/region_resources.spec (added) +++ rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/region_resources.spec Mon Jul 29 17:18:19 2013 @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * 'License'); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +describe('Region Resources', function(){ + var mockBackend, region; + + beforeEach(module('common.resources')); + + beforeEach(function(){ + //A function to compare objects which resources return + this.addMatchers({ + toEqualData: function(expected) { + return angular.equals(this.actual, expected); + } + }); + }); + + beforeEach(inject(function(_$httpBackend_, Region){ + mockBackend = _$httpBackend_; + region = Region; + })); + + describe('Region get all', function(){ + it('returns a list of all regions', function(){ + var mockDataResponse = [{id: 1, locked: 0, renderOrder: 0}, {id: 2, locked: 1, renderOrder: 1}]; + + mockBackend.expectGET('/pages/123/regions'). + respond({meta: {}, data: mockDataResponse}); + + var regions = region.query({pageId: 123}); + + mockBackend.flush(); + + expect(regions).toEqualData(mockDataResponse) + }) + }); + + describe('Region get by id and update', function(){ + it('correctly returns a single region and updates it', function(){ + var mockDataResponse = {id: 1, locked: 0, renderOrder: 0}; + var mockPostData = {id: 1, locked: 1, renderOrder: 0}; + + mockBackend.expectGET('/pages/123/regions/1'). + respond({meta: {}, data: mockDataResponse}); + + var regions = region.get({pageId: 123, id: 1}); + + mockBackend.flush(); + + expect(regions).toEqualData(mockDataResponse) + + mockBackend.expectPOST('/pages/123/regions/1', mockPostData). + respond({meta: {}, data: mockPostData}); + + regions.locked = 1 + regions.$save({pageId: 123}); + + mockBackend.flush(); + + expect(regions).toEqualData(mockPostData); + }) + }); + + describe('post a new Region', function(){ + it('saves a new Region correctly', function(){ + var mockPostData = {locked: 0, renderOrder: 0}; + var mockDataResponse = {id: 1, locked: 0, renderOrder: 0}; + var mockDataResponse2 = {id: 2, locked: 0, renderOrder: 0}; + + mockBackend.expectPOST('/pages/123/regions'). + respond({meta: {}, data: mockDataResponse}); + + mockBackend.expectPOST('/pages/123/regions'). + respond({meta: {}, data: mockDataResponse2}); + + var regions = region.save({pageId: 123}, mockPostData); + var regions2 = region.save({pageId: 123}, mockPostData); + + mockBackend.flush(); + + expect(regions).toEqualData(mockDataResponse) + expect(regions2).toEqualData(mockDataResponse2) + + }) + }); + +}) Added: rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/region_widget_resources.spec URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/region_widget_resources.spec?rev=1508141&view=auto ============================================================================== --- rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/region_widget_resources.spec (added) +++ rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/region_widget_resources.spec Mon Jul 29 17:18:19 2013 @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * 'License'); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +describe('Region Widget Resources', function(){ + var mockBackend, regionWidget; + + beforeEach(module('common.resources')); + + beforeEach(function(){ + //A function to compare objects which resources return + this.addMatchers({ + toEqualData: function(expected) { + return angular.equals(this.actual, expected); + } + }); + }); + + beforeEach(inject(function(_$httpBackend_, RegionWidget){ + mockBackend = _$httpBackend_; + regionWidget = RegionWidget; + })); + + describe('RegionWidget get all', function(){ + it('returns a list of all region widgets', function(){ + var mockDataResponse = [{id: 1, type: 'opensocial', widgetId: 12, widgetUrl: 'http://example.com/gadget.xml', regionId: '44', collapsed: 0, locked: 0, hideChrome: 1, ownerId: 99, userPrefs: ''}, + {id: 1, type: 'opensocial', widgetId: 15, widgetUrl: 'http://example.com/gadget2.xml', regionId: '92', collapsed: 1, locked: 0, hideChrome: 0, ownerId: 102, userPrefs: ''}]; + + mockBackend.expectGET('/pages/123/regions/1/regionWidgets'). + respond({meta: {}, data: mockDataResponse}); + + var regionWidgets = regionWidget.query({pageId: 123, regionId: 1}); + + mockBackend.flush(); + + expect(regionWidgets).toEqualData(mockDataResponse) + }) + }); + + describe('RegionWidget get by id and update', function(){ + it('returns returns a single region widget with updated data', function(){ + var mockDataResponse = {id: 1, type: 'opensocial', widgetId: 12, widgetUrl: 'http://example.com/gadget.xml', regionId: '44', collapsed: 0, locked: 0, hideChrome: 1, ownerId: 99, userPrefs: ''}; + var mockPostData = {id: 1, type: 'w3c', widgetId: 12, widgetUrl: 'http://example.com/gadget.xml', regionId: '44', collapsed: 0, locked: 0, hideChrome: 1, ownerId: 99, userPrefs: ''}; + + mockBackend.expectGET('/pages/123/regions/1/regionWidgets/1'). + respond({meta: {}, data: mockDataResponse}); + + var regionWidgets = regionWidget.get({pageId: 123, regionId: 1, id: 1}); + + mockBackend.flush(); + + expect(regionWidgets).toEqualData(mockDataResponse) + + mockBackend.expectPOST('/pages/123/regions/1/regionWidgets/1', mockPostData). + respond({meta: {}, data: mockPostData}); + + regionWidgets.type = 'w3c'; + + regionWidgets.$save({pageId: 123, regionId: 1}); + + mockBackend.flush(); + + expect(regionWidgets).toEqualData(mockPostData); + }) + }); + + describe('post a new RegionWidget', function(){ + it('saves a new RegionWidget successfully', function(){ + var mockPostData = {type: 'opensocial', widgetId: 12, widgetUrl: 'http://example.com/gadget.xml', regionId: '44', collapsed: 0, locked: 0, hideChrome: 1, ownerId: 99, userPrefs: ''}; + var mockDataResponse = {id: 1, type: 'opensocial', widgetId: 12, widgetUrl: 'http://example.com/gadget.xml', regionId: '44', collapsed: 0, locked: 0, hideChrome: 1, ownerId: 99, userPrefs: ''}; + var mockDataResponse2 = {id: 2, type: 'opensocial', widgetId: 12, widgetUrl: 'http://example.com/gadget.xml', regionId: '44', collapsed: 0, locked: 0, hideChrome: 1, ownerId: 99, userPrefs: ''}; + + mockBackend.expectPOST('/pages/123/regions/1/regionWidgets', mockPostData). + respond({meta: {}, data: mockDataResponse}); + + mockBackend.expectPOST('/pages/123/regions/1/regionWidgets', mockPostData). + respond({meta: {}, data: mockDataResponse2}); + + var regionWidgets = regionWidget.save({pageId: 123, regionId: 1}, mockPostData); + var regionWidgets2 = regionWidget.save({pageId: 123, regionId: 1}, mockPostData); + + mockBackend.flush(); + + expect(regionWidgets).toEqualData(mockDataResponse) + expect(regionWidgets2).toEqualData(mockDataResponse2) + }) + }); +}) Added: rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/user_resources.spec URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/user_resources.spec?rev=1508141&view=auto ============================================================================== --- rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/user_resources.spec (added) +++ rave/branches/angular/rave-portal-resources/src/test/javascript/common/resources/user_resources.spec Mon Jul 29 17:18:19 2013 @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * 'License'); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +describe('User Resources', function(){ + var mockBackend, user; + + beforeEach(module('common.resources')); + + beforeEach(function(){ + //A function to compare objects which resources return + this.addMatchers({ + toEqualData: function(expected) { + return angular.equals(this.actual, expected); + } + }); + }); + + beforeEach(inject(function(_$httpBackend_, User){ + mockBackend = _$httpBackend_; + user = User; + })); + + describe('User get all', function(){ + it('returns a list of all users', function(){ + var mockDataResponse = [{id: 1, username: 'dgornstein', password: 'aHash', email: '[email protected]', locked: 0, enabled: 1}, + {id: 2, username: 'jdoe', password: 'aHash', email: '[email protected]', locked: 1, enabled: 1}]; + + mockBackend.expectGET('/users'). + respond({meta: {}, data: mockDataResponse}); + + var users = user.query(); + + mockBackend.flush(); + + expect(users).toEqualData(mockDataResponse) + }) + }); + + describe('User get by id and update', function(){ + it('returns a single user and updates correctly', function(){ + var mockDataResponse = {id: 1, username: 'dgornstein', password: 'aHash', email: '[email protected]', locked: 0, enabled: 1}; + var mockPostData = {id: 1, username: 'dgornstein', password: 'aHash', email: '[email protected]', locked: 1, enabled: 0}; + + mockBackend.expectGET('/users/1'). + respond({meta: {}, data: mockDataResponse}); + + var users = user.get({id: 1}); + + mockBackend.flush(); + + expect(users).toEqualData(mockDataResponse) + + mockBackend.expectPOST('/users/1', mockPostData). + respond({meta: {}, data: mockPostData}); + + users.locked = 1; + users.enabled = 0; + + users.$save(); + + mockBackend.flush(); + + expect(users).toEqualData(mockPostData); + }) + }); + + describe('post a new User', function(){ + it('creates a new user correctly', function(){ + var mockDataResponse = {id: 1, username: 'dgornstein', password: 'aHash', email: '[email protected]', locked: 0, enabled: 1}; + var mockDataResponse2 = {id: 2, username: 'dgornstein', password: 'aHash', email: '[email protected]', locked: 0, enabled: 1}; + var mockPostData = {username: 'dgornstein', password: 'aHash', email: '[email protected]', locked: 0, enabled: 1}; + + mockBackend.expectPOST('/users', mockPostData). + respond({meta: {}, data: mockDataResponse}); + + mockBackend.expectPOST('/users', mockPostData). + respond({meta: {}, data: mockDataResponse2}); + + var users = user.save(mockPostData); + var users2 = user.save(mockPostData); + + mockBackend.flush(); + + expect(users).toEqualData(mockDataResponse); + expect(users2).toEqualData(mockDataResponse2); + }) + }); + +}) Modified: rave/branches/angular/rave-portal-resources/src/test/requireConfig.js URL: http://svn.apache.org/viewvc/rave/branches/angular/rave-portal-resources/src/test/requireConfig.js?rev=1508141&r1=1508140&r2=1508141&view=diff ============================================================================== --- rave/branches/angular/rave-portal-resources/src/test/requireConfig.js (original) +++ rave/branches/angular/rave-portal-resources/src/test/requireConfig.js Mon Jul 29 17:18:19 2013 @@ -22,7 +22,10 @@ require.config({ paths:{ "osapi": "/src/test/dependencies/osapi", "jquery": "/src/test/dependencies/jquery", - "underscore": "/src/test/dependencies/underscore" + "underscore": "/src/test/dependencies/underscore", + "angular": "/src/test/dependencies/angular", + "angularResource": "/src/test/dependencies/angular-resource", + "angularMocks": "/src/test/dependencies/angular-mocks" }, shim: { underscore:{ @@ -30,6 +33,16 @@ require.config({ }, jquery:{ exports: '$' + }, + angular:{ + exports: 'angular', + deps:['jquery'] + }, + angularResource:{ + deps:['angular'] + }, + angularMocks:{ + deps:['angularResource'] } } });
