Skip to content

Instantly share code, notes, and snippets.

@HenriqueSilverio
Created December 3, 2021 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HenriqueSilverio/ad78fe0e8e90fea21b5df38b65db7ae2 to your computer and use it in GitHub Desktop.
Save HenriqueSilverio/ad78fe0e8e90fea21b5df38b65db7ae2 to your computer and use it in GitHub Desktop.
/**
* Scenario:
* The user requests an account sync
* Given the account
* And the institution of account
* And the user of account
* When the user requests the account sync
* Then a sync is scheduled
* And the sync scheduled event is created
*/
const getAccountRequestedToSync = () => ({
waiting: false,
isWaiting() {
return this.waiting
},
scheduleSync() {
this.waiting = true
},
events: {
syncScheduled: {
create() {
return {
type: 'SYNC_SCHEDULED'
}
}
}
},
})
const getInstitutionOfAccount = () => ({})
const getUserOfAccount = () => ({})
const account = getAccountRequestedToSync()
const institution = getInstitutionOfAccount(account)
const user = getUserOfAccount(account)
console.assert(!account.isWaiting(), 'Expected waiting to be falsy, received truthy')
account.scheduleSync(institution, user)
console.assert(account.isWaiting(), 'Expected waiting to be truthy, received falsy')
const syncScheduled = account.events.syncScheduled.create({
account,
institution,
user
})
console.assert(syncScheduled, 'Expected syncScheduled to be truthy, received falsy')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment