Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Remove duplication in action tests #139

Merged
merged 7 commits into from
Nov 13, 2015

Conversation

msecret
Copy link
Contributor

@msecret msecret commented Nov 12, 2015

An attempt to remove duplication in action tests, open to
opinions.

WIP, wanted feedback

An attempt to remove duplication in action tests, open to
opinions.
@@ -6,6 +6,15 @@ import cfApi from '../../../util/cf_api.js';
import serviceActions from '../../../actions/service_actions.js';
import { serviceActionTypes } from '../../../constants.js';

function assertAction(spy, type, params) {
expect(spy).toHaveBeenCalledOnce();
let arg = spy.getCall(0).args[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change arg to actualOrgGuidArg or something that lets the reader know that the arg being assigned should the org.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my only worry is the indices used for getCall and args i really doubt the order of the call or args will ever matter (since we are only expecting one call and the call will have just one arg for now for these org calls). but i'm just thinking how this will be used in case some other developer comes along trying to add tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with that said. i'm fine with it (the index hard coding) for now, and we can worry about it later when that time comes.

@@ -17,17 +18,40 @@ describe('serviceActions', function() {
sandbox.restore();
});

function setupViewSpy() {
return sandbox.spy(AppDispatcher, 'handleViewAction');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you find yourself referring to the string 'handleViewAction' or 'handleServerAction' elsewhere in the code, I would make those constants. i'm not sure if you do use them more than here. i remember i did that in the angular stuff and wished i didn't. too many places to find and replace when refactoring. your call on this one.

msecret and others added 5 commits November 12, 2015 15:47
msecret pushed a commit that referenced this pull request Nov 13, 2015
@msecret msecret merged commit de0cf2a into cloud-gov:staging-alpha Nov 13, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants