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

feat(Utility): expose UUID generator #303

Merged
merged 2 commits into from
May 28, 2019
Merged

Conversation

benjamincharity
Copy link
Contributor

ISSUES CLOSED: #91

  • Expose UUID generator

@codecov
Copy link

codecov bot commented May 24, 2019

Codecov Report

Merging #303 into release will increase coverage by 0.13%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           release     #303      +/-   ##
===========================================
+ Coverage    80.53%   80.67%   +0.13%     
===========================================
  Files           94       95       +1     
  Lines         1115     1123       +8     
  Branches       186      186              
===========================================
+ Hits           898      906       +8     
  Misses         217      217
Flag Coverage Δ
#coercion 100% <ø> (ø) ⬆️
#keycodes 100% <ø> (ø) ⬆️
#regex 100% <ø> (ø) ⬆️
#testing 33.82% <ø> (-0.25%) ⬇️
#utilities 95.15% <100%> (+0.05%) ⬆️
Impacted Files Coverage Δ
ngx-tools/testing/src/utilities/event-objects.ts 100% <ø> (ø) ⬆️
ngx-tools/src/uuid/uuid.ts 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f323396...7b198da. Read the comment docs.

@codecov
Copy link

codecov bot commented May 24, 2019

Codecov Report

Merging #303 into release will increase coverage by 0.13%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           release     #303      +/-   ##
===========================================
+ Coverage    80.53%   80.67%   +0.13%     
===========================================
  Files           94       95       +1     
  Lines         1115     1123       +8     
  Branches       186      186              
===========================================
+ Hits           898      906       +8     
  Misses         217      217
Flag Coverage Δ
#coercion 100% <ø> (ø) ⬆️
#keycodes 100% <ø> (ø) ⬆️
#regex 100% <ø> (ø) ⬆️
#testing 33.82% <ø> (-0.25%) ⬇️
#utilities 95.15% <100%> (+0.05%) ⬆️
Impacted Files Coverage Δ
ngx-tools/testing/src/utilities/event-objects.ts 100% <ø> (ø) ⬆️
ngx-tools/src/uuid/uuid.ts 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e49ecb...3298a8a. Read the comment docs.

@@ -96,6 +96,7 @@ describe(`JWT Token Effects`, function() {
};

test(`should provide a cookie and store cookie message if the cookie is set`, () => {
// tslint:disable-next-line deprecation
Copy link
Contributor

Choose a reason for hiding this comment

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

What is getting deprecated, here, 118, 136, and 155?

@@ -14,6 +14,7 @@ describe(`retryWithBackoff`, function() {
const error = new Error('bar');
const seenValues: {[idx: number]: number} = {};

// tslint:disable-next-line deprecation
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, so I will assume of is getting deprecated.
Do we have a plan of updating our code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're actually just getting around a TSLint bug. The deprecation rule is triggered even though of itself is not deprecated; only certain overloads are. We did this a bit here also GetTerminus/terminus-ui#1488

There is an open PR to fix this which would allow us to remove all of these disables. But since TSLint itself is deprecated I'm not holding my breath on it getting fixed.

@@ -50,7 +50,7 @@ describe(`event-objects`, function() {
const actual: KeyboardEvent = createKeyboardEvent('keydown', KEYS.ENTER, target);
expect(actual.code).toEqual(KEYS.ENTER.code);
expect(actual.key).toEqual(KEYS.ENTER.code);
expect(actual.keyCode).toEqual(KEYS.ENTER.keyCode);
expect(actual.code).toEqual(KEYS.ENTER.code);
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate of line 51
have we removed all references to keyCode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

I didn't do a full search as that's not the basis of this PR. I'm honestly not entirely sure how these were missed in the linting PR. They should have been flagged by the deprecation rule when it was implemented.


// Test Validity
if (!uuidRegex.test(newUuid)) {
done.fail(new Error('This is the error'));
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's only a test but the message could be more descriptive: 'UUID is not valid'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops.. yeah definitely should make that better.

@shani-terminus
Copy link
Contributor

Looks like public-api.ts still needs to be updated.

@benjamincharity
Copy link
Contributor Author

Huh not sure how that got dropped. Re-added to public api 👍

@@ -220,7 +220,8 @@
"tsickle": "^0.34.0",
"tslint": "^5.16.0",
"typescript": "~3.2.1",
"validate-commit-msg": "^2.14.0"
"validate-commit-msg": "^2.14.0",
"window-crypto": "^1.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need this to use window.crypto.getRandomValues?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only for testing. Jest doesn't have a polyfill for window.crypto by default. So in order to test it as accurately as possible, I'm just polyfilling the functionality as a whole (vs just mocking it).

setItem: (key: string, value: any) => {
storage[key] = value || '';
return storage[key];
},
removeItem: (key: string) => delete storage[key],
clear: () => storage = {},
clear: () => (storage = {}),
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the parenthesis needed or for better readability?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kind of. Creating an assignment in a return statement can be confusing so we have a lint rule warning about this.

The () is just us being explicit that something is happening inside, then it returns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A better way for me to phrase it: It is not more readable, but the intent should be more clear.

@benjamincharity benjamincharity merged commit beee1f7 into release May 28, 2019
@benjamincharity benjamincharity deleted the 91-uuid-clean-branch branch June 12, 2019 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Utility: UUID
3 participants