-
Notifications
You must be signed in to change notification settings - Fork 2
Test/development of existing test stubs #182
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
Open
pixxiec
wants to merge
9
commits into
dev
Choose a base branch
from
test/development-of-existing-test-stubs
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b63d1c6
Model tests
pixxiec 78971a4
Additional unit test work
pixxiec d6aa604
Additional testing
pixxiec a3131fb
Additional testing
pixxiec 3ed8fc0
Additional testing
pixxiec 61c09de
CircleCI failures
pixxiec 67c94bf
CircleCI failures
pixxiec 18de34d
CircleCI failures
pixxiec 6049e53
Final push
pixxiec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { ApiAddPermissionParams, callApiAddPermission } from './addPermission' | ||
| import { ApiEndpoint, ApiMessageResult, ChainNetwork, ExternalWalletType } from '../../models' | ||
| import * as helpers from '../helpers' | ||
| import OreIdContext from '../../core/IOreidContext' | ||
| import { createOreIdContext } from '../../test-utils' | ||
|
|
||
| function isApiAddPermissionParams(obj: any): obj is ApiAddPermissionParams { | ||
| return ( | ||
| 'account' in obj && | ||
| obj.account === 'account value' && | ||
| 'chainAccount' in obj && | ||
| obj.chainAccount === 'chainAccount value' && | ||
| 'chainNetwork' in obj && | ||
| obj.chainNetwork === 'algo_beta' && | ||
| 'parentPermission' in obj && | ||
| obj.parentPermission === 'geolocation' && | ||
| 'permission' in obj && | ||
| obj.permission === 'geolocation' && | ||
| 'provider' in obj && | ||
| obj.provider === 'algosigner' && | ||
| 'publicKey' in obj && | ||
| obj.publicKey === 'publicKey value' | ||
| ) | ||
| } | ||
|
|
||
| const aapp: ApiAddPermissionParams = { | ||
| account: 'account value', | ||
| chainAccount: 'chainAccount value', | ||
| chainNetwork: ChainNetwork.AlgoBeta, | ||
| parentPermission: 'geolocation', | ||
| permission: 'geolocation', | ||
| provider: ExternalWalletType.AlgoSigner, | ||
| publicKey: 'publicKey value', | ||
| } | ||
|
|
||
| describe('Api Add Permission Params type', () => { | ||
| test('type can be instantiated', () => { | ||
| expect(isApiAddPermissionParams(aapp)).toBeTruthy() | ||
| }) | ||
| }) | ||
|
|
||
| let oreIdContext: OreIdContext | ||
|
|
||
| beforeEach(() => { | ||
| oreIdContext = createOreIdContext() | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| jest.clearAllMocks() | ||
| }) | ||
|
|
||
| describe('Add API permission', () => { | ||
| test('should return a valid response', async () => { | ||
| const tpSpyKeyOrToken = jest.spyOn(helpers, 'assertHasApiKeyOrAccessToken') | ||
| const tpSpyReqdParams = jest.spyOn(helpers, 'assertParamsHaveRequiredValues') | ||
| const tpSpyApiCall = jest.spyOn(oreIdContext, 'callOreIdApi') | ||
| const resultValue: ApiMessageResult = { success: 'true' } | ||
| tpSpyApiCall.mockReturnValue(resultValue as Promise<ApiMessageResult>) | ||
| expect(tpSpyKeyOrToken).not.toBeCalled() | ||
| expect(tpSpyReqdParams).not.toBeCalled() | ||
| expect(tpSpyApiCall).not.toBeCalled() | ||
| const result: ApiMessageResult = await callApiAddPermission(oreIdContext, aapp) | ||
| expect(tpSpyKeyOrToken).toBeCalledWith(oreIdContext, ApiEndpoint.AddPermission) | ||
| expect(tpSpyApiCall).toBeCalled() | ||
| expect(result).toBeTruthy() | ||
| expect(result.success).toBeDefined() | ||
| expect(result.success).toEqual('true') | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { ApiGetAppTokenParams, callApiGetAppToken } from './appToken' | ||
| import { | ||
| ApiEndpoint, | ||
| AppAccessTokenMetadata, | ||
| RequestType, | ||
| ApiKeyUsedFor, | ||
| NewAccountAppTokenParams, | ||
| AccountType, | ||
| } from '../../models' | ||
| import { assertHasApiKey } from '../helpers' | ||
| import Helpers from '../../utils/helpers' | ||
| import * as helpers from '../helpers' | ||
| import OreIdContext from '../../core/IOreidContext' | ||
| import { createOreIdContext } from '../../test-utils' | ||
|
|
||
| function isApiGetAppTokenParams(obj: any): obj is ApiGetAppTokenParams { | ||
| return 'appAccessTokenMetadata' in obj && typeof obj.appAccessTokenMetadata === 'object' | ||
| } | ||
|
|
||
| const aatmd: AppAccessTokenMetadata = {} | ||
|
|
||
| const agatp: ApiGetAppTokenParams = { | ||
| appAccessTokenMetadata: aatmd, | ||
| } | ||
|
|
||
| describe('Api Get App Token Params type', () => { | ||
| test('type can be instantiated', () => { | ||
| expect(isApiGetAppTokenParams(agatp)).toBeTruthy() | ||
| }) | ||
| }) | ||
|
|
||
| let oreIdContext: OreIdContext | ||
|
|
||
| beforeEach(() => { | ||
| oreIdContext = createOreIdContext() | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| jest.clearAllMocks() | ||
| }) | ||
|
|
||
| describe('Get app token', () => { | ||
| test('should return a valid response', async () => { | ||
| const tpNullOrEmpty = jest.spyOn(Helpers, 'isNullOrEmpty') | ||
| const tpSpyReqdParams = jest.spyOn(helpers, 'assertHasApiKey') | ||
| const tpSpyApiCall = jest.spyOn(oreIdContext, 'callOreIdApi') | ||
| const resultValue = { appAccessToken: 'appAccessToken value' } | ||
| tpSpyApiCall.mockReturnValue(resultValue as unknown as Promise<string>) | ||
| expect(tpNullOrEmpty).not.toBeCalled() | ||
| expect(tpSpyReqdParams).not.toBeCalled() | ||
| expect(tpSpyApiCall).not.toBeCalled() | ||
| const result: string = await callApiGetAppToken(oreIdContext, agatp) | ||
| expect(tpNullOrEmpty).toBeCalledWith(agatp.appAccessTokenMetadata) | ||
| expect(tpSpyReqdParams).toBeCalledWith(oreIdContext, null, ApiEndpoint.AppToken) | ||
| expect(tpSpyApiCall).toBeCalled() | ||
| expect(result).toEqual('appAccessToken value') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiCanAutosignTransaction } from './canAutoSign' | ||
|
|
||
| describe('Can auto sign', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiConvertOauthTokens } from './convertOauth' | ||
|
|
||
| describe('Convert OAuth', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiCustodialMigrateAccount } from './custodialMigrateAccount' | ||
|
|
||
| describe('Custodial migrate account', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiCustodialNewAccount } from './custodialNewAccount' | ||
|
|
||
| describe('Custodial new account', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiDeleteTestUser } from './deleteTestUser' | ||
|
|
||
| describe('Delete test user', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiGetConfig } from './getConfig' | ||
|
|
||
| describe('Get config', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiGetUser } from './getUser' | ||
|
|
||
| describe('Get user', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiLoginUserWithToken } from './loginUserWithToken' | ||
|
|
||
| describe('Login user with token', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiNewUserWithToken } from './newUserWithToken' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's drop the unimplemented tests, they make it hard to spot the changes |
||
|
|
||
| describe('New user with token', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiPasswordLessSendCode } from './passwordLessSendCode' | ||
|
|
||
| describe('Password-less send code', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiPasswordLessVerifyCode } from './passwordLessVerifyCode' | ||
|
|
||
| describe('Password-less verify code', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiCustodialSignTransaction } from './signTransaction' | ||
|
|
||
| describe('Sign transaction', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { callApiUpdateDelayWalletSetup } from './updateDelayWalletSetup' | ||
|
|
||
| describe('Update delay wallet setup', () => { | ||
| test('should return a valid response', async () => { | ||
| expect(1).toEqual(1) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import { | ||
| assertHasAccessToken, | ||
| assertHasApiKey, | ||
| assertHasApiKeyOrAccessToken, | ||
| assertHeaderhasRequiredValues, | ||
| assertParamsHaveAtLeastOneOfValues, | ||
| assertParamsHaveOnlyOneOfValues, | ||
| assertParamsHaveRequiredValues, | ||
| extractProcessIdFromData, | ||
| } from './helpers' | ||
| import OreIdContext from '../core/IOreidContext' | ||
| import { createOreIdContext } from '../test-utils' | ||
| import { ApiKeyUsedFor } from '../models' | ||
|
|
||
| let oreIdContext: OreIdContext | ||
|
|
||
| describe('API helpers', () => { | ||
| test('should not throw an error is all required header values are present', async () => { | ||
| const obj = { test1: 'value', test2: 'value' } | ||
| const names = ['test1', 'test2'] | ||
| assertHeaderhasRequiredValues(obj, names, '') | ||
| expect(1).toEqual(1) | ||
| }) | ||
|
|
||
| test('should throw error for missing header values', async () => { | ||
| const obj = { test1: 'value' } | ||
| const names = ['test1', 'test2'] | ||
| expect(() => assertHeaderhasRequiredValues(obj, names, '')).toThrow(Error) | ||
| }) | ||
|
|
||
| test('should not throw an error if access token and api key are given', async () => { | ||
| oreIdContext = createOreIdContext() | ||
| assertHasApiKeyOrAccessToken(oreIdContext, '') | ||
| expect(1).toEqual(1) | ||
| }) | ||
|
|
||
| test('should throw error for missing access token and api key', async () => { | ||
| oreIdContext = createOreIdContext() | ||
| delete oreIdContext.accessToken | ||
| delete oreIdContext.options.apiKey | ||
| expect(() => assertHasApiKeyOrAccessToken(oreIdContext, '')).toThrow(Error) | ||
| }) | ||
|
|
||
| test('should not throw an error if access token is given', async () => { | ||
| oreIdContext = createOreIdContext() | ||
| assertHasAccessToken(oreIdContext, '') | ||
| expect(1).toEqual(1) | ||
| }) | ||
|
|
||
| test('should throw error for missing access token', async () => { | ||
| oreIdContext = createOreIdContext() | ||
| delete oreIdContext.accessToken | ||
| expect(() => assertHasAccessToken(oreIdContext, '')).toThrow(Error) | ||
| }) | ||
|
|
||
| test('should not throw an error if api key is provided', async () => { | ||
| oreIdContext = createOreIdContext() | ||
| assertHasApiKey(oreIdContext, ApiKeyUsedFor.AccountMigration, '') | ||
| expect(1).toEqual(1) | ||
| }) | ||
|
|
||
| test('should throw error for missing api key', async () => { | ||
| oreIdContext = createOreIdContext() | ||
| delete oreIdContext.options.apiKey | ||
| expect(() => assertHasApiKey(oreIdContext, ApiKeyUsedFor.AccountMigration, '')).toThrow(Error) | ||
| }) | ||
|
|
||
| test('should not throw an error if all paramater values are found', async () => { | ||
| const obj = { test1: 'value', test2: 'value' } | ||
| const names = ['test1', 'test2'] | ||
| assertParamsHaveRequiredValues(obj, names, '') | ||
| expect(1).toEqual(1) | ||
| }) | ||
|
|
||
| test('should throw error for missing paramater values', async () => { | ||
| const obj = { test1: 'value' } | ||
| const names = ['test1', 'test2'] | ||
| expect(() => assertParamsHaveRequiredValues(obj, names, '')).toThrow(Error) | ||
| }) | ||
|
|
||
| test('should not throw an error if at least one paramater value is found', async () => { | ||
| const obj = { test1: 'value', test2: 'value' } | ||
| const names = ['test2'] | ||
| assertParamsHaveAtLeastOneOfValues(obj, names, '') | ||
| expect(1).toEqual(1) | ||
| }) | ||
|
|
||
| test('should throw error if no required paramater values are provided', async () => { | ||
| const obj = { test1: 'value', test3: 'value', test4: 'value' } | ||
| const names = ['test2'] | ||
| expect(() => assertParamsHaveAtLeastOneOfValues(obj, names, '')).toThrow(Error) | ||
| }) | ||
|
|
||
| test('should not throw an error if only one paramater value is found from the given', async () => { | ||
| const obj = { test1: 'value', test4: 'value' } | ||
| const names = ['test1', 'test3'] | ||
| assertParamsHaveOnlyOneOfValues(obj, names, '') | ||
| expect(1).toEqual(1) | ||
| }) | ||
|
|
||
| test('should throw error if more than one required paramater values is provided', async () => { | ||
| const obj = { test1: 'value', test3: 'value', test4: 'value' } | ||
| const names = ['test1', 'test3'] | ||
| expect(() => assertParamsHaveOnlyOneOfValues(obj, names, '')).toThrow(Error) | ||
| }) | ||
|
|
||
| test('should remove processId from data', async () => { | ||
| const input = { test1: 'value', processId: 'processId' } | ||
| const { data, processId } = extractProcessIdFromData(input) | ||
| expect(data).toEqual({ test1: 'value' }) | ||
| expect(processId).toEqual('processId') | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These instantiation tests aren't needed, they don't any functionality