Skip to content

Commit

Permalink
Merge pull request #590 from CruGlobal/develop
Browse files Browse the repository at this point in the history
develop > master
  • Loading branch information
reldredge71 committed Oct 26, 2018
2 parents 1f09b16 + ed4a695 commit b16f204
Show file tree
Hide file tree
Showing 34 changed files with 1,095 additions and 411 deletions.
24 changes: 9 additions & 15 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
"ErrorUtils": true
},
"rules": {
"prettier/prettier": "error",
"strict": 0,
"no-console": 2,
"no-case-declarations": 0,
"import/order": [2, {
"newlines-between": "always"
}],
"import/order": [
2,
{
"newlines-between": "always"
}
],
"react/jsx-no-undef": 2,
"react/jsx-uses-vars": 2,
"react/jsx-uses-react": 2,
Expand All @@ -47,18 +49,10 @@
"settings": {
"import/resolver": {
"node": {
"extensions": [
".js",
".ios.js",
".android.js"
]
"extensions": [".js", ".ios.js", ".android.js"]
}
}
},
"extends": "plugin:prettier/recommended",
"plugins": [
"react",
"import",
"prettier"
]
"extends": "prettier",
"plugins": ["react", "import"]
}
102 changes: 51 additions & 51 deletions .travis.yml

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions __tests__/actions/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
DISABLE_WELCOME_NOTIFICATION,
NAVIGATE_FORWARD,
LOAD_HOME_NOTIFICATION_REMINDER,
REQUEST_NOTIFICATIONS,
} from '../../src/constants';
import * as common from '../../src/utils/common';
import callApi, { REQUESTS } from '../../src/actions/api';
Expand Down Expand Up @@ -50,7 +51,7 @@ beforeEach(() => {
describe('showReminderScreen', () => {
const descriptionText = 'test description';

it('should do nothing for Android', () => {
it('should request permissions from device for Android', () => {
const store = mockStore({
notifications: {
pushDevice: {},
Expand All @@ -59,6 +60,7 @@ describe('showReminderScreen', () => {
common.isAndroid = true;
store.dispatch(showReminderScreen());
expect(PushNotification.checkPermissions).not.toHaveBeenCalled();
expect(store.getActions()).toEqual([{ type: REQUEST_NOTIFICATIONS }]);
});
it('should do nothing if we already have a token', () => {
const store = mockStore({
Expand All @@ -80,7 +82,7 @@ describe('showReminderScreen', () => {
store.dispatch(showReminderScreen(descriptionText));
expect(store.getActions()).toEqual([]);
});
it('should do nothing if permissions are already granted', () => {
it('should request permissions from device permissions are already granted by user', () => {
const store = mockStore({
notifications: {
pushDevice: {},
Expand All @@ -91,7 +93,7 @@ describe('showReminderScreen', () => {
);
store.dispatch(showReminderScreen(descriptionText));

expect(store.getActions()).toEqual([]);
expect(store.getActions()).toEqual([{ type: REQUEST_NOTIFICATIONS }]);
});
it('should show Notification Primer screen', () => {
const store = mockStore({
Expand Down
19 changes: 19 additions & 0 deletions __tests__/components/GroupCardItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const uncontactedCount = 56;
let group = {
name: 'Group Name',
contactReport: {},
user_created: false,
};

const test = () => {
Expand All @@ -21,6 +22,20 @@ describe('GroupCardItem', () => {
test();
});

it('renders with no report counts for user created org', () => {
group = {
...group,
contactReport: {
contactsCount,
unassignedCount,
uncontactedCount,
},
user_created: true,
};

test();
});

it('renders with all report counts', () => {
group = {
...group,
Expand All @@ -29,6 +44,7 @@ describe('GroupCardItem', () => {
unassignedCount,
uncontactedCount,
},
user_created: false,
};

test();
Expand All @@ -41,6 +57,7 @@ describe('GroupCardItem', () => {
contactsCount,
unassignedCount,
},
user_created: false,
};

test();
Expand All @@ -53,6 +70,7 @@ describe('GroupCardItem', () => {
contactsCount,
uncontactedCount,
},
user_created: false,
};

test();
Expand All @@ -64,6 +82,7 @@ describe('GroupCardItem', () => {
contactReport: {
contactsCount,
},
user_created: false,
};

test();
Expand Down
14 changes: 14 additions & 0 deletions __tests__/components/GroupsPersonHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ const contactAssignment = {
organization: { id: '231413' },
};
const myStageId = 4;
const isCruOrg = true;

const props = {
person,
organization,
dispatch,
myId,
stages,
isCruOrg,
};

const phoneNumber = { number: '1800Roge' };
Expand Down Expand Up @@ -117,6 +119,12 @@ describe('isMember', () => {
);
});

it('renders no contact buttons for User-Created Org', () => {
testSnapshotShallow(
<GroupsPersonHeader {...props} isMember={true} isCruOrg={false} />,
);
});

describe('has contact info and contact assignment', () => {
beforeEach(() => {
getPersonEmailAddress.mockReturnValue(emailAddress);
Expand Down Expand Up @@ -238,6 +246,12 @@ describe('isContact', () => {
);
});

it('renders no contact buttons for User-Created Org', () => {
testSnapshotShallow(
<GroupsPersonHeader {...props} isMember={false} isCruOrg={false} />,
);
});

it('should navigate to person stage screen', () => {
const screen = renderShallow(
<GroupsPersonHeader
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/PersonSideMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const organization = { id: '4', type: 'organization' };

const store = createMockStore({
auth: {
isJean: true,
person: me,
},
people: {
Expand All @@ -70,6 +69,7 @@ const createComponent = () => {
navigation={createMockNavState({
person,
organization,
isCruOrg: true,
})}
/>,
store,
Expand Down
45 changes: 45 additions & 0 deletions __tests__/components/__snapshots__/GroupCardItem.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,48 @@ exports[`GroupCardItem renders with no report counts 1`] = `
</Flex>
</Card>
`;

exports[`GroupCardItem renders with no report counts for user created org 1`] = `
<Card
onPress={[Function]}
style={
Object {
"alignItems": "center",
"backgroundColor": "#ffffff",
"borderBottomColor": "#E6E8EC",
"borderBottomWidth": 1,
"flexDirection": "row",
"marginHorizontal": 16,
"marginVertical": 8,
"paddingHorizontal": 13,
"paddingVertical": 16,
}
}
>
<Flex>
<MyText
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
style={
Object {
"color": "#007398",
"fontSize": 16,
"fontWeight": "bold",
}
}
>
GROUP NAME
</MyText>
<Flex
align="center"
direction="row"
style={
Object {
"paddingTop": 4,
}
}
/>
</Flex>
</Card>
`;
46 changes: 46 additions & 0 deletions __tests__/components/__snapshots__/GroupsPersonHeader.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@ exports[`isContact with contact assignment does not render status button if cont
</Flex>
`;

exports[`isContact with contact assignment renders no contact buttons for User-Created Org 1`] = `
<Flex>
<Connect(Translate(AssignToMeButton))
organization={
Object {
"id": "50",
}
}
person={
Object {
"first_name": "Roge",
"id": "1002",
}
}
/>
<Flex
align="center"
direction="row"
justify="center"
/>
</Flex>
`;

exports[`isContact with contact assignment renders status button if contact is part of org 1`] = `
<Flex>
<Flex
Expand Down Expand Up @@ -170,6 +193,29 @@ exports[`isMember has contact info and contact assignment renders 1`] = `
</Flex>
`;

exports[`isMember renders no contact buttons for User-Created Org 1`] = `
<Flex>
<Connect(Translate(AssignToMeButton))
organization={
Object {
"id": "50",
}
}
person={
Object {
"first_name": "Roge",
"id": "1002",
}
}
/>
<Flex
align="center"
direction="row"
justify="center"
/>
</Flex>
`;

exports[`isMember renders null because its not supposed to be visible 1`] = `""`;

exports[`isMember renders with no contact assignment and no contact info 1`] = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jest.mock('../../../../src/selectors/organizations');
jest.mock('../../../../src/actions/navigation', () => ({
navigateBack: jest.fn(() => ({ type: 'test' })),
}));
jest.mock('../../../../src/utils/common');

const organization = { id: '1', name: 'Test Org' };
const person = { id: '1', first_name: 'Test Person' };
Expand Down Expand Up @@ -73,6 +74,7 @@ const props = {
myId: myId,
stages: stages,
isMember: true,
isCruOrg: true,
};

beforeEach(() => {
Expand All @@ -82,6 +84,7 @@ beforeEach(() => {
describe('Contact', () => {
it('should provide necessary props', () => {
organizationSelector.mockReturnValue(undefined);
common.communityIsCru.mockReturnValue(true);

expect(mapStateToProps(store, nav)).toEqual({
organization,
Expand All @@ -90,7 +93,9 @@ describe('Contact', () => {
myId,
stages,
myStageId: pathwayStage.id,
isCruOrg: true,
});
expect(common.communityIsCru).toHaveBeenCalledWith(organization);
});

it('should render AssignedPersonScreen correctly without stage', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ exports[`Contact hides the header when the keyboard is shown 1`] = `
],
}
}
isCruOrg={true}
isMember={true}
isVisible={false}
myId="1000"
Expand Down Expand Up @@ -161,6 +162,7 @@ exports[`Contact should render AssignedPersonScreen correctly with stage 1`] = `
],
}
}
isCruOrg={true}
isMember={true}
isVisible={true}
myId="1000"
Expand Down Expand Up @@ -249,6 +251,7 @@ exports[`Contact should render AssignedPersonScreen correctly without stage 1`]
],
}
}
isCruOrg={true}
isMember={true}
isVisible={true}
myId="1000"
Expand Down

0 comments on commit b16f204

Please sign in to comment.