Skip to content

Commit

Permalink
Update jest.global-setup.js
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
lelemm and coderabbitai[bot] authored Nov 8, 2024
1 parent 490f010 commit 1ccf2ae
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions jest.global-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ const GENERIC_ADMIN_ID = 'genericAdmin';
const ADMIN_ROLE_ID = 'ADMIN';

const createUser = (userId, userName, role, owner = 0, enabled = 1) => {
if (!userId || !userName || !role) {
throw new Error('Missing required parameters');
const missingParams = [];
if (!userId) missingParams.push('userId');
if (!userName) missingParams.push('userName');
if (!role) missingParams.push('role');
if (missingParams.length > 0) {
throw new Error(`Missing required parameters: ${missingParams.join(', ')}`);
}

Check failure on line 15 in jest.global-setup.js

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
if (typeof userId !== 'string' || typeof userName !== 'string' || typeof role !== 'string') {

Check failure on line 16 in jest.global-setup.js

View workflow job for this annotation

GitHub Actions / lint

Replace `typeof·userId·!==·'string'·||·typeof·userName·!==·'string'·||·typeof·role·!==·'string'` with `⏎····typeof·userId·!==·'string'·||⏎····typeof·userName·!==·'string'·||⏎····typeof·role·!==·'string'⏎··`
throw new Error('Invalid parameter types. userId, userName, and role must be strings');

Check failure on line 17 in jest.global-setup.js

View workflow job for this annotation

GitHub Actions / lint

Replace `'Invalid·parameter·types.·userId,·userName,·and·role·must·be·strings'` with `⏎······'Invalid·parameter·types.·userId,·userName,·and·role·must·be·strings',⏎····`
}

try {
getAccountDb().mutate(
'INSERT INTO users (id, user_name, display_name, enabled, owner, role) VALUES (?, ?, ?, ?, ?, ?)',
[userId, userName, `${userName} display`, enabled, owner, role],
[userId, userName, userName, enabled, owner, role],
);
} catch (error) {
console.error('Error creating user:', error);
console.error(`Error creating user ${userName}:`, error);
throw error;
}
};
Expand Down

0 comments on commit 1ccf2ae

Please sign in to comment.