-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
5,645 additions
and
6,731 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
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 was deleted.
Oops, something went wrong.
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,54 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import enTranslation from '../../../lib/languages/en.json' | ||
import zhHansTranslation from '../../../lib/languages/zh-Hans.json' | ||
|
||
import { IntlProvider } from 'react-intl' | ||
|
||
import ManageData from '../ManageData' | ||
|
||
describe('ManageData', () => { | ||
it('decodes ordinary string values', () => { | ||
render( | ||
<IntlProvider locale="en" messages={enTranslation}> | ||
<ManageData name="lang" value="aW5kb25lc2lhbg==" /> | ||
</IntlProvider>, | ||
) | ||
|
||
expect( | ||
screen.getByText((content) => { | ||
return content.includes('indonesian') | ||
}), | ||
).toBeInTheDocument() | ||
}) | ||
|
||
it('decodes utf8 string values', () => { | ||
render( | ||
<IntlProvider locale="zh-CN" messages={zhHansTranslation}> | ||
<ManageData name="utf8value" value="6ams6ams6JmO6JmO" /> | ||
</IntlProvider>, | ||
) | ||
|
||
expect( | ||
screen.getByText((content) => { | ||
return content.includes('马马虎虎') | ||
}), | ||
).toBeInTheDocument() | ||
}) | ||
|
||
it('truncates a long key and long value', () => { | ||
const aLongPrefix = 'some_really_long_12345678901234567890123456789' | ||
const aLongName = `name_${aLongPrefix}` | ||
const aLongValue = Buffer.from(`value_${aLongPrefix}`).toString('base64') | ||
render( | ||
<IntlProvider locale="en" messages={enTranslation}> | ||
<ManageData name={aLongName} value={aLongValue} /> | ||
</IntlProvider>, | ||
) | ||
|
||
expect( | ||
screen.getByText((content) => { | ||
return content.includes('value_some_really_long_1234...') | ||
}), | ||
).toBeInTheDocument() | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,52 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { BrowserRouter } from 'react-router-dom' | ||
|
||
import type { KnownAccountProps } from '../../../data/known_accounts' | ||
import knownAccounts from '../../../data/known_accounts' | ||
import AccountLink, { BaseAccountLink } from '../AccountLink' | ||
|
||
interface TKnownAccountProps extends KnownAccountProps { | ||
displayName: string | ||
} | ||
|
||
const ACC_KNOWN = Object.keys(knownAccounts).find( | ||
(key) => (knownAccounts[key] as TKnownAccountProps).displayName === 'NaoBTC', | ||
) as string | ||
const ACC_UNKNOWN = 'GCGG3CIRBG2TTBR4HYZJ7JLDRFKZIYOAHFXRWLU62CA2QN52P2SUQNPJ' | ||
const LABEL = 'Anchor' | ||
|
||
describe('AccountLink', () => { | ||
it('renders with label', () => { | ||
render( | ||
<BrowserRouter> | ||
<AccountLink label={LABEL} account={ACC_UNKNOWN} /> | ||
</BrowserRouter>, | ||
) | ||
|
||
expect(screen.getByText(LABEL)).toBeInTheDocument() | ||
}) | ||
|
||
it('renders short account for label when no label property', () => { | ||
render( | ||
<BrowserRouter> | ||
<AccountLink account={ACC_UNKNOWN} /> | ||
</BrowserRouter>, | ||
) | ||
|
||
expect(screen.getByText(ACC_UNKNOWN.slice(0, 4))).toBeInTheDocument() | ||
}) | ||
|
||
it('renders anchor name in italics if account a known anchor', () => { | ||
render( | ||
<BrowserRouter> | ||
<BaseAccountLink label={''} address={ACC_KNOWN} hideKnown={false} /> | ||
</BrowserRouter>, | ||
) | ||
|
||
expect(screen.getByText('NaoBTC')).toBeInTheDocument() | ||
}) | ||
}) | ||
|
||
describe('MuxedAccount', () => { | ||
it.todo('muxed account renders muxed and base') | ||
}) |
Oops, something went wrong.