Skip to content

Commit

Permalink
fix: add string function to test
Browse files Browse the repository at this point in the history
  • Loading branch information
OxBonaparte committed Dec 1, 2022
1 parent 47489a3 commit bf24d7f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
19 changes: 13 additions & 6 deletions __tests__/utils/starknetId.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { StarknetChainId } from '../../src/constants';
import {
generateString,
getStarknetIdContract,
useDecoded,
useEncoded,
} from '../../src/utils/starknetId';
import { getStarknetIdContract, useDecoded, useEncoded } from '../../src/utils/starknetId';

const characters = 'abcdefghijklmnopqrstuvwxyz0123456789-这来';

function generateString(length: number): string {
let result = '';
const charactersLength = characters.length;
for (let i = 0; i < length; i += 1) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}

return result;
}

describe('Should tets StarknetId utils', () => {
test('Should test useEncoded and useDecoded hook with 100 random strings', () => {
Expand Down
12 changes: 0 additions & 12 deletions src/utils/starknetId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,3 @@ export function getStarknetIdContract(chainId: StarknetChainId): string {
throw new Error('Starknet.id is not yet deployed on this network');
}
}

const characters = basicAlphabet.concat(bigAlphabet);

export function generateString(length: number): string {
let result = '';
const charactersLength = characters.length;
for (let i = 0; i < length; i += 1) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}

return result;
}

0 comments on commit bf24d7f

Please sign in to comment.