Last active
February 11, 2022 19:06
-
-
Save kelly-tock/4a747b4caebcaef1c8b4b25e2f433eaf to your computer and use it in GitHub Desktop.
example of separating a builder from renderer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LocalDate } from 'js-joda'; | |
import { ViewInitializer, renderTest } from 'test/testUtils'; | |
import { initialState } from 'state/app'; | |
import AppConstants from 'constants/AppConstants'; | |
import React from 'react'; | |
import WalkinWaitlistActionCard from 'components/business/walkin-waitlist/WalkinWaitlistActionCard'; | |
describe('<WalkinWaitlistActionCard />', () => { | |
const defaultBusiness = { | |
id: 123, | |
domainName: 'testWalkinWaitlist', | |
onlineWalkinWaitlistEnabled: true, | |
}; | |
const viewInitializer = ViewInitializer.build() | |
.setFeatureFlag('ONLINE_WALKIN_WAITLIST') | |
.setStoreState('app', { | |
...initialState, | |
config: { | |
...initialState.config, | |
business: defaultBusiness, | |
}, | |
}); | |
it('Shows action card for waitlisted parties', () => { | |
const viewInitializer2 = viewInitializer | |
.setAction({ | |
type: AppConstants.WALK_IN_WAITLIST_ADD_DONE, | |
payload: { | |
businessId: 123, | |
partyId: -12, | |
serviceDate: LocalDate.now().toString(), | |
}, | |
}); | |
const { container } = renderTest( | |
<WalkinWaitlistActionCard business={defaultBusiness} className="actionCard-test" />, | |
viewInitializer2 | |
); | |
expect(container.firstChild).toMatchSnapshot(); | |
}); | |
it('does not need an initializer at all for really simple things', () => { | |
const { container } = renderTest(<Button>test</Button>); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment