Skip to content

Commit

Permalink
Clean up wrapLinks for blaze, clean up test syntax now that include w…
Browse files Browse the repository at this point in the history
…orks, and add a new wrapLinks test.
  • Loading branch information
queso committed Mar 28, 2014
1 parent cd4beea commit 7a3296c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
10 changes: 5 additions & 5 deletions client/views/accountButtons/accountButtons.coffee
Expand Up @@ -3,11 +3,11 @@ Template.entryAccountButtons.helpers
return false unless AccountsEntry.settings.profileRoute
AccountsEntry.settings.profileRoute

wrapLinksOpenLi: ->
Spacebars.SafeString("<li>") if AccountsEntry.settings.wrapLinks

wrapLinksCloseLi: ->
Spacebars.SafeString("</li>") if AccountsEntry.settings.wrapLinks
wrapLinksLi: ->
if AccountsEntry.settings.wrapLinks
Template.wrapLinks
else
Template.noWrapLinks

beforeSignIn: ->
AccountsEntry.settings.beforeSignIn
Expand Down
20 changes: 10 additions & 10 deletions client/views/accountButtons/accountButtons.html
Expand Up @@ -2,30 +2,30 @@
{{#if currentUser}}

{{#if profileUrl}}
{{wrapLinksOpenLi}}
{{#wrapLinksLi}}
<a class='profileLink' href='{{profileUrl}}'>{{{beforeSignedInAs}}}{{signedInAs}}</a>
{{wrapLinksCloseLi}}
{{/wrapLinksLi}}
{{else}}
{{wrapLinksOpenLi}}
{{#wrapLinksLi}}
<p class="navbar-text">{{{beforeSignedInAs}}}{{signedInAs}}</p>
{{wrapLinksCloseLi}}
{{/wrapLinksLi}}
{{/if}}

{{wrapLinksOpenLi}}
{{#wrapLinksLi}}
<a href="/sign-out">{{{beforeSignOut}}}{{i18n "signOut"}}</a>
{{wrapLinksCloseLi}}
{{/wrapLinksLi}}
{{else}}

{{wrapLinksOpenLi}}
{{#wrapLinksLi}}
<a href="/sign-in">{{{beforeSignIn}}}{{i18n "signIn"}}</a>
{{wrapLinksCloseLi}}
{{/wrapLinksLi}}

{{#unless wrapLinks}}
<span>or</span>
{{/unless}}

{{wrapLinksOpenLi}}
{{#wrapLinksLi}}
<a href="{{entrySignUp}}">{{{beforeSignUp}}}{{i18n "signUp"}}</a>
{{wrapLinksCloseLi}}
{{/wrapLinksLi}}
{{/if}}
</template>
1 change: 1 addition & 0 deletions package.js
Expand Up @@ -36,6 +36,7 @@ Package.on_use(function(api) {
'client/views/error/error.coffee',
'client/views/accountButtons/accountButtons.html',
'client/views/accountButtons/accountButtons.coffee',
'client/views/accountButtons/_wrapLinks.html',
'client/i18n/english.coffee',
'client/i18n/german.coffee',
'client/i18n/spanish.coffee'
Expand Down
12 changes: 9 additions & 3 deletions tests/client.coffee
Expand Up @@ -6,6 +6,12 @@ renderToDiv = (comp) ->
Tinytest.add "Accounts Entry - {{accountButtons}} helper", (test) ->
div = renderToDiv(Template.test_helper_account_buttons)
html = canonicalizeHtml(div.innerHTML)
debugger
test.notEqual html.indexOf("Sign In"), -1, "Account Buttons helper didn't render a sign in link."
test.notEqual html.indexOf("Sign Up"), -1, "Account Buttons helper didn't render a sign up link."
test.include html, "Sign In"
test.include html, "Sign Up"

Tinytest.add "Accounts Entry - wrapLinks setting on should wrap links in li elements", (test) ->
AccountsEntry.settings.wrapLinks = true
div = renderToDiv(Template.test_helper_account_buttons)
html = canonicalizeHtml(div.innerHTML)
test.include html, '<li><a href="/sign-in">Sign In</a></li>'

0 comments on commit 7a3296c

Please sign in to comment.