Skip to content

feat: Support pagination in issue-list screen and pull-list screen #856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 0 additions & 96 deletions __tests__/tests/reducers/issue.reducer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import {
GET_ISSUE_COMMENTS,
POST_ISSUE_COMMENT,
DELETE_ISSUE_COMMENT,
EDIT_ISSUE_COMMENT,
Expand All @@ -11,9 +10,7 @@ import {
GET_ISSUE_MERGE_STATUS,
GET_PULL_REQUEST_FROM_URL,
MERGE_PULL_REQUEST,
GET_ISSUE_FROM_URL,
SUBMIT_NEW_ISSUE,
GET_ISSUE_EVENTS,
} from 'issue/issue.type';
import { initialState, issueReducer } from 'issue/issue.reducer';
import { open } from '../../data/api/issue';
Expand All @@ -23,68 +20,6 @@ describe('Issuer Reducer', () => {
expect(issueReducer()).toEqual(initialState);
});

describe('GET_ISSUE_COMMENTS', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for cleaning this up 🚀

it('.PENDING should set pending state', () => {
const action = { type: GET_ISSUE_COMMENTS.PENDING };
const expectedState = { ...initialState, isPendingComments: true };

expect(issueReducer(initialState, action)).toEqual(expectedState);
});

it('.ERROR should set error state', () => {
const action = { type: GET_ISSUE_COMMENTS.ERROR, payload: 'error' };
const expectedState = {
...initialState,
isPendingComments: false,
error: 'error',
};

expect(issueReducer(initialState, action)).toEqual(expectedState);
});

it('.SUCCESS should set comments', () => {
const action = { type: GET_ISSUE_COMMENTS.SUCCESS, payload: [{}] };
const expectedState = {
...initialState,
isPendingComments: false,
comments: action.payload,
};

expect(issueReducer(initialState, action)).toEqual(expectedState);
});
});

describe('GET_ISSUE_EVENTS', () => {
it('.PENDING should set pending state', () => {
const action = { type: GET_ISSUE_EVENTS.PENDING };
const expectedState = { ...initialState, isPendingEvents: true };

expect(issueReducer(initialState, action)).toEqual(expectedState);
});

it('.ERROR should set error state', () => {
const action = { type: GET_ISSUE_EVENTS.ERROR, payload: 'error' };
const expectedState = {
...initialState,
isPendingEvents: false,
error: 'error',
};

expect(issueReducer(initialState, action)).toEqual(expectedState);
});

it('.SUCCESS should set events', () => {
const action = { type: GET_ISSUE_EVENTS.SUCCESS, payload: [{}] };
const expectedState = {
...initialState,
isPendingEvents: false,
events: action.payload,
};

expect(issueReducer(initialState, action)).toEqual(expectedState);
});
});

describe('POST_ISSUE_COMMENT', () => {
it('.PEDNING should set pending state', () => {
const action = { type: POST_ISSUE_COMMENT.PENDING };
Expand Down Expand Up @@ -521,37 +456,6 @@ describe('Issuer Reducer', () => {
});
});

describe('GET_ISSUE_FROM_URL', () => {
it('.PENDING should set pending state', () => {
const action = { type: GET_ISSUE_FROM_URL.PENDING };
const expectedState = { ...initialState, isPendingIssue: true };

expect(issueReducer(initialState, action)).toEqual(expectedState);
});

it('.ERROR should set error state', () => {
const action = { type: GET_ISSUE_FROM_URL.ERROR, payload: 'error' };
const expectedState = {
...initialState,
isPendingIssue: false,
error: 'error',
};

expect(issueReducer(initialState, action)).toEqual(expectedState);
});

it('.SUCCESS should set issue', () => {
const action = { type: GET_ISSUE_FROM_URL.SUCCESS, payload: open };
const expectedState = {
...initialState,
isPendingIssue: false,
issue: action.payload,
};

expect(issueReducer(initialState, action)).toEqual(expectedState);
});
});

describe('SUBMIT_NEW_ISSUE', () => {
it('.PENDING should set pending state', () => {
const action = { type: SUBMIT_NEW_ISSUE.PENDING };
Expand Down
210 changes: 0 additions & 210 deletions __tests__/tests/reducers/repository.reducer.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import {
GET_REPOSITORY,
GET_REPOSITORY_CONTRIBUTORS,
GET_REPOSITORY_CONTENTS,
GET_REPOSITORY_FILE,
GET_REPOSITORY_README,
GET_REPOSITORY_LABELS,
SEARCH_OPEN_ISSUES,
SEARCH_CLOSED_ISSUES,
SEARCH_OPEN_PULLS,
SEARCH_CLOSED_PULLS,
} from 'repository/repository.type';

import { initialState, repositoryReducer } from 'repository/repository.reducer';
Expand All @@ -18,84 +12,6 @@ describe('Repository Reducer', () => {
expect(repositoryReducer(undefined)).toEqual(initialState);
});

describe('GET_REPOSITORY', () => {
it('.PENDING should set state to pending', () => {
const action = { type: GET_REPOSITORY.PENDING };
const expectedState = {
...initialState,
isPendingRepository: true,
contributors: [],
issues: [],
readMe: '',
hasRepoExist: false,
hasReadMe: false,
error: '',
topics: [],
isPendingRepository: true,
};

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});

it('.ERROR should set error state', () => {
const action = { type: GET_REPOSITORY.ERROR, payload: 'error' };
const expectedState = { ...initialState, error: action.payload };

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});

it('.SUCCESS should set repository', () => {
const action = { type: GET_REPOSITORY.SUCCESS, payload: { id: 1 } };
const expectedState = {
...initialState,
repository: action.payload,
hasRepoExist: true,
error: '',
isPendingRepository: false,
};

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});
});

describe('GET_REPOSITORY_CONTRIBUTORS', () => {
it('.PENDING should set pending state', () => {
const action = { type: GET_REPOSITORY_CONTRIBUTORS.PENDING };
const expectedState = { ...initialState, isPendingContributors: true };

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});

it('.ERROR should set error state', () => {
const action = {
type: GET_REPOSITORY_CONTRIBUTORS.ERROR,
payload: 'error',
};
const expectedState = {
...initialState,
error: action.payload,
isPendingContributors: false,
contributors: [],
};

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});

it('.SUCCESS should set contributors', () => {
const action = {
type: GET_REPOSITORY_CONTRIBUTORS.SUCCESS,
payload: [{ id: 1 }],
};
const expectedState = {
...initialState,
isPendingContributors: false,
contributors: action.payload,
};

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});
});

describe('GET_REPOSITORY_CONTENTS', () => {
it('.PENDING should set pending state', () => {
const action = { type: GET_REPOSITORY_CONTENTS.PENDING };
Expand Down Expand Up @@ -226,130 +142,4 @@ describe('Repository Reducer', () => {
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});
});

describe('SEARCH_OPEN_ISSUES', () => {
it('.PENDING should set pending state', () => {
const action = { type: SEARCH_OPEN_ISSUES.PENDING };
const expectedState = {
...initialState,
searchedOpenIssues: [],
isPendingSearchOpenIssues: true,
};

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});

it('.ERROR should set error state', () => {
const action = { type: SEARCH_OPEN_ISSUES.ERROR, payload: 'error' };
const expectedState = { ...initialState, error: action.payload };

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});

it('.SUCCESS should set searched open issues', () => {
const action = { type: SEARCH_OPEN_ISSUES.SUCCESS, payload: [{ id: 1 }] };
const expectedState = {
...initialState,
searchedOpenIssues: action.payload,
};

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});
});

describe('SEARCH_CLOSED_ISSUES', () => {
it('.PENDING should set pending state', () => {
const action = { type: SEARCH_CLOSED_ISSUES.PENDING };
const expectedState = {
...initialState,
searchedClosedIssues: [],
isPendingSearchClosedIssues: true,
};

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});

it('.ERROR should set error state', () => {
const action = { type: SEARCH_CLOSED_ISSUES.ERROR, payload: 'error' };
const expectedState = { ...initialState, error: action.payload };

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});

it('.SUCCESS should set searched closed issues', () => {
const action = {
type: SEARCH_CLOSED_ISSUES.SUCCESS,
payload: [{ id: 1 }],
};
const expectedState = {
...initialState,
searchedClosedIssues: action.payload,
};

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});
});

describe('SEARCH_OPEN_PULLS', () => {
it('.PENDING should set pending state', () => {
const action = { type: SEARCH_OPEN_PULLS.PENDING };
const expectedState = {
...initialState,
searchedOpenPulls: [],
isPendingSearchOpenPulls: true,
};

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});

it('.ERROR should set error state', () => {
const action = { type: SEARCH_OPEN_PULLS.ERROR, payload: 'error' };
const expectedState = { ...initialState, error: action.payload };

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});

it('.SUCCESS should set search open pulls', () => {
const action = { type: SEARCH_OPEN_PULLS.SUCCESS, payload: [{ id: 1 }] };
const expectedState = {
...initialState,
searchedOpenPulls: action.payload,
};

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});
});

describe('SEARCH_CLOSED_PULLS', () => {
it('.PENDING should set pending state', () => {
const action = { type: SEARCH_CLOSED_PULLS.PENDING };
const expectedState = {
...initialState,
searchedClosedPulls: [],
isPendingSearchClosedPulls: true,
};

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});

it('.ERROR should set error state', () => {
const action = { type: SEARCH_CLOSED_PULLS.ERROR, payload: 'error' };
const expectedState = { ...initialState, error: action.payload };

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});

it('.SUCCESS should set search closed pulls', () => {
const action = {
type: SEARCH_CLOSED_PULLS.SUCCESS,
payload: [{ id: 1 }],
};
const expectedState = {
...initialState,
searchedClosedPulls: action.payload,
};

expect(repositoryReducer(initialState, action)).toEqual(expectedState);
});
});
});
1 change: 1 addition & 0 deletions src/api/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const ACTIVITY_WATCH_REPO = createActionSet('ACTIVITY_WATCH_REPO');
export const ACTIVITY_UNWATCH_REPO = createActionSet('ACTIVITY_UNWATCH_REPO');
export const SEARCH_REPOS = createPaginationActionSet('SEARCH_REPOS');
export const SEARCH_USERS = createPaginationActionSet('SEARCH_USERS');
export const SEARCH_ISSUES = createPaginationActionSet('SEARCH_ISSUES');
Copy link
Member

Choose a reason for hiding this comment

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

👍

export const ORGS_GET_MEMBERS = createPaginationActionSet('ORGS_GET_MEMBERS');
export const ORGS_GET_BY_ID = createActionSet('ORGS_GET_BY_ID');

Expand Down
Loading