Skip to content

Commit

Permalink
Step 6.6: Tests of PartyDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Kisiela authored and DAB0mB committed Dec 14, 2016
1 parent 7a42433 commit bb81944
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions imports/ui/components/partyDetails/client/partyDetails.tests.js
@@ -0,0 +1,49 @@
import { name as PartyDetails } from '../partyDetails';
import { Parties } from '../../../../api/parties';
import 'angular-mocks';

describe('PartyDetails', () => {
beforeEach(() => {
window.module(PartyDetails);
});

describe('controller', () => {
let controller;
const party = {
_id: 'partyId',
name: 'Foo',
description: 'Birthday of Foo'
};

beforeEach(() => {
inject(($rootScope, $componentController) => {
controller = $componentController(PartyDetails, {
$scope: $rootScope.$new(true)
});
});
});

describe('save()', () => {
beforeEach(() => {
spyOn(Parties, 'update');
controller.party = party;
controller.save();
});

it('should update a proper party', () => {
expect(Parties.update.calls.mostRecent().args[0]).toEqual({
_id: party._id
});
});

it('should update with proper modifier', () => {
expect(Parties.update.calls.mostRecent().args[1]).toEqual({
$set: {
name: party.name,
description: party.description
}
});
});
});
});
});

0 comments on commit bb81944

Please sign in to comment.