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

Add Small image ui style tests #310

Merged

Conversation

rymorale
Copy link
Contributor

Description

These tests should be merged after #308

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 30.80%. Comparing base (ee0c04f) to head (dcde21c).
Report is 8 commits behind head on feature/content-cards.

❗ There is a different number of reports uploaded between BASE (ee0c04f) and HEAD (dcde21c). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (ee0c04f) HEAD (dcde21c)
unit-tests 1 0
Additional details and impacted files
@@                     Coverage Diff                      @@
##             feature/content-cards     #310       +/-   ##
============================================================
- Coverage                    76.57%   30.80%   -45.78%     
+ Complexity                     769      252      -517     
============================================================
  Files                           78       78               
  Lines                         3688     3688               
  Branches                       568      568               
============================================================
- Hits                          2824     1136     -1688     
- Misses                         717     2346     +1629     
- Partials                       147      206       +59     
Flag Coverage Δ
functional-tests 30.80% <ø> (-0.09%) ⬇️
unit-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Comment on lines 119 to 125
// verify image style parameters
assertEquals(imageStyle.alpha, style.imageStyle.alpha)
assertEquals(imageStyle.colorFilter, style.imageStyle.colorFilter)
assertEquals(imageStyle.contentDescription, style.imageStyle.contentDescription)
assertEquals(imageStyle.alignment, style.imageStyle.alignment)
assertEquals(imageStyle.contentScale, style.imageStyle.contentScale)
assertEquals(imageStyle.modifier, style.imageStyle.modifier)

Choose a reason for hiding this comment

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

Can you add helper methods for comparing style totally similar elements. That will allow you to re-use them for other templates and make these tests less verbose (thought partial style overrides will still need to compared individually)

}

@Test
fun `create SmallImageUIStyle with some custom builder styles used`() {

Choose a reason for hiding this comment

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

Would you be willing to split & expand this into specific tests that override individual style elements (image style, title text style etc). This will allow us to ensure that any new logic introduced later (perhaps to influence one element style due to another) breaks the tests and enforce writing new tests to accommodate changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, i'll get these split up per style type

Comment on lines 62 to 67
assertEquals(overridingStyle.textStyle?.textStyle, result.textStyle?.textStyle)
assertEquals(overridingStyle.textStyle?.overflow, result.textStyle?.overflow)
assertEquals(overridingStyle.textStyle?.softWrap, result.textStyle?.softWrap)
assertEquals(overridingStyle.textStyle?.maxLines, result.textStyle?.maxLines)
assertEquals(overridingStyle.textStyle?.minLines, result.textStyle?.minLines)
assertEquals(overridingStyle.textStyle?.modifier, result.textStyle?.modifier)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can we use the new utility validateTextStyle here?

import org.mockito.Mockito.mock

class SmallImageUIStyleTests {
val defaultSmallImageUIStyle = SmallImageUIStyle.Builder().build()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can we also add a test for create SmallImageUIStyle no builder styles used and verify that the default style is used to all elements?

Copy link
Contributor

@spoorthipujariadobe spoorthipujariadobe left a comment

Choose a reason for hiding this comment

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

LGTM, some minor nits

@rymorale rymorale merged commit c3f3547 into adobe:feature/content-cards Nov 26, 2024
8 of 9 checks passed
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.

3 participants