mirror of
https://github.com/AlecM33/Werewolf.git
synced 2026-02-10 04:03:33 +01:00
Add independent alignment for custom roles (#217)
* Initial plan * Add independent alignment: constants, validation, UI, and CSS Co-authored-by: AlecM33 <24642328+AlecM33@users.noreply.github.com> * Add unit tests for independent alignment validation Co-authored-by: AlecM33 <24642328+AlecM33@users.noreply.github.com> * Fix remaining binary alignment checks in role display Co-authored-by: AlecM33 <24642328+AlecM33@users.noreply.github.com> * Add independent player container and game-role-independent CSS Co-authored-by: AlecM33 <24642328+AlecM33@users.noreply.github.com> * fix a couple bugs, tweak colors * remove import * remove duplicate tag --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AlecM33 <24642328+AlecM33@users.noreply.github.com> Co-authored-by: AlecM33 <leohfx@gmail.com>
This commit is contained in:
104
spec/unit/server/model/GameCreationRequest_Spec.js
Normal file
104
spec/unit/server/model/GameCreationRequest_Spec.js
Normal file
@@ -0,0 +1,104 @@
|
||||
const GameCreationRequest = require('../../../../server/model/GameCreationRequest');
|
||||
const { ALIGNMENT } = require('../../../../server/config/globals');
|
||||
|
||||
describe('GameCreationRequest', () => {
|
||||
describe('#deckIsValid', () => {
|
||||
it('should accept a deck with good, evil, and independent roles', () => {
|
||||
const deck = [
|
||||
{
|
||||
role: 'Villager',
|
||||
team: ALIGNMENT.GOOD,
|
||||
description: 'A simple villager',
|
||||
custom: false,
|
||||
quantity: 2
|
||||
},
|
||||
{
|
||||
role: 'Werewolf',
|
||||
team: ALIGNMENT.EVIL,
|
||||
description: 'A werewolf',
|
||||
custom: false,
|
||||
quantity: 1
|
||||
},
|
||||
{
|
||||
role: 'Tanner',
|
||||
team: ALIGNMENT.INDEPENDENT,
|
||||
description: 'An independent role',
|
||||
custom: true,
|
||||
quantity: 1
|
||||
}
|
||||
];
|
||||
|
||||
expect(GameCreationRequest.deckIsValid(deck)).toBe(true);
|
||||
});
|
||||
|
||||
it('should accept a deck with only good roles', () => {
|
||||
const deck = [
|
||||
{
|
||||
role: 'Villager',
|
||||
team: ALIGNMENT.GOOD,
|
||||
description: 'A simple villager',
|
||||
custom: false,
|
||||
quantity: 3
|
||||
}
|
||||
];
|
||||
|
||||
expect(GameCreationRequest.deckIsValid(deck)).toBe(true);
|
||||
});
|
||||
|
||||
it('should accept a deck with only evil roles', () => {
|
||||
const deck = [
|
||||
{
|
||||
role: 'Werewolf',
|
||||
team: ALIGNMENT.EVIL,
|
||||
description: 'A werewolf',
|
||||
custom: false,
|
||||
quantity: 2
|
||||
}
|
||||
];
|
||||
|
||||
expect(GameCreationRequest.deckIsValid(deck)).toBe(true);
|
||||
});
|
||||
|
||||
it('should accept a deck with only independent roles', () => {
|
||||
const deck = [
|
||||
{
|
||||
role: 'Tanner',
|
||||
team: ALIGNMENT.INDEPENDENT,
|
||||
description: 'An independent role',
|
||||
custom: true,
|
||||
quantity: 1
|
||||
}
|
||||
];
|
||||
|
||||
expect(GameCreationRequest.deckIsValid(deck)).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject a deck with invalid team values', () => {
|
||||
const deck = [
|
||||
{
|
||||
role: 'InvalidRole',
|
||||
team: 'invalid',
|
||||
description: 'Invalid team',
|
||||
custom: true,
|
||||
quantity: 1
|
||||
}
|
||||
];
|
||||
|
||||
expect(GameCreationRequest.deckIsValid(deck)).toBe(false);
|
||||
});
|
||||
|
||||
it('should reject a deck with missing required fields', () => {
|
||||
const deck = [
|
||||
{
|
||||
role: 'Villager',
|
||||
// missing team
|
||||
description: 'A simple villager',
|
||||
custom: false,
|
||||
quantity: 1
|
||||
}
|
||||
];
|
||||
|
||||
expect(GameCreationRequest.deckIsValid(deck)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user