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

Unit tests #4

Merged
merged 10 commits into from
Jan 12, 2022
Merged

Unit tests #4

merged 10 commits into from
Jan 12, 2022

Conversation

TamaraBogantseva
Copy link
Contributor

@TamaraBogantseva TamaraBogantseva commented Jan 12, 2022

Checklist

Reviewer

  • I've checked out the code and tested it myself.

Changes

  • configure jest for unit tests.
  • create link test
  • shuffle participant test
  • change create link test and function = pass encoding func as a param
  • validate shuffle test
  • form serializer test

@TamaraBogantseva TamaraBogantseva changed the base branch from main to dev January 12, 2022 09:14
@TamaraBogantseva TamaraBogantseva added 🤓 review needed Someone needs to review this PR dependencies Pull requests that update a dependency file labels Jan 12, 2022
@TamaraBogantseva TamaraBogantseva marked this pull request as ready for review January 12, 2022 15:54
Copy link
Contributor

@cowglow cowglow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. Let's try to name the function on the initial describe block.
And always check for dead code like our friend the tab space that we found.

@@ -2,10 +2,9 @@ import type { Participant } from '$lib/stores/participants-store';

type linkParams = { participant: Participant; assignment: Participant };

export function createLink(url: string, { participant, assignment }: linkParams): string {
export function createLink(url: string, { participant, assignment }: linkParams, encode:Function = btoa): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, now we can pass any kind of encoder we want. Let's change the name to encoder please.

@@ -10,7 +10,7 @@ export const randomizeParticipants = (participants: Participant[]): Participant[
const temp = _participants[randomIndex];

_participants[randomIndex] = _participants[i];
_participants[i] = temp;
_participants[i] = temp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for the tab space

import { validateShuffle } from "./validate-shuffle";
import { demoParticipants } from '../demo-participants'

describe('check that func return what we expected', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe adding the name of the function will help better read the jest log.

@TamaraBogantseva TamaraBogantseva merged commit 227ca84 into dev Jan 12, 2022
@TamaraBogantseva TamaraBogantseva deleted the unit-tests branch January 12, 2022 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file 🤓 review needed Someone needs to review this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit Tests of utility functions
2 participants