Feature: Ability to set an account name (#667)
* Ability to change the account name * Ability to set a language to the account Addresses: #667 #307 Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a1a81e3799
commit
99eaf59509
@@ -11,3 +11,12 @@ export const conversationUrl = (accountId, activeInbox, id) => {
|
||||
: `accounts/${accountId}/conversations/${id}`;
|
||||
return path;
|
||||
};
|
||||
|
||||
export const accountIdFromPathname = pathname => {
|
||||
const isInsideAccountScopedURLs = pathname.includes('/app/accounts');
|
||||
const urlParam = pathname.split('/')[3];
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
const isScoped = isInsideAccountScopedURLs && !isNaN(urlParam);
|
||||
const accountId = isScoped ? Number(urlParam) : '';
|
||||
return accountId;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { frontendURL, conversationUrl } from '../URLHelper';
|
||||
import {
|
||||
frontendURL,
|
||||
conversationUrl,
|
||||
accountIdFromPathname,
|
||||
} from '../URLHelper';
|
||||
|
||||
describe('#URL Helpers', () => {
|
||||
describe('conversationUrl', () => {
|
||||
@@ -22,4 +26,26 @@ describe('#URL Helpers', () => {
|
||||
expect(frontendURL('main', { ping: 'pong' })).toBe('/app/main?ping=pong');
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
export const accountIdFromPathname = pathname => {
|
||||
const isInsideAccountScopedURLs = pathname.includes('/app/accounts');
|
||||
const accountId = isInsideAccountScopedURLs ? pathname.split('/')[3] : '';
|
||||
return Number(accountId);
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
describe('accountIdFromPathname', () => {
|
||||
it('should return account id if accont scoped url is passed', () => {
|
||||
expect(accountIdFromPathname('/app/accounts/1/settings/general')).toBe(1);
|
||||
});
|
||||
it('should return empty string if accont scoped url not is passed', () => {
|
||||
expect(accountIdFromPathname('/app/accounts/settings/general')).toBe('');
|
||||
});
|
||||
it('should return empty string if empty string is passed', () => {
|
||||
expect(accountIdFromPathname('')).toBe('');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user