-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#215 (#217) * Add topic create and private topics Signed-off-by: Michiel Mulders <[email protected]> * Add demo script for topic create Signed-off-by: Michiel Mulders <[email protected]> * Add topic submit feature Signed-off-by: Michiel Mulders <[email protected]> * Add message retrieve feature Signed-off-by: Michiel Mulders <[email protected]> * Add docs for topic features Signed-off-by: Michiel Mulders <[email protected]> * Update clear command to clear topics Signed-off-by: Michiel Mulders <[email protected]> * Update download state and clear state commands to handle topics Signed-off-by: Michiel Mulders <[email protected]> * Add dummy test for topic Signed-off-by: Michiel Mulders <[email protected]> * Update state clear for topics and add single-test command in package.json Signed-off-by: Michiel Mulders <[email protected]> * Add e2e tests for topics Signed-off-by: Michiel Mulders <[email protected]> * Update husky hook for pre-push Signed-off-by: Michiel Mulders <[email protected]> * Update husky hook for pre-push Signed-off-by: Michiel Mulders <[email protected]> * Linting changes Signed-off-by: Michiel Mulders <[email protected]> * Add filter options and tests Signed-off-by: Michiel Mulders <[email protected]> * Add e2e test for filters Signed-off-by: Michiel Mulders <[email protected]> * Update mock for account create test Signed-off-by: Michiel Mulders <[email protected]> * Update mock for token create test Signed-off-by: Michiel Mulders <[email protected]> * Add token associate test Signed-off-by: Michiel Mulders <[email protected]> * Add token transfer test Signed-off-by: Michiel Mulders <[email protected]> * Update state.json Signed-off-by: Michiel Mulders <[email protected]> * Fix balance test with mock state Signed-off-by: Michiel Mulders <[email protected]> * update base state Signed-off-by: Michiel Mulders <[email protected]> --------- Signed-off-by: Michiel Mulders <[email protected]>
- Loading branch information
1 parent
d32a24d
commit 1ba014c
Showing
43 changed files
with
1,521 additions
and
78 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
npm run test | ||
node clear-state.js | ||
node clear-state.js | ||
git add . |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,64 @@ | ||
import { alice, tokenState } from '../../helpers/state'; | ||
import { Command } from 'commander'; | ||
import commands from '../../../src/commands'; | ||
import stateController from '../../../src/state/stateController'; | ||
|
||
let tokenId = Object.keys(tokenState.tokens)[0]; | ||
jest.mock('../../../src/state/state'); // Mock the original module -> looks for __mocks__/state.ts in same directory | ||
jest.mock('@hashgraph/sdk', () => { | ||
const originalModule = jest.requireActual('@hashgraph/sdk'); | ||
|
||
return { | ||
...originalModule, | ||
TokenAssociateTransaction: jest.fn().mockImplementation(() => ({ | ||
setAccountId: jest.fn().mockReturnThis(), | ||
setTokenIds: jest.fn().mockReturnThis(), | ||
sign: jest.fn().mockReturnThis(), | ||
freezeWith: jest.fn().mockReturnThis(), | ||
execute: jest.fn().mockResolvedValue({ | ||
getReceipt: jest.fn().mockResolvedValue({}), | ||
}), | ||
})), | ||
}; | ||
}); | ||
|
||
describe('token associate command', () => { | ||
beforeEach(() => { | ||
const tokenStateWithAlice = { | ||
...tokenState, | ||
accounts: { | ||
[alice.alias]: alice, | ||
}, | ||
}; | ||
stateController.saveState(tokenStateWithAlice); | ||
}); | ||
|
||
describe('token associate - success path', () => { | ||
test('✅ ', async () => { | ||
// Arrange | ||
const program = new Command(); | ||
commands.tokenCommands(program); | ||
|
||
// Act | ||
await program.parseAsync([ | ||
'node', | ||
'hedera-cli.ts', | ||
'token', | ||
'associate', | ||
'-a', | ||
alice.accountId, | ||
'-t', | ||
tokenId, | ||
]); | ||
|
||
// Assert | ||
const tokens = stateController.get('tokens'); | ||
expect(tokens[tokenId].associations).toEqual([ | ||
{ | ||
alias: alice.alias, | ||
accountId: alice.accountId, | ||
}, | ||
]); | ||
}); | ||
}); | ||
}); |
This file contains 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
Oops, something went wrong.