Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Resin
Server
Commits
1b1724ef
Commit
1b1724ef
authored
4 years ago
by
Antonin COQUET
Browse files
Options
Downloads
Patches
Plain Diff
feat: TU for admin mailer and posts
parent
22902ce4
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!96
release V1.10.0
,
!62
Dev
,
!52
feat: TU for admin mailer and posts
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/admin/admin.controller.spec.ts
+24
-1
24 additions, 1 deletion
src/admin/admin.controller.spec.ts
src/mailer/mailer.service.spec.ts
+24
-0
24 additions, 0 deletions
src/mailer/mailer.service.spec.ts
src/posts/posts.controller.spec.ts
+21
-0
21 additions, 0 deletions
src/posts/posts.controller.spec.ts
with
69 additions
and
1 deletion
src/admin/admin.controller.spec.ts
+
24
−
1
View file @
1b1724ef
import
{
Http
Module
}
from
'
@nestjs/common
'
;
import
{
Http
Exception
,
HttpModule
,
HttpStatus
}
from
'
@nestjs/common
'
;
import
{
getModelToken
}
from
'
@nestjs/mongoose
'
;
import
{
getModelToken
}
from
'
@nestjs/mongoose
'
;
import
{
Test
,
TestingModule
}
from
'
@nestjs/testing
'
;
import
{
Test
,
TestingModule
}
from
'
@nestjs/testing
'
;
import
{
ConfigurationModule
}
from
'
../configuration/configuration.module
'
;
import
{
ConfigurationModule
}
from
'
../configuration/configuration.module
'
;
import
{
MailerService
}
from
'
../mailer/mailer.service
'
;
import
{
MailerService
}
from
'
../mailer/mailer.service
'
;
import
{
CreateStructureDto
}
from
'
../structures/dto/create-structure.dto
'
;
import
{
structureDto
}
from
'
../structures/dto/structure.dto
'
;
import
{
Structure
}
from
'
../structures/schemas/structure.schema
'
;
import
{
Structure
}
from
'
../structures/schemas/structure.schema
'
;
import
{
StructuresService
}
from
'
../structures/services/structures.service
'
;
import
{
StructuresService
}
from
'
../structures/services/structures.service
'
;
import
{
User
}
from
'
../users/schemas/user.schema
'
;
import
{
User
}
from
'
../users/schemas/user.schema
'
;
import
{
UsersService
}
from
'
../users/users.service
'
;
import
{
UsersService
}
from
'
../users/users.service
'
;
import
{
AdminController
}
from
'
./admin.controller
'
;
import
{
AdminController
}
from
'
./admin.controller
'
;
import
{
PendingStructureDto
}
from
'
./dto/pending-structure.dto
'
;
describe
(
'
AdminController
'
,
()
=>
{
describe
(
'
AdminController
'
,
()
=>
{
let
controller
:
AdminController
;
let
controller
:
AdminController
;
...
@@ -37,4 +40,24 @@ describe('AdminController', () => {
...
@@ -37,4 +40,24 @@ describe('AdminController', () => {
it
(
'
should be defined
'
,
()
=>
{
it
(
'
should be defined
'
,
()
=>
{
expect
(
controller
).
toBeDefined
();
expect
(
controller
).
toBeDefined
();
});
});
it
(
'
should get pending attachments
'
,
async
()
=>
{
const
result
=
[{
name
:
"
MJC Route de vienne
"
,
address
:
"
14 chemin des platanes
"
},
{
name
:
"
Mairie Lyon 7eme
"
,
address
:
"
21 boulevard martin
"
}];
jest
.
spyOn
(
controller
,
'
getPendingAttachments
'
).
mockImplementation
(
async
():
Promise
<
any
>
=>
result
);
expect
(
await
controller
.
getPendingAttachments
()).
toBe
(
result
);
});
it
(
'
should validate pending structure
'
,
async
()
=>
{
const
result
=
[{
name
:
"
MJC Route de vienne
"
,
address
:
"
14 chemin des platanes
"
}];
const
structure
:
PendingStructureDto
=
{
userEmail
:
"
martin@mjc.fr
"
,
structureId
:
"
1
"
,
structureName
:
"
MJC Route de vienne
"
};
jest
.
spyOn
(
controller
,
'
validatePendingStructure
'
).
mockImplementation
(
async
():
Promise
<
any
>
=>
result
);
expect
(
await
controller
.
validatePendingStructure
(
structure
)).
toBe
(
result
);
});
it
(
'
should refuse pending structure
'
,
async
()
=>
{
const
result
=
[{
name
:
"
MJC Route de vienne
"
,
address
:
"
14 chemin des platanes
"
},
{
name
:
"
Mairie Lyon 7eme
"
,
address
:
"
21 boulevard martin
"
}];
const
structure
:
PendingStructureDto
=
{
userEmail
:
"
martin@mjc.fr
"
,
structureId
:
"
1
"
,
structureName
:
"
MJC Route de vienne
"
};
jest
.
spyOn
(
controller
,
'
refusePendingStructure
'
).
mockImplementation
(
async
():
Promise
<
any
>
=>
result
);
expect
(
await
controller
.
refusePendingStructure
(
structure
)).
toBe
(
result
);
});
});
});
This diff is collapsed.
Click to expand it.
src/mailer/mailer.service.spec.ts
+
24
−
0
View file @
1b1724ef
...
@@ -18,4 +18,28 @@ describe('MailerService', () => {
...
@@ -18,4 +18,28 @@ describe('MailerService', () => {
it
(
'
should be defined
'
,
()
=>
{
it
(
'
should be defined
'
,
()
=>
{
expect
(
service
).
toBeDefined
();
expect
(
service
).
toBeDefined
();
});
});
it
(
'
should send email
'
,
async
()
=>
{
const
result
=
"
AxiosResponse
"
jest
.
spyOn
(
service
,
'
send
'
).
mockImplementation
(
async
():
Promise
<
any
>
=>
result
);
expect
(
await
service
.
send
(
"
to
"
,
"
subject
"
,
"
html
"
)).
toBe
(
result
);
});
it
(
'
should get template location
'
,
async
()
=>
{
const
result
=
"
/path/to/template
"
;
jest
.
spyOn
(
service
,
'
getTemplateLocation
'
).
mockImplementation
(()
=>
{
return
result
});
expect
(
await
service
.
getTemplateLocation
(
"
filename
"
)).
toBe
(
result
);
});
it
(
'
should load Json Config
'
,
async
()
=>
{
const
result
=
null
;
jest
.
spyOn
(
service
,
'
loadJsonConfig
'
).
mockImplementation
(
async
():
Promise
<
any
>
=>
result
);
expect
(
await
service
.
loadJsonConfig
(
"
filename
"
)).
toBe
(
result
);
});
it
(
'
should add signature
'
,
async
()
=>
{
const
result
=
"
signed html
"
;
jest
.
spyOn
(
service
,
'
addSignature
'
).
mockImplementation
(()
=>
{
return
result
});
expect
(
await
service
.
addSignature
(
"
html
"
)).
toBe
(
result
);
});
});
});
This diff is collapsed.
Click to expand it.
src/posts/posts.controller.spec.ts
+
21
−
0
View file @
1b1724ef
...
@@ -3,6 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing';
...
@@ -3,6 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import
{
ConfigurationModule
}
from
'
../configuration/configuration.module
'
;
import
{
ConfigurationModule
}
from
'
../configuration/configuration.module
'
;
import
{
PostsController
}
from
'
./posts.controller
'
;
import
{
PostsController
}
from
'
./posts.controller
'
;
import
{
PostsService
}
from
'
./posts.service
'
;
import
{
PostsService
}
from
'
./posts.service
'
;
import
{
PostWithMeta
}
from
'
./schemas/postWithMeta.schema
'
;
describe
(
'
PostsController
'
,
()
=>
{
describe
(
'
PostsController
'
,
()
=>
{
let
controller
:
PostsController
;
let
controller
:
PostsController
;
...
@@ -20,4 +21,24 @@ describe('PostsController', () => {
...
@@ -20,4 +21,24 @@ describe('PostsController', () => {
it
(
'
should be defined
'
,
()
=>
{
it
(
'
should be defined
'
,
()
=>
{
expect
(
controller
).
toBeDefined
();
expect
(
controller
).
toBeDefined
();
});
});
it
(
'
should get pending attachments
'
,
async
()
=>
{
const
result
:
PostWithMeta
=
{
posts
:[],
meta
:{
pagination
:
null
}};
const
query
=
""
;
jest
.
spyOn
(
controller
,
'
findAll
'
).
mockImplementation
(
async
():
Promise
<
any
>
=>
result
);
expect
(
await
controller
.
findAll
(
query
)).
toBe
(
result
);
});
it
(
'
should get pending attachments
'
,
async
()
=>
{
const
result
=
{
posts
:[]
};
jest
.
spyOn
(
controller
,
'
findAllTags
'
).
mockImplementation
(
async
():
Promise
<
any
>
=>
result
);
expect
(
await
controller
.
findAllTags
()).
toBe
(
result
);
});
it
(
'
should get pending attachments
'
,
async
()
=>
{
const
result
=
{
public
:[],
comune
:[],
others
:[]
};
const
id
=
"
78945945
"
jest
.
spyOn
(
controller
,
'
getPostbyId
'
).
mockImplementation
(
async
():
Promise
<
any
>
=>
result
);
expect
(
await
controller
.
getPostbyId
(
id
)).
toBe
(
result
);
});
});
});
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