Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
ss22-devops-project-app
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
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Dobromir Palushev
ss22-devops-project-app
Commits
0f5dd2da
Unverified
Commit
0f5dd2da
authored
4 years ago
by
Lucendio
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #4 from RufusGladiuz/Add_Test
Added DB-Test
parents
f596e81b
73e08ed0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/server/src/models/Todos.test.js
+47
-0
47 additions, 0 deletions
app/server/src/models/Todos.test.js
with
47 additions
and
0 deletions
app/server/src/models/Todos.test.js
0 → 100644
+
47
−
0
View file @
0f5dd2da
const
dbClientInstance_
=
require
(
'
../db/mongo.js
'
);
const
{
model
:
Todos
}
=
require
(
'
./Todos.js
'
);
const
mongoose
=
require
(
'
mongoose
'
);
describe
(
'
Todos: Todos
'
,
()
=>
{
beforeAll
(
async
()
=>
{
try
{
await
dbClientInstance_
;
}
catch
(
err
){
console
.
warn
(
"
Error
"
)
console
.
error
(
new
Error
(
`Cannot connect to database:
${
process
.
env
.
MONGODB_URL
}
`
)
);
process
.
exit
(
1
);
}
});
test
(
'
creating a todo
'
,
async
()
=>
{
console
.
debug
(
"
Creating Todo
"
)
const
todoData
=
{
title
:
'
Homework
'
,
description
:
'
Devops project 2020
'
,
user
:
mongoose
.
Types
.
ObjectId
()
};
console
.
warn
(
"
Done
"
)
const
todoDoc
=
await
Todos
(
todoData
);
await
todoDoc
.
save
();
console
.
warn
(
"
todo Record
"
)
const
todoRecord
=
await
Todos
.
findOne
({
user
:
todoData
.
user
});
console
.
warn
(
"
PW
"
)
const
{
description
,
...
todoInfo
}
=
todoData
;
expect
(
todoRecord
).
toEqual
(
expect
.
objectContaining
(
todoInfo
)
);
});
afterAll
(
async
()
=>
{
console
.
warn
(
"
PW2
"
)
const
dbClient
=
await
dbClientInstance_
;
const
{
connection
}
=
dbClient
;
await
connection
.
dropDatabase
();
await
dbClient
.
disconnect
();
});
});
\ No newline at end of file
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