-
Notifications
You must be signed in to change notification settings - Fork 5
feat: adds gap property #29
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
39a94d9
01fec8b
6a820bd
840eac4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,4 +140,24 @@ describe('<Flex /> component', () => { | |
expect(container).not.toHaveStyle('flex-direction: column'); // default/fallback | ||
}); | ||
}); | ||
|
||
describe('gap prop', () => { | ||
test('has gap prop set to 1 rem', () => { | ||
const container = renderFlex({ gap: '1rem' }); | ||
expect(container).toHaveStyle('gap: 1rem'); | ||
expect(container).not.toHaveStyle('gap: 0rem'); | ||
}); | ||
|
||
test('does not has gap prop', () => { | ||
const container = renderFlex(); | ||
expect(container).toHaveStyle('gap: 0'); | ||
expect(container).not.toHaveStyle('gap: 1rem'); | ||
}); | ||
|
||
test('bad value', () => { | ||
const container = renderFlex({ gap: 'oops' }); | ||
expect(container).not.toHaveStyle('gap: 1rem'); | ||
expect(container).not.toHaveStyle('gap: 0'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great tests! 😄 Perhaps we can also add an expected fallback/default value? (the initial value we discussed above). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how can i test this? as far as i know, if i make the default value for the gap prop equal to undefined, the svelte style directive would just ignore it and not pass anything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the initial value for Try this: expect(container).toHaveStyle({ gap: 'normal normal' }); If not, I'd say the tests you've already added are sufficient. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tried expecting it to have |
||
}); | ||
}) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a number, not a string.
Eventually I'd like to add Typescript definitions for this package, which would help make this more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think this should be the initial value for
gap
, which I think is'normal normal'
(based on MDN). Either that or we should perhaps leave it undefined/null or something, as I don't want it to be applied if consumers aren't using it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think that leaving as null / undefined would be better (because it wouldnt be applied)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes let's leave it as
null
orundefined