Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
F
fether
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
20
Issues
20
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
parity
fether
Commits
a0bd59ad
Commit
a0bd59ad
authored
Jul 02, 2018
by
Amaury Martiny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more tests
parent
f9250b71
Pipeline
#44262
canceled with stages
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
118 additions
and
8 deletions
+118
-8
packages/fether-react/src/stores/createAccountStore.js
packages/fether-react/src/stores/createAccountStore.js
+1
-1
packages/fether-react/src/stores/createAccountStore.spec.js
packages/fether-react/src/stores/createAccountStore.spec.js
+78
-0
packages/fether-react/src/stores/healthStore.js
packages/fether-react/src/stores/healthStore.js
+1
-1
packages/fether-react/src/stores/onboardingStore.js
packages/fether-react/src/stores/onboardingStore.js
+1
-1
packages/fether-react/src/stores/parityStore.js
packages/fether-react/src/stores/parityStore.js
+1
-1
packages/fether-react/src/stores/sendStore.spec.js
packages/fether-react/src/stores/sendStore.spec.js
+35
-3
packages/fether-react/src/stores/tokensStore.js
packages/fether-react/src/stores/tokensStore.js
+1
-1
No files found.
packages/fether-react/src/stores/createAccountStore.js
View file @
a0bd59ad
...
...
@@ -7,7 +7,7 @@ import { action, observable } from 'mobx';
import
parityStore
from
'
./parityStore
'
;
class
CreateAccountStore
{
export
class
CreateAccountStore
{
@
observable
address
=
null
;
@
observable
isImport
=
false
;
// Are we creating a new account, or importing via phrase?
@
observable
name
=
''
;
// Account name
...
...
packages/fether-react/src/stores/createAccountStore.spec.js
0 → 100644
View file @
a0bd59ad
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
/* eslint-env jest */
import
{
CreateAccountStore
}
from
'
./createAccountStore
'
;
import
parityStore
from
'
./parityStore
'
;
import
*
as
storeTests
from
'
../utils/testHelpers/storeTests
'
;
jest
.
mock
(
'
./parityStore
'
,
()
=>
({
api
:
{
parity
:
{
generateSecretPhrase
:
jest
.
fn
(()
=>
Promise
.
resolve
(
'
foo
'
)),
newAccountFromPhrase
:
jest
.
fn
(()
=>
Promise
.
resolve
()),
phraseToAddress
:
jest
.
fn
(()
=>
Promise
.
resolve
(
'
0x123
'
)),
setAccountName
:
jest
.
fn
(()
=>
Promise
.
resolve
()),
setAccountMeta
:
jest
.
fn
(()
=>
Promise
.
resolve
())
}
}
}));
let
createAccountStore
;
// Will hold the newly created instance of createAccountStore in each test
beforeEach
(()
=>
{
createAccountStore
=
new
CreateAccountStore
();
});
describe
(
'
method clear
'
,
()
=>
{
test
(
'
should call setAddress and setName
'
,
()
=>
{
createAccountStore
.
setAddress
=
jest
.
fn
();
createAccountStore
.
setName
=
jest
.
fn
();
createAccountStore
.
clear
();
expect
(
createAccountStore
.
setAddress
).
toHaveBeenCalledWith
(
null
);
expect
(
createAccountStore
.
setName
).
toHaveBeenCalledWith
(
''
);
});
});
describe
(
'
method generateNewAccount
'
,
()
=>
{
test
(
'
should call api.parity.generateSecretPhrase
'
,
()
=>
{
createAccountStore
.
generateNewAccount
();
expect
(
parityStore
.
api
.
parity
.
generateSecretPhrase
).
toHaveBeenCalledWith
();
});
});
describe
(
'
method saveAccountToParity
'
,
()
=>
{
beforeAll
(()
=>
{
createAccountStore
.
setPhrase
(
'
foo
'
);
createAccountStore
.
saveAccountToParity
(
'
bar
'
);
});
test
(
'
should call api.parity.newAccountFromPhrase
'
,
()
=>
{
expect
(
parityStore
.
api
.
parity
.
newAccountFromPhrase
).
toHaveBeenCalledWith
(
'
foo
'
,
'
bar
'
);
});
test
(
'
should call api.parity.setAccountName
'
,
()
=>
{
expect
(
parityStore
.
api
.
parity
.
setAccountName
).
toHaveBeenCalled
();
});
test
(
'
should call api.parity.setAccountMeta
'
,
()
=>
{
expect
(
parityStore
.
api
.
parity
.
setAccountMeta
).
toHaveBeenCalled
();
});
});
storeTests
.
setterTest
(
CreateAccountStore
,
'
address
'
);
storeTests
.
setterTest
(
CreateAccountStore
,
'
isImport
'
);
storeTests
.
setterTest
(
CreateAccountStore
,
'
name
'
);
describe
(
'
setter phrase
'
,
()
=>
{
test
(
'
should set correct value and call api.parity.phraseToAddress
'
,
()
=>
{
createAccountStore
.
setPhrase
(
'
foo
'
);
expect
(
parityStore
.
api
.
parity
.
phraseToAddress
).
toHaveBeenCalledWith
(
'
foo
'
);
expect
(
createAccountStore
.
phrase
).
toEqual
(
'
foo
'
);
});
});
packages/fether-react/src/stores/healthStore.js
View file @
a0bd59ad
...
...
@@ -22,7 +22,7 @@ export const STATUS = {
SYNCING
:
'
SYNCING
'
// Obvious
};
class
HealthStore
{
export
class
HealthStore
{
@
observable
nodeHealth
;
@
observable
syncing
;
...
...
packages/fether-react/src/stores/onboardingStore.js
View file @
a0bd59ad
...
...
@@ -10,7 +10,7 @@ import LS_PREFIX from './utils/lsPrefix';
const
LS_KEY
=
`
${
LS_PREFIX
}
::firstRun`
;
class
OnboardingStore
{
export
class
OnboardingStore
{
@
observable
isFirstRun
;
// If it's the 1st time the user is running the app
constructor
()
{
...
...
packages/fether-react/src/stores/parityStore.js
View file @
a0bd59ad
...
...
@@ -17,7 +17,7 @@ const electron = isElectron() ? window.require('electron') : null;
const
LS_KEY
=
`
${
LS_PREFIX
}
::secureToken`
;
class
ParityStore
{
export
class
ParityStore
{
@
observable
downloadProgress
=
0
;
@
observable
isApiConnected
=
false
;
@
observable
isParityRunning
=
false
;
...
...
packages/fether-react/src/stores/sendStore.spec.js
View file @
a0bd59ad
...
...
@@ -28,7 +28,12 @@ jest.mock('@parity/light.js', () => ({
},
transfer
$
:
jest
.
fn
(()
=>
({
subscribe
:
jest
.
fn
()
}))
})),
post
$
:
jest
.
fn
(()
=>
({
subscribe
:
jest
.
fn
()
}))
post
$
:
jest
.
fn
(()
=>
({
subscribe
:
jest
.
fn
(
callback
=>
{
setTimeout
(
callback
({
estimating
:
true
}),
100
);
// eslint-disable-line standard/no-callback-literal
setTimeout
(
callback
({
requested
:
1
}),
200
);
// eslint-disable-line standard/no-callback-literal
})
}))
}));
jest
.
mock
(
'
./parityStore
'
,
()
=>
({
...
...
@@ -82,6 +87,12 @@ describe('method clear', () => {
sendStore
.
clear
();
expect
(
sendStore
.
tx
).
toEqual
({});
});
test
(
'
should unsubscribe
'
,
()
=>
{
sendStore
.
subscription
=
{
unsubscribe
:
jest
.
fn
()
};
sendStore
.
clear
();
expect
(
sendStore
.
subscription
.
unsubscribe
).
toHaveBeenCalled
();
});
});
describe
(
'
@computed confirmations
'
,
()
=>
{
...
...
@@ -146,7 +157,7 @@ describe('method estimateGasForErc20', () => {
sendStore
.
setTokenAddress
(
'
foo
'
);
});
test
(
'
should call the transfer method on the contract
'
,
()
=>
{
test
.
skip
(
'
should call the transfer method on the contract
'
,
()
=>
{
sendStore
.
estimateGasForErc20
(
mockTx
);
expect
(
sendStore
.
contract
.
contractObject
.
instance
.
transfer
.
estimateGas
...
...
@@ -182,7 +193,7 @@ describe('method send', () => {
sendStore
.
setTx
(
mockTx
);
});
test
(
'
should call transfer$ if the token is Erc20 and subscribe to it
'
,
()
=>
{
test
.
skip
(
'
should call transfer$ if the token is Erc20 and subscribe to it
'
,
()
=>
{
sendStore
.
setTokenAddress
(
'
foo
'
);
sendStore
.
send
();
expect
(
sendStore
.
contract
.
transfer$
).
toHaveBeenCalledWith
(
...
...
@@ -195,6 +206,27 @@ describe('method send', () => {
sendStore
.
send
();
expect
(
lightJs
.
post$
).
toHaveBeenCalledWith
(
sendStore
.
txForEth
);
});
test
(
'
should update txStatus
'
,
()
=>
{
sendStore
.
setTxStatus
=
jest
.
fn
();
sendStore
.
setTokenAddress
(
'
ETH
'
);
sendStore
.
send
();
expect
(
sendStore
.
setTxStatus
).
toHaveBeenCalledWith
({
estimating
:
true
});
});
test
(
'
should call acceptRequest when txStatus is requested
'
,
()
=>
{
sendStore
.
acceptRequest
=
jest
.
fn
(()
=>
Promise
.
resolve
(
true
));
sendStore
.
setTokenAddress
(
'
ETH
'
);
sendStore
.
send
(
'
foo
'
);
expect
(
sendStore
.
acceptRequest
).
toHaveBeenCalledWith
(
1
,
'
foo
'
);
});
});
describe
(
'
setter setEstimated
'
,
()
=>
{
test
(
'
should add a 1.33 factor
'
,
()
=>
{
sendStore
.
setEstimated
(
new
BigNumber
(
2
));
expect
(
sendStore
.
estimated
).
toEqual
(
new
BigNumber
(
2
*
1.33
));
});
});
describe
(
'
@computed txForErc20
'
,
()
=>
{
...
...
packages/fether-react/src/stores/tokensStore.js
View file @
a0bd59ad
...
...
@@ -13,7 +13,7 @@ import LS_PREFIX from './utils/lsPrefix';
const
LS_KEY
=
`
${
LS_PREFIX
}
::tokens`
;
class
TokensStore
{
export
class
TokensStore
{
@
observable
tokens
=
{};
constructor
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment