Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@shivamG640
Copy link
Contributor

No description provided.

@shivamG640 shivamG640 force-pushed the fix_copy-paste-improved branch from b57f688 to 2a86fc6 Compare July 16, 2025 14:23
@codecov
Copy link

codecov bot commented Jul 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.62%. Comparing base (97b1f3b) to head (347c89b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2372      +/-   ##
==========================================
+ Coverage   81.61%   81.62%   +0.01%     
==========================================
  Files         464      464              
  Lines       14740    14750      +10     
  Branches     3227     3112     -115     
==========================================
+ Hits        12030    12040      +10     
  Misses       2708     2708              
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shivamG640 shivamG640 marked this pull request as ready for review July 16, 2025 15:02
@shivamG640 shivamG640 requested a review from lordrip July 16, 2025 15:05
// Mock the ClipboardItem
Object.assign(window, {
ClipboardItem: jest.fn(),
// Mocking ClipboardItem.supports
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lordrip , Not entirely sure if this is the proper way to mock both the ClipboardItem constructor and its static supports() method.

Copy link
Member

Choose a reason for hiding this comment

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

Wow, that's interesting 😄 , I've never seen it before.

Another way would be using:

jest.spyOn(ClipboardItem.prototype, 'supports');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Yup, I've seen that for functions, but I've never thought of using it for a class, you're a visionary @shivamG640. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was the only approach I found that actually worked, none of the other methods I tried were successful.
Could you take a look and see if it's possible to mock both the constructor and the static method within the same test block?
It would be interesting to explore other working examples if you come across any.

Copy link
Member

@lordrip lordrip left a comment

Choose a reason for hiding this comment

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

Looks good to me, just wondering about the any castings.

// Mock the ClipboardItem
Object.assign(window, {
ClipboardItem: jest.fn(),
// Mocking ClipboardItem.supports
Copy link
Member

Choose a reason for hiding this comment

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

Wow, that's interesting 😄 , I've never seen it before.

Another way would be using:

jest.spyOn(ClipboardItem.prototype, 'supports');

@shivamG640 shivamG640 force-pushed the fix_copy-paste-improved branch from 2a86fc6 to 347c89b Compare July 18, 2025 11:02
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 18, 2025

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@shivamG640 shivamG640 requested a review from lordrip July 18, 2025 11:43
Copy link
Member

@lordrip lordrip left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of the supports static method.

@lordrip lordrip merged commit cdba42e into KaotoIO:main Jul 18, 2025
13 checks passed
@shivamG640 shivamG640 deleted the fix_copy-paste-improved branch July 21, 2025 15:18
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.

2 participants