Skip to content

Commit

Permalink
Step 4.22: Tests of PartyAdd
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 1fa2641 commit c247078
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions imports/ui/components/partyAdd/client/partyAdd.tests.js
@@ -0,0 +1,53 @@
import { name as PartyAdd } from '../partyAdd';
import { Parties } from '../../../../api/parties';
import 'angular-mocks';

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

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

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

describe('reset()', () => {
it('should clean up party object', () => {
controller.party = party;
controller.reset();

expect(controller.party).toEqual({});
});
});

describe('submit()', () => {
beforeEach(() => {
spyOn(Parties, 'insert');
spyOn(controller, 'reset').and.callThrough();

controller.party = party;

controller.submit();
});

it('should insert a new party', () => {
expect(Parties.insert).toHaveBeenCalledWith(party);
});

it('should call reset()', () => {
expect(controller.reset).toHaveBeenCalled();
});
});
});
});

0 comments on commit c247078

Please sign in to comment.