Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ecolyo
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
Container registry
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
Ecolyo
Commits
5ece0f7e
Commit
5ece0f7e
authored
4 years ago
by
Yoan VALLET
Browse files
Options
Downloads
Patches
Plain Diff
feat: review account service test
parent
8292bf52
No related branches found
No related tags found
1 merge request
!139
Features/unit tests
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/models/account.model.ts
+4
-4
4 additions, 4 deletions
src/models/account.model.ts
src/services/account.service.spec.ts
+2
-7
2 additions, 7 deletions
src/services/account.service.spec.ts
with
6 additions
and
11 deletions
src/models/account.model.ts
+
4
−
4
View file @
5ece0f7e
export
interface
Account
extends
AccountAttributes
{
export
interface
Account
extends
AccountAttributes
{
_id
:
string
_id
:
string
id
:
string
id
?
:
string
_rev
?:
string
_rev
?:
string
_type
?:
string
_type
?:
string
cozyMetadata
?:
Record
<
string
,
any
>
cozyMetadata
?:
Record
<
string
,
any
>
...
@@ -8,8 +8,9 @@ export interface Account extends AccountAttributes {
...
@@ -8,8 +8,9 @@ export interface Account extends AccountAttributes {
export
interface
AccountAttributes
{
export
interface
AccountAttributes
{
account_type
:
string
account_type
:
string
auth
:
AccountAuthData
|
AccountOAuthData
auth
?:
AccountAuthData
identifier
:
string
oauth
?:
AccountOAuthData
identifier
?:
string
state
?:
string
|
null
state
?:
string
|
null
}
}
...
@@ -22,5 +23,4 @@ export interface AccountAuthData {
...
@@ -22,5 +23,4 @@ export interface AccountAuthData {
export
interface
AccountOAuthData
{
export
interface
AccountOAuthData
{
access_token
:
string
access_token
:
string
refresh_token
:
string
refresh_token
:
string
scope
:
string
|
null
}
}
This diff is collapsed.
Click to expand it.
src/services/account.service.spec.ts
+
2
−
7
View file @
5ece0f7e
...
@@ -2,6 +2,7 @@ import { Client, QueryResult } from 'cozy-client'
...
@@ -2,6 +2,7 @@ import { Client, QueryResult } from 'cozy-client'
import
{
AccountAuthData
,
Konnector
,
Account
}
from
'
models
'
import
{
AccountAuthData
,
Konnector
,
Account
}
from
'
models
'
import
AccountService
from
'
./account.service
'
import
AccountService
from
'
./account.service
'
import
accountData
from
'
./__mocks__/accountsData.json
'
import
accountData
from
'
./__mocks__/accountsData.json
'
import
konnectorData
from
'
./__mocks__/konnectorsData.json
'
const
mockClient
=
({
const
mockClient
=
({
query
:
jest
.
fn
(),
query
:
jest
.
fn
(),
...
@@ -24,18 +25,12 @@ describe('Account service', () => {
...
@@ -24,18 +25,12 @@ describe('Account service', () => {
describe
(
'
createAccount method
'
,
()
=>
{
describe
(
'
createAccount method
'
,
()
=>
{
it
(
'
should return created account for login type
'
,
async
()
=>
{
it
(
'
should return created account for login type
'
,
async
()
=>
{
mockHavestLibAccounts
.
createAccount
.
mockResolvedValueOnce
(
mockAccounts
[
2
])
mockHavestLibAccounts
.
createAccount
.
mockResolvedValueOnce
(
mockAccounts
[
2
])
const
mockKonnector
:
Konnector
=
{
_id
:
'
io.cozy.konnectors/eglgrandlyon
'
,
name
:
'
EGL
'
,
slug
:
'
eglgrandlyon
'
,
state
:
'
ready
'
,
}
const
mockAuthData
:
AccountAuthData
=
{
const
mockAuthData
:
AccountAuthData
=
{
login
:
'
login
'
,
login
:
'
login
'
,
password
:
'
password
'
,
password
:
'
password
'
,
}
}
const
result
=
await
accountService
.
createAccount
(
const
result
=
await
accountService
.
createAccount
(
mockK
onnector
,
k
onnector
Data
[
2
]
,
mockAuthData
mockAuthData
)
)
expect
(
result
).
toEqual
(
mockAccounts
[
2
])
expect
(
result
).
toEqual
(
mockAccounts
[
2
])
...
...
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