Skip to content
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

Update tests for custom admin path #4375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion admin/client/App/sagas/queryParamsSagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function * evalQueryParams () {
const { cachedQuery } = yield select(state => state.active);
const { currentList } = yield select(state => state.lists);

if (pathname !== `/keystone/${currentList.id}`) return;
if (pathname !== `/${Keystone.adminPath}/${currentList.id}`) return;

if (isEqual(query, cachedQuery)) {
yield put({ type: actions.QUERY_HAS_NOT_CHANGED });
Expand Down
14 changes: 10 additions & 4 deletions admin/client/App/sagas/test/queryParamsSagas.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import * as actions from '../../screens/List/constants.js';
import { replace, push } from 'react-router-redux';

describe('<List /> query param sagas', function () {
beforeEach(() => {
global.Keystone = {
adminPath: 'admin',
};
});

describe('* urlUpdate()', function () {
describe('Given a query object and a cache object', function () {
describe('If the query object sans search, is the same as the cache object sans search', function () {
Expand Down Expand Up @@ -66,7 +72,7 @@ describe('<List /> query param sagas', function () {
const size = 100;

const page = { index, size };
const pathname = `/keystone/${currentList.id}`;
const pathname = `/${Keystone.adminPath}/${currentList.id}`;
const query = {};
const location = { pathname, query };

Expand Down Expand Up @@ -145,7 +151,7 @@ describe('<List /> query param sagas', function () {
describe('If the pathame is is not valid', function () {
it('bails out', function () {
const generator = evalQueryParams();
const pathname = '/keystone/badUrl';
const pathname = `/${Keystone.adminPath}/badUrl`;
const query = { query: 'some query' };
const locationBeforeTransitions = {
pathname,
Expand Down Expand Up @@ -178,7 +184,7 @@ describe('<List /> query param sagas', function () {
describe('If the query and the cached query are the same', function () {
it('puts a QUERY HAS NOT CHANGED action to the store', function () {
const generator = evalQueryParams();
const pathname = '/keystone/Dictators';
const pathname = `/${Keystone.adminPath}/Dictators`;
const query = { someKey: 'someValue' };
const cachedQuery = { someKey: 'someValue' };
const locationBeforeTransitions = {
Expand Down Expand Up @@ -211,7 +217,7 @@ describe('<List /> query param sagas', function () {
describe('If the query and the cached query are different', function () {
it('parses the query and puts QUERY HAS CHANGED to the store', function () {
const generator = evalQueryParams();
const pathname = '/keystone/collection';
const pathname = `/${Keystone.adminPath}/collection`;
const query = { columns: ['name', 'email'], search: 'test search' };
const parsedQuery = {
columns: ['name', 'email'],
Expand Down