Skip to content

Commit

Permalink
handle undefined flag val (#904) (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
piyalbasu authored Jul 19, 2023
1 parent 78db4bb commit 61ebf27
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,14 @@ const PathList = ({ paths }: { paths: [Path] }) => {
const FlagList = ({ flags }: { flags: FLAGS }) => (
<>
{Object.entries(flags).map(([flag, value]) => (
<div key={flag}>
<KeyValueList
operationKey={FLAG_TYPES[flag as keyof typeof FLAG_TYPES]}
operationValue={value.toString()}
/>
</div>
<KeyValueList
key={flag}
operationKey={FLAG_TYPES[flag as keyof typeof FLAG_TYPES]}
operationValue={
// clawbackEnabled will be undefined if not being cleared
typeof value === "undefined" ? "undefined" : value.toString()
}
/>
))}
</>
);
Expand Down
21 changes: 16 additions & 5 deletions extension/src/popup/views/__tests__/SignTransaction.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,20 @@ const defaultSettingsState = {
},
};

const defaultTransactionInfo = {
const mockTransactionInfo = {
accountToSign: "",
transaction: { _networkPassphrase: "foo" },
transaction: {
_networkPassphrase: "foo",
_operations: [
{
flags: {
authorized: true,
authorizedToMaintainLiabilities: false,
clawbackEnabled: undefined,
},
},
],
},
transactionXdr: "",
domain: "",
domainTitle: "",
Expand All @@ -39,7 +50,7 @@ jest.mock("stellar-sdk", () => {
return {
...original,
TransactionBuilder: {
fromXDR: () => defaultTransactionInfo.transaction,
fromXDR: () => mockTransactionInfo.transaction,
},
};
});
Expand All @@ -52,7 +63,7 @@ describe("SignTransactions", () => {
it("renders", async () => {
jest
.spyOn(Stellar, "getTransactionInfo")
.mockImplementation(() => defaultTransactionInfo);
.mockImplementation(() => mockTransactionInfo);

render(
<Wrapper
Expand All @@ -68,7 +79,7 @@ describe("SignTransactions", () => {
});
it("shows non-https domain error", async () => {
jest.spyOn(Stellar, "getTransactionInfo").mockImplementation(() => ({
...defaultTransactionInfo,
...mockTransactionInfo,
isHttpsDomain: false,
}));
render(
Expand Down

0 comments on commit 61ebf27

Please sign in to comment.