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

Snapshot test for usernameToColor function #1346

Merged
merged 4 commits into from
Oct 16, 2020
Merged

Conversation

juliushaertl
Copy link
Contributor

@juliushaertl juliushaertl commented Aug 25, 2020

This adds some basic snapshot testing for the usernameToColor functionality, which mainly aims to get a testset that we can use to test different implementations of the same algorithm against, e.g. in the android app.

A JSON export can be generated with
node ./build/usernameToColor-export.js

JSON output for the current snapshot

{"":"#0082c9",",":"#1e78c1",".":"#c98879","123e4567-e89b-12d3-a456-426614174000":"#bc5c91","Akeel Robertson":"#9750a4","Alishia Ann Lowry":"#d09e6d","Arham Johnson":"#0082c9","Brayden Truong":"#d09e6d","Daphne Roy":"#9750a4","Ellena Wright Frederic Conway":"#c37285","Gianluca Hills":"#d6b461","Haseeb Stephens":"#d6b461","Idris Mac":"#9750a4","Kristi Fisher":"#0082c9","Lillian Wall":"#bc5c91","Lorelai Taylor":"#ddcb55","Madina Knight":"#9750a4","Meeting":"#c98879","Private Circle":"#c37285","Rae Hope":"#795aab","Santiago Singleton":"#bc5c91","Sid Combs":"#d09e6d","TestCircle":"#499aa2","Tom Mörtel":"#248eb5","Vivienne Jacobs":"#1e78c1","Zaki Cortes":"#6ea68f","a user":"#5b64b3","admin":"#d09e6d","admin@cloud.example.com":"#9750a4","another user":"#ddcb55","asd":"#248eb5","bar":"#0082c9","foo":"#d09e6d","wasd":"#b6469d","مرحبا بالعالم":"#c98879","🙈":"#b6469d"}

cc @tobiasKaminsky

const snapshot = require('./../src/functions/usernameToColor/__snapshots__/usernameToColor.spec.js.snap')
const result = {}
Object.keys(snapshot).map((key) => {
const uid = key.replace('usernameToColor ', '').replace(' has the proper color 1', '')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There might be a more sane way to properly deserialize the jest snapshot but for now this does the trick

@tobiasKaminsky
Copy link

Can we also have a tests for

  • "" (no name)
  • Meeting
  • Private Circle
  • TestCircle
    (just so that we have evry share type included)

@skjnldsv skjnldsv added 2. developing Work in progress enhancement New feature or request labels Aug 25, 2020
@juliushaertl juliushaertl added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Aug 25, 2020
@skjnldsv
Copy link
Contributor

Ping? :D

@juliushaertl
Copy link
Contributor Author

Pong ....

Waiting for reviews 😁

Copy link
Contributor

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

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

🚀

Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Copy link
Contributor

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

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

Still 👌

Copy link
Contributor

@marcoambrosini marcoambrosini left a comment

Choose a reason for hiding this comment

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

Tested and works!

@skjnldsv skjnldsv merged commit 4b83bc2 into master Oct 16, 2020
@skjnldsv skjnldsv deleted the tests/noid/color-snapshot branch October 16, 2020 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants