Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve settings tests and validation #27

Merged
merged 5 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const settings = JSON.parse(
const settings_validations = {
username: (name) => typeof name === "string",
password: (pass) => typeof pass === "string" && pass.startsWith("oauth"),
channel: (channel) => typeof channel === "string",
channel: (channel) => typeof channel === "string" && /^[a-z0-9_]{3,}$/.test(channel), // channel needs to be a valid twitch username (this is used in the chatters URL in twitch.js)
start_open: (open) => typeof open === "boolean",
enable_absolute_position: (absolute_position) => typeof absolute_position === "boolean",
custom_codes_enabled: cc => typeof cc === "boolean",
Expand Down
2 changes: 2 additions & 0 deletions tests/chat-logs/chat-logs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ for (const file of testFiles) {
} else if (command == 'accuracy') {
accuracy = parseInt(rest);
} else if (command == 'settings') {
// TODO: ideally new settings would be written to settings.json
// and settings.js could be reloaded instead to validate settings
replaceSettings(test.settings, JSON.parse(rest));
} else if (command == 'chatters') {
simSetChatters(JSON.parse(rest));
Expand Down