Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
Wichtelbot
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
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
dnns01
Wichtelbot
Commits
5cae1ba7
Commit
5cae1ba7
authored
3 years ago
by
Benedikt Magnus
Browse files
Options
Downloads
Patches
Plain Diff
Added exclusion test for the assignment module.
parent
0a4e749a
No related branches found
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
tests/tests/wichtelbot.message.module.assignment.ts
+54
-0
54 additions, 0 deletions
tests/tests/wichtelbot.message.module.assignment.ts
tests/utility/relationship.ts
+13
-1
13 additions, 1 deletion
tests/utility/relationship.ts
with
67 additions
and
1 deletion
tests/tests/wichtelbot.message.module.assignment.ts
+
54
−
0
View file @
5cae1ba7
...
...
@@ -6,6 +6,8 @@ import Database from '../../scripts/wichtelbot/database';
import
GiftType
from
'
../../scripts/wichtelbot/types/giftType
'
;
import
Member
from
'
../../scripts/wichtelbot/classes/member
'
;
import
{
RelationshipTestUtility
}
from
'
../utility/relationship
'
;
import
{
ExclusionData
}
from
'
../../scripts/wichtelbot/classes/exclusion
'
;
import
{
ExclusionReason
}
from
'
../../scripts/wichtelbot/types/exclusionReason
'
;
describe
(
'
assignment module
'
,
function
()
...
...
@@ -157,6 +159,58 @@ describe('assignment module',
}
);
it
(
'
can assign members with exclusions
'
,
function
()
{
const
newMembers
:
Member
[]
=
[];
for
(
let
i
=
0
;
i
<
4
;
i
++
)
{
const
newMember
=
ContactTestUtility
.
createRandomMemberWithMostCompatibleInformation
();
newMembers
.
push
(
newMember
);
database
.
saveContact
(
newMember
);
database
.
saveMember
(
newMember
);
}
const
exclusions
:
ExclusionData
[]
=
[
{
giverId
:
newMembers
[
0
].
id
,
takerId
:
newMembers
[
1
].
id
,
reason
:
ExclusionReason
.
Wish
,
},
{
giverId
:
newMembers
[
0
].
id
,
takerId
:
newMembers
[
2
].
id
,
reason
:
ExclusionReason
.
Wish
,
},
{
giverId
:
newMembers
[
1
].
id
,
takerId
:
newMembers
[
2
].
id
,
reason
:
ExclusionReason
.
Wish
,
},
{
giverId
:
newMembers
[
1
].
id
,
takerId
:
newMembers
[
3
].
id
,
reason
:
ExclusionReason
.
Wish
,
},
];
database
.
saveUserExclusions
(
exclusions
);
const
successful
=
assignmentModule
.
assign
();
assert
.
isTrue
(
successful
);
const
relationships
=
database
.
getRelationships
();
assert
.
equal
(
relationships
.
length
,
4
);
RelationshipTestUtility
.
assertValidity
(
relationships
,
newMembers
);
RelationshipTestUtility
.
assertCompatibility
(
relationships
,
newMembers
,
exclusions
);
}
);
it
(
'
cannot assign with zero members
'
,
function
()
{
...
...
This diff is collapsed.
Click to expand it.
tests/utility/relationship.ts
+
13
−
1
View file @
5cae1ba7
import
{
assert
}
from
"
chai
"
;
import
{
ExclusionData
}
from
"
../../scripts/wichtelbot/classes/exclusion
"
;
import
{
ExclusionReason
}
from
"
../../scripts/wichtelbot/types/exclusionReason
"
;
import
GiftType
from
"
../../scripts/wichtelbot/types/giftType
"
;
import
Member
from
"
../../scripts/wichtelbot/classes/member
"
;
import
{
Relationship
}
from
"
../../scripts/wichtelbot/classes/relationship
"
;
...
...
@@ -39,7 +41,7 @@ export abstract class RelationshipTestUtility
/**
* Proofs the compatibility of every relationship.
*/
public
static
assertCompatibility
(
relationships
:
Relationship
[],
members
:
Member
[]):
void
public
static
assertCompatibility
(
relationships
:
Relationship
[],
members
:
Member
[],
exclusions
:
ExclusionData
[]
=
[]):
void
{
for
(
const
relationship
of
relationships
)
{
...
...
@@ -81,6 +83,16 @@ export abstract class RelationshipTestUtility
const
isInternationalCompatible
=
countriesAreTheSame
||
noneHasAnalogueGiftType
||
giver
.
information
.
internationalAllowed
;
assert
.
isTrue
(
isInternationalCompatible
,
'
International compatibility check failed
'
);
for
(
const
exclusion
of
exclusions
)
{
if
(
exclusion
.
reason
==
ExclusionReason
.
Wish
)
{
const
isNoExclusion
=
exclusion
.
giverId
!==
giver
.
id
||
exclusion
.
takerId
!==
taker
.
id
;
assert
.
isTrue
(
isNoExclusion
,
'
Exclusion compatibility check failed
'
);
}
}
}
}
}
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