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

Adding tests for accountTypes and buildAccount #1350

Merged
merged 5 commits into from
Jan 31, 2025
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
124 changes: 124 additions & 0 deletions lib/__tests__/accountTypes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
import {
isStandardAccount,
isSandbox,
isStandardSandbox,
isDevelopmentSandbox,
isDeveloperTestAccount,
isAppDeveloperAccount,
} from '../accountTypes';

const STANDARD_ACCOUNT: CLIAccount = {
name: 'standard-account',
accountId: 123,
accountType: HUBSPOT_ACCOUNT_TYPES.STANDARD,
env: 'prod',
};

const DEVELOPMENT_SANDBOX_ACCOUNT: CLIAccount = {
name: 'development-sandbox-account',
accountId: 456,
accountType: HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
env: 'prod',
};

const STANDARD_SANDBOX_ACCOUNT: CLIAccount = {
name: 'sandbox-account',
accountId: 456,
accountType: HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX,
env: 'prod',
};

const DEVELOPER_TEST_ACCOUNT: CLIAccount = {
name: 'developer-test-account',
accountId: 789,
accountType: HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST,
env: 'prod',
};

const APP_DEVELOPER_ACCOUNT: CLIAccount = {
name: 'app-developer-account',
accountId: 1011,
accountType: HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER,
env: 'prod',
};

describe('lib/accountTypes', () => {
describe('isStandardAccount()', () => {
it('should return true if the account is a standard account', () => {
const result = isStandardAccount(STANDARD_ACCOUNT);
expect(result).toBe(true);
});

it('should return false if the account is not a standard account', () => {
const result = isStandardAccount(DEVELOPER_TEST_ACCOUNT);
expect(result).toBe(false);
});
});

describe('isSandbox()', () => {
it('should return true if the account is a standard sandbox account', () => {
const result = isSandbox(STANDARD_SANDBOX_ACCOUNT);
expect(result).toBe(true);
});

it('should return true if the account is a development sandbox account', () => {
const result = isSandbox(DEVELOPMENT_SANDBOX_ACCOUNT);
expect(result).toBe(true);
});

it('should return false if the account is not a sandbox account', () => {
const result = isSandbox(STANDARD_ACCOUNT);
expect(result).toBe(false);
});
});

describe('isStandardSandbox()', () => {
it('should return true if the account is a standard sandbox account', () => {
const result = isStandardSandbox(STANDARD_SANDBOX_ACCOUNT);
expect(result).toBe(true);
});

it('should return false if the account is not a standard sandbox account', () => {
const result = isStandardSandbox(DEVELOPMENT_SANDBOX_ACCOUNT);
expect(result).toBe(false);
});
});

describe('isDevelopmentSandbox()', () => {
it('should return true if the account is a development sandbox account', () => {
const result = isDevelopmentSandbox(DEVELOPMENT_SANDBOX_ACCOUNT);
expect(result).toBe(true);
});

it('should return false if the account is not a development sandbox account', () => {
const result = isDevelopmentSandbox(STANDARD_ACCOUNT);
expect(result).toBe(false);
});
});

describe('isDeveloperTestAccount()', () => {
it('should return true if the account is a developer test account', () => {
const result = isDeveloperTestAccount(DEVELOPER_TEST_ACCOUNT);
expect(result).toBe(true);
});

it('should return false if the account is not a developer test account', () => {
const result = isDeveloperTestAccount(STANDARD_ACCOUNT);
expect(result).toBe(false);
});
});

describe('isAppDeveloperAccount()', () => {
it('should return true if the account is an app developer account', () => {
const result = isAppDeveloperAccount(APP_DEVELOPER_ACCOUNT);
expect(result).toBe(true);
});

it('should return false if the account is not an app developer account', () => {
const result = isAppDeveloperAccount(STANDARD_ACCOUNT);
expect(result).toBe(false);
});
});
});
Loading
Loading