Created
December 3, 2021 21:25
-
-
Save HenriqueSilverio/ad78fe0e8e90fea21b5df38b65db7ae2 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* 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