Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QSI_Groupe4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lydia Tarmelit
QSI_Groupe4
Commits
84645c1e
Commit
84645c1e
authored
1 year ago
by
Nawfel Senoussi
Browse files
Options
Downloads
Patches
Plain Diff
update unit tests
parent
de493816
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/handlers/handlers.spec.ts
+15
-6
15 additions, 6 deletions
test/handlers/handlers.spec.ts
test/handlers/roleHandlers.spec.ts
+37
-37
37 additions, 37 deletions
test/handlers/roleHandlers.spec.ts
with
52 additions
and
43 deletions
test/handlers/handlers.spec.ts
+
15
−
6
View file @
84645c1e
...
@@ -7,21 +7,30 @@ const { createAssociationSpy, promptSpy, createFATokenSpy, getBalanceSpy, create
...
@@ -7,21 +7,30 @@ const { createAssociationSpy, promptSpy, createFATokenSpy, getBalanceSpy, create
vi
.
hoisted
(()
=>
{
vi
.
hoisted
(()
=>
{
return
{
return
{
createAssociationSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
association-hash
'
}),
createAssociationSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
association-hash
'
}),
createFATokenSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
associatio
n-hash
'
}),
createFATokenSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
toke
n-hash
'
}),
getBalanceSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
association
-hash
'
}),
getBalanceSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
balance
-hash
'
}),
createProposalSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
association
-hash
'
}),
createProposalSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
proposal
-hash
'
}),
joinAssociationSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
association-hash
'
}),
joinAssociationSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
association-hash
'
}),
getAssociationsSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
association-hash
'
}),
getAssociationsSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
association-hash
'
}),
getAssociationDetailsSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
association-hash
'
}),
getAssociationDetailsSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
association-hash
'
}),
burnTokenSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
associatio
n-hash
'
}),
burnTokenSpy
:
vi
.
fn
().
mockResolvedValue
({
hash
:
'
toke
n-hash
'
}),
promptSpy
:
vi
.
fn
().
mockResolvedValue
({})
promptSpy
:
vi
.
fn
().
mockResolvedValue
({})
}
}
})
})
vi
.
mock
(
'
inquirer
'
,
async
(
importOriginal
)
=>
{
vi
.
mock
(
'
inquirer
'
,
async
(
importOriginal
)
=>
{
const
actual
=
await
importOriginal
()
const
actual
=
await
importOriginal
()
actual
.
default
.
prompt
=
promptSpy
return
actual
if
(
typeof
actual
===
'
object
'
&&
actual
!==
null
)
{
return
{
...
actual
,
default
:
{
prompt
:
promptSpy
}
}
}
else
{
return
actual
}
})
})
vi
.
mock
(
'
../../src/services/association.service
'
,
()
=>
({
vi
.
mock
(
'
../../src/services/association.service
'
,
()
=>
({
...
...
This diff is collapsed.
Click to expand it.
test/handlers/roleHandlers.spec.ts
+
37
−
37
View file @
84645c1e
...
@@ -19,39 +19,39 @@ const mockedTezosToolkit = {} as unknown as TezosToolkit
...
@@ -19,39 +19,39 @@ const mockedTezosToolkit = {} as unknown as TezosToolkit
describe
(
'
roleHandlers
'
,
()
=>
{
describe
(
'
roleHandlers
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vi
.
clearAllMocks
()
vi
.
clearAllMocks
()
})
;
})
describe
(
'
handleAdminFATokenChoice
'
,
()
=>
{
describe
(
'
handleAdminFATokenChoice
'
,
()
=>
{
describe
(
'
when choice is "
1
"
'
,
()
=>
{
describe
(
'
when choice is "
Créer une association
"
'
,
()
=>
{
it
(
'
should call handleCreateAssociation
'
,
async
()
=>
{
it
(
'
should call handleCreateAssociation
'
,
async
()
=>
{
await
handleAdminFATokenChoice
(
'
Créer une association
'
,
mockedTezosToolkit
)
await
handleAdminFATokenChoice
(
'
Créer une association
'
,
mockedTezosToolkit
)
expect
(
handleCreateAssociation
).
toBeCalled
()
expect
(
handleCreateAssociation
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is "
2
"
'
,
()
=>
{
describe
(
'
when choice is "
Créer un token
"
'
,
()
=>
{
it
(
'
should call handleCreateToken
'
,
async
()
=>
{
it
(
'
should call handleCreateToken
'
,
async
()
=>
{
await
handleAdminFATokenChoice
(
'
Créer un token
'
,
mockedTezosToolkit
)
await
handleAdminFATokenChoice
(
'
Créer un token
'
,
mockedTezosToolkit
)
expect
(
handleCreateToken
).
toBeCalled
()
expect
(
handleCreateToken
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is "
3
"
'
,
()
=>
{
describe
(
'
when choice is "
Bruler des tokens
"
'
,
()
=>
{
it
(
'
should call handleBurnToken
'
,
async
()
=>
{
it
(
'
should call handleBurnToken
'
,
async
()
=>
{
await
handleAdminFATokenChoice
(
'
Bruler des tokens
'
,
mockedTezosToolkit
)
await
handleAdminFATokenChoice
(
'
Bruler des tokens
'
,
mockedTezosToolkit
)
expect
(
handleBurnToken
).
toBeCalled
()
expect
(
handleBurnToken
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is "
4
"
'
,
()
=>
{
describe
(
'
when choice is "
Voir mon portefeuille
"
'
,
()
=>
{
it
(
'
should call handleGetBalance
'
,
async
()
=>
{
it
(
'
should call handleGetBalance
'
,
async
()
=>
{
await
handleAdminFATokenChoice
(
'
Voir mon portefeuille
'
,
mockedTezosToolkit
)
await
handleAdminFATokenChoice
(
'
Voir mon portefeuille
'
,
mockedTezosToolkit
)
expect
(
handleGetBalance
).
toBeCalled
()
expect
(
handleGetBalance
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is invalid
'
,
()
=>
{
describe
(
'
when choice is invalid
'
,
()
=>
{
...
@@ -60,33 +60,33 @@ describe('roleHandlers', () => {
...
@@ -60,33 +60,33 @@ describe('roleHandlers', () => {
await
handleAdminFATokenChoice
(
'
invalid
'
,
mockedTezosToolkit
)
await
handleAdminFATokenChoice
(
'
invalid
'
,
mockedTezosToolkit
)
expect
(
consoleSpy
).
toHaveBeenCalledWith
(
chalk
.
bgRedBright
(
'
\n
Choix invalide
\n
'
))
expect
(
consoleSpy
).
toHaveBeenCalledWith
(
chalk
.
bgRedBright
(
'
\n
Choix invalide
\n
'
))
})
;
})
})
})
})
;
})
describe
(
'
handleAdminAssociationChoice
'
,
()
=>
{
describe
(
'
handleAdminAssociationChoice
'
,
()
=>
{
describe
(
'
when choice is "
1
"
'
,
()
=>
{
describe
(
'
when choice is "
Créer un token
"
'
,
()
=>
{
it
(
'
should call handleCreateToken
'
,
async
()
=>
{
it
(
'
should call handleCreateToken
'
,
async
()
=>
{
await
handleAdminAssociationChoice
(
'
Créer un token
'
,
mockedTezosToolkit
)
await
handleAdminAssociationChoice
(
'
Créer un token
'
,
mockedTezosToolkit
)
expect
(
handleCreateToken
).
toBeCalled
()
expect
(
handleCreateToken
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is "
2
"
'
,
()
=>
{
describe
(
'
when choice is "
Bruler des tokens
"
'
,
()
=>
{
it
(
'
should call handleBurnToken
'
,
async
()
=>
{
it
(
'
should call handleBurnToken
'
,
async
()
=>
{
await
handleAdminAssociationChoice
(
'
Bruler des tokens
'
,
mockedTezosToolkit
)
await
handleAdminAssociationChoice
(
'
Bruler des tokens
'
,
mockedTezosToolkit
)
expect
(
handleBurnToken
).
toBeCalled
()
expect
(
handleBurnToken
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is "
3
"
'
,
()
=>
{
describe
(
'
when choice is "
Voir mon portefeuille
"
'
,
()
=>
{
it
(
'
should call handleGetBalance
'
,
async
()
=>
{
it
(
'
should call handleGetBalance
'
,
async
()
=>
{
await
handleAdminAssociationChoice
(
'
Voir mon portefeuille
'
,
mockedTezosToolkit
)
await
handleAdminAssociationChoice
(
'
Voir mon portefeuille
'
,
mockedTezosToolkit
)
expect
(
handleGetBalance
).
toBeCalled
()
expect
(
handleGetBalance
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is invalid
'
,
()
=>
{
describe
(
'
when choice is invalid
'
,
()
=>
{
...
@@ -95,33 +95,33 @@ describe('roleHandlers', () => {
...
@@ -95,33 +95,33 @@ describe('roleHandlers', () => {
await
handleAdminAssociationChoice
(
'
invalid
'
,
mockedTezosToolkit
)
await
handleAdminAssociationChoice
(
'
invalid
'
,
mockedTezosToolkit
)
expect
(
consoleSpy
).
toHaveBeenCalledWith
(
chalk
.
bgRedBright
(
'
\n
Choix invalide
\n
'
))
expect
(
consoleSpy
).
toHaveBeenCalledWith
(
chalk
.
bgRedBright
(
'
\n
Choix invalide
\n
'
))
})
;
})
})
})
})
;
})
describe
(
'
handleAdherentChoice
'
,
()
=>
{
describe
(
'
handleAdherentChoice
'
,
()
=>
{
describe
(
'
when choice is "
1
"
'
,
()
=>
{
describe
(
'
when choice is "
Faire une proposition
"
'
,
()
=>
{
it
(
'
should call handleCreateProposal
'
,
async
()
=>
{
it
(
'
should call handleCreateProposal
'
,
async
()
=>
{
await
handleAdherentChoice
(
'
Faire une proposition
'
,
mockedTezosToolkit
)
await
handleAdherentChoice
(
'
Faire une proposition
'
,
mockedTezosToolkit
)
expect
(
handleCreateProposal
).
toBeCalled
()
expect
(
handleCreateProposal
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is "
2
"
'
,
()
=>
{
describe
(
'
when choice is "
Créer un token
"
'
,
()
=>
{
it
(
'
should call handleCreateToken
'
,
async
()
=>
{
it
(
'
should call handleCreateToken
'
,
async
()
=>
{
await
handleAdherentChoice
(
'
Créer un token
'
,
mockedTezosToolkit
)
await
handleAdherentChoice
(
'
Créer un token
'
,
mockedTezosToolkit
)
expect
(
handleCreateToken
).
toBeCalled
()
expect
(
handleCreateToken
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is "
3
"
'
,
()
=>
{
describe
(
'
when choice is "
Voir mon portefeuille
"
'
,
()
=>
{
it
(
'
should call handleGetBalance
'
,
async
()
=>
{
it
(
'
should call handleGetBalance
'
,
async
()
=>
{
await
handleAdherentChoice
(
'
Voir mon portefeuille
'
,
mockedTezosToolkit
)
await
handleAdherentChoice
(
'
Voir mon portefeuille
'
,
mockedTezosToolkit
)
expect
(
handleGetBalance
).
toBeCalled
()
expect
(
handleGetBalance
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is invalid
'
,
()
=>
{
describe
(
'
when choice is invalid
'
,
()
=>
{
...
@@ -130,41 +130,41 @@ describe('roleHandlers', () => {
...
@@ -130,41 +130,41 @@ describe('roleHandlers', () => {
await
handleAdherentChoice
(
'
invalid
'
,
mockedTezosToolkit
)
await
handleAdherentChoice
(
'
invalid
'
,
mockedTezosToolkit
)
expect
(
consoleSpy
).
toHaveBeenCalledWith
(
chalk
.
bgRedBright
(
'
\n
Choix invalide
\n
'
))
expect
(
consoleSpy
).
toHaveBeenCalledWith
(
chalk
.
bgRedBright
(
'
\n
Choix invalide
\n
'
))
})
;
})
})
})
})
;
})
describe
(
'
handleConnectedChoice
'
,
()
=>
{
describe
(
'
handleConnectedChoice
'
,
()
=>
{
describe
(
'
when choice is "
1
"
'
,
()
=>
{
describe
(
'
when choice is "
Rejoindre une association
"
'
,
()
=>
{
it
(
'
should call handleJoinAssociation
'
,
async
()
=>
{
it
(
'
should call handleJoinAssociation
'
,
async
()
=>
{
await
handleConnectedChoice
(
'
Rejoindre une association
'
,
mockedTezosToolkit
)
await
handleConnectedChoice
(
'
Rejoindre une association
'
,
mockedTezosToolkit
)
expect
(
handleJoinAssociation
).
toBeCalled
()
expect
(
handleJoinAssociation
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is "
2
"
'
,
()
=>
{
describe
(
'
when choice is "
Créer un token
"
'
,
()
=>
{
it
(
'
should call handleCreateToken
'
,
async
()
=>
{
it
(
'
should call handleCreateToken
'
,
async
()
=>
{
await
handleConnectedChoice
(
'
Créer un token
'
,
mockedTezosToolkit
)
await
handleConnectedChoice
(
'
Créer un token
'
,
mockedTezosToolkit
)
expect
(
handleCreateToken
).
toBeCalled
()
expect
(
handleCreateToken
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is "
3
"
'
,
()
=>
{
describe
(
'
when choice is "
Voir les associations
"
'
,
()
=>
{
it
(
'
should call handleGetAssociations
'
,
async
()
=>
{
it
(
'
should call handleGetAssociations
'
,
async
()
=>
{
await
handleConnectedChoice
(
'
Voir les associations
'
,
mockedTezosToolkit
)
await
handleConnectedChoice
(
'
Voir les associations
'
,
mockedTezosToolkit
)
expect
(
handleGetAssociations
).
toBeCalled
()
expect
(
handleGetAssociations
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is "
4
"
'
,
()
=>
{
describe
(
'
when choice is "
Voir mon portefeuille
"
'
,
()
=>
{
it
(
'
should call handleGetBalance
'
,
async
()
=>
{
it
(
'
should call handleGetBalance
'
,
async
()
=>
{
await
handleConnectedChoice
(
'
Voir mon portefeuille
'
,
mockedTezosToolkit
)
await
handleConnectedChoice
(
'
Voir mon portefeuille
'
,
mockedTezosToolkit
)
expect
(
handleGetBalance
).
toBeCalled
()
expect
(
handleGetBalance
).
toBeCalled
()
})
;
})
})
})
describe
(
'
when choice is invalid
'
,
()
=>
{
describe
(
'
when choice is invalid
'
,
()
=>
{
...
@@ -173,7 +173,7 @@ describe('roleHandlers', () => {
...
@@ -173,7 +173,7 @@ describe('roleHandlers', () => {
await
handleConnectedChoice
(
'
invalid
'
,
mockedTezosToolkit
)
await
handleConnectedChoice
(
'
invalid
'
,
mockedTezosToolkit
)
expect
(
consoleSpy
).
toHaveBeenCalledWith
(
chalk
.
bgRedBright
(
'
\n
Choix invalide
\n
'
))
expect
(
consoleSpy
).
toHaveBeenCalledWith
(
chalk
.
bgRedBright
(
'
\n
Choix invalide
\n
'
))
})
;
})
})
})
})
;
})
})
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment