Created
October 1, 2015 10:46
-
-
Save rhyslbw/2333d4ddab4d4291a2f3 to your computer and use it in GitHub Desktop.
Proposed API for abstracting timestamp checking in Space Aggregate testing
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
describe 'Space.accounts.User', -> | |
beforeEach -> | |
@createUser = new Space.accounts.CreateUser { | |
targetId: new Guid | |
username: new Username('testUsername') | |
email: new EmailAddress('test@email.com') | |
password: new Password('123') | |
} | |
describe 'creating users', -> | |
it 'publishes user created events', -> | |
TestAggregate(Space.accounts.User) | |
.Given(@createUser) | |
.Expect([ | |
new Space.accounts.UserCreated { | |
sourceId: @createUser.targetId | |
timestamp: @date() | |
username: @createUser.username | |
email: @createUser.email | |
password: @createUser.password | |
} | |
]) | |
describe 'authorising users', -> | |
it 'publishes user logged in events', -> | |
TestAggregate(Space.accounts.User) | |
.Given([ | |
new Space.accounts.UserCreated { | |
sourceId: @createUser.targetId | |
timestamp: new Date() | |
username: @createUser.username | |
email: @createUser.email | |
password: @createUser.password | |
} | |
]) | |
.When([ | |
new Space.accounts.RegisterSuccessfulLogin { | |
targetId: @createUser.targetId | |
type: "password" | |
} | |
]) | |
.Expect([ | |
new Space.accounts.UserLoggedIn { | |
sourceId: @createUser.targetId | |
timestamp: @date() | |
via: "password" | |
} | |
]) | |
it 'publishes user login error events', -> | |
TestAggregate(Space.accounts.User) | |
.Given([ | |
new Space.accounts.UserCreated { | |
sourceId: @createUser.targetId | |
timestamp: new Date() | |
username: @createUser.username | |
email: @createUser.email | |
password: @createUser.password | |
} | |
]) | |
.When([ | |
new Space.accounts.RegisterFailedLogin { | |
targetId: @createUser.targetId | |
type: "password" | |
error: "Login attempt failed" | |
} | |
]) | |
.Expect([ | |
new Space.accounts.UserLoginFailed { | |
sourceId: @createUser.targetId | |
timestamp: @date() | |
via: "password" | |
error: "Login attempt failed" | |
} | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment