Last active
April 27, 2016 10:35
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
test "Sebastian commented on Matylda's gallery: Looks awesome!", (assert) -> | |
assert.expect 1 | |
commenter = Ember.Object.create( # mock for Ember DS.Model | |
displayName: "Sebastian" | |
) | |
galleryOwner = Ember.Object.create( | |
id: 2, | |
displayName: "Matylda" | |
) | |
gallery = Ember.Object.create( | |
name: "Paintings" | |
owner: galleryOwner | |
) | |
comment = Ember.Object.create( | |
id: 1, | |
text: "Looks awesome!", | |
commenter: commenter, | |
gallery: gallery, | |
) | |
notification = Ember.Object.create( | |
id: 1, | |
comment: comment | |
) | |
@set('notification', notification) | |
@render hbs """{{notifications/new-comment/gallery-notification notification=notification}}""" | |
assert.equal @$().text().trim(), "Sebastian commented on Matylda's gallery: Looks awesome!" |
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
# component's template | |
notification.comment.commenter.displayName | |
| commented on | |
notification.comment.gallery.owner.displayName | |
| 's gallery: | |
notification.comment.text |
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
# component | |
`import Ember from "ember"` | |
GalleryNotification = Ember.Component.extend | |
comment: Ember.computed.readOnly('notification.comment') | |
commenter: Ember.computed.readOnly('comment.commenter') | |
gallery: Ember.computed.readOnly('comment.gallery') | |
galleryOwner: Ember.computed.readOnly('gallery.owner') | |
`export default GalleryNotification` | |
# template | |
commenter.displayName | |
| commented on | |
galleryOwner.displayName | |
|'s gallery: | |
| | |
comment.text |
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
test 'when Sebastian commented on his own gallery: Looks awesome!', (assert) -> | |
assert.expect 1 | |
commenter = Ember.Object.create( | |
id: 1, | |
displayName: "Sebastian", | |
gender: 'male' | |
) | |
gallery = Ember.Object.create( | |
name: "Paintings", | |
owner: commenter | |
) | |
comment = Ember.Object.create( | |
id: 1, | |
text: "Looks awesome!", | |
commenter: commenter, | |
gallery: gallery | |
) | |
notification = Ember.Object.create( | |
id: 1, | |
comment: comment | |
) | |
@set('notification', notification) | |
@render hbs """{{notifications/new-comment/gallery-notification notification=notification}}""" | |
assert.equal @$().text().trim(), 'Sebastian commented on his own gallery: Looks awesome!' |
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
# component | |
GalleryNotification = Ember.Component.extend | |
comment: Ember.computed.readOnly('notification.comment') | |
commenter: Ember.computed.readOnly('comment.commenter') | |
gallery: Ember.computed.readOnly('comment.gallery') | |
galleryOwner: Ember.computed.readOnly('gallery.owner') | |
hasCommentedOwnGallery: Ember.computed 'commenter', 'galleryOwner', -> | |
@get('commenter') == @get('galleryOwner') | |
isCommenterMale: Ember.computed 'commenter', -> | |
@get('commenter.gender') == 'male' | |
# template | |
commenter.displayName | |
| commented on | |
if hasCommentedOwnCreation | |
if isCommenterMale | |
_ "his own" | |
else | |
galleryOwner.displayName | |
_"'s gallery" space='e' | |
comment.text |
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
test 'when Matylda commented on her own gallery: Looks awesome!', (assert) -> | |
assert.expect 1 | |
commenter = Ember.Object.create( | |
id: 1, | |
displayName: "Matylda", | |
gender: 'female', | |
) | |
gallery = Ember.Object.create( | |
name: "Paintings", | |
owner: commenter, | |
) | |
comment = Ember.Object.create( | |
id: 1, | |
text: "Looks awesome!", | |
commenter: commenter, | |
gallery: gallery, | |
) | |
notification = Ember.Object.create( | |
id: 1, | |
comment: comment | |
) | |
@set('notification', notification) | |
@render hbs """{{notifications/new-comment/gallery-notification notification=notification}}""" | |
assert.equal @$().text().trim(), "Matylda commented on her own gallery: Looks awesome!" |
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
# template | |
commenter.displayName | |
| commented on | |
if hasCommentedOwnCreation | |
if isCommenterMale | |
_ "his" | |
else | |
_ "her" | |
_ "own" space='s | |
galleryOwner.displayName | |
_"'s gallery" space='e' | |
comment.text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment