Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#66 test: 100% coverage #78

Merged
merged 2 commits into from Mar 26, 2016
Merged

Conversation

acdpnk
Copy link
Contributor

@acdpnk acdpnk commented Feb 25, 2016

WIP

bearerToken: 'abc45678',
path: false
}, 'calls fetchProperties with account url and non-string path')
// expected behavior??
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path in this context is not part of the URL, but the path to the properties you want to return. If it’s undefined, all properties are returned. If path is set to address, then only the address value is returned. false makes not much sense here, why did you decide to test with it?

See examples in the README for account.profile.fetch

Note that this example is wrong – I’ll make a separate issue to get it fixed

account.fetch('fullname').then(function (createdAt) {
  alert('Hey there ' + fullname)
})

should be

account.fetch('fullname').then(function (fullname) {
  alert('Hey there ' + fullname)
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false makes not much sense here, why did you decide to test with it?

To achieve full branch coverage I need to have a test covering the else clause in the following code.

if (typeof path === 'string') {
  set(state.account, path, properties)
} else {
  merge(state.account, properties)
}

coverage report excerpt

Which, if I'm not mistaken, comes down to testing with a path where typeof path !== 'string'. I picked false because it doesn't make much sense, as I assumed that this was not a legitimate use case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I think you can leave out path entirely, so that it will be undefined, that will cover the else path

@gr2m
Copy link
Member

gr2m commented Mar 4, 2016

Hey @chrifpa, what’s your status here?

@acdpnk
Copy link
Contributor Author

acdpnk commented Mar 5, 2016

Got sick and had to stop working on it for a bit. Back now.

@gr2m
Copy link
Member

gr2m commented Mar 5, 2016

Glad to hear you are good again, thanks for the update! Ping us if you have any questions :)

@toh82 toh82 mentioned this pull request Mar 8, 2016
6 tasks
@gr2m
Copy link
Member

gr2m commented Mar 18, 2016

Hey @chrifpa all good from your side? Any blockers right now?

@acdpnk
Copy link
Contributor Author

acdpnk commented Mar 20, 2016

Just a little constrained on time, sorry… 😄

t.deepEqual(data, accountsReturn, 'returns right data')

t.end()
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @gr2m, do you mind having a look at this? I wrote these tests to achieve full branch coverage, but I have a hard time figuring out if the fixtures I'm using make sense and/or if this last test — with what to me looks like a malformed response — shouldn't fail.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure looking into it now, thanks @chrifpa

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the complex relationship, instead of having account -> profile -> vet, can you do session -> account -> profile? You can take this as a server response fixture: https://github.com/hoodiehq/hoodie-server-account/blob/master/tests/integration/fixtures/session-with-profile-response.json

The rest looks great, thanks for the enormous efforts Chris! 💐

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will do!

@gr2m
Copy link
Member

gr2m commented Mar 22, 2016

sorry for the noisy comments by coveralls, I’ve disabled that now

@gr2m
Copy link
Member

gr2m commented Mar 22, 2016

Looking great now, also getting close :)

=============================== Coverage summary ===============================
Statements   : 99.39% ( 492/495 )
Branches     : 99.28% ( 138/139 )
Functions    : 96.59% ( 85/88 )
Lines        : 99.39% ( 492/495 )
================================================================================

Let us know if you run into any blockers or have any questions, we know that some of these might be tricky to get 100% :)

}
}
]
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @gr2m, could you take a look at this and tell me wether this fixture makes sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admins have no account relationship, you can remove the "relationships" key and the "included" key

@acdpnk
Copy link
Contributor Author

acdpnk commented Mar 24, 2016

Looks like coveralls got stuck. Anything I can do to unstick it?

@finnp
Copy link
Member

finnp commented Mar 24, 2016

@chrifpa I re-run the travis job and now it's working. 100% ftw \o/

@gr2m
Copy link
Member

gr2m commented Mar 24, 2016

w00p now that looks great 👏

=============================== Coverage summary ===============================
Statements   : 100% ( 495/495 )
Branches     : 100% ( 137/137 )
Functions    : 100% ( 87/87 )
Lines        : 100% ( 495/495 )
================================================================================


var storeAccount = store.getObject('account_admin')

t.is(storeAccount, null, 'removes acocunt from store')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: acocunt should be account

@gr2m
Copy link
Member

gr2m commented Mar 24, 2016

okay if you could fix the fixture and the typo, and clean up the commits, this is good to be merged :)

@acdpnk acdpnk force-pushed the test-coverage branch 3 times, most recently from 1be6d29 to 86a9ce9 Compare March 25, 2016 11:21
@acdpnk
Copy link
Contributor Author

acdpnk commented Mar 25, 2016

I think I got the commits right now 😅

Therefore ready for review @gr2m

@acdpnk acdpnk changed the title #66 coverage #66 test: 100% coverage Mar 25, 2016
@gr2m
Copy link
Member

gr2m commented Mar 25, 2016

Yes, absolutely, perfect, wow such work, very awesome 🐶 👏

LGTM!

ping @hoodiehq/maintainers for 2nd 👀 review

@gr2m
Copy link
Member

gr2m commented Mar 25, 2016

@chrifpa can you rebase your work on latest master? No biggie if not, the 2nd reviewer can do the rebase before merging, and then manually close this PR and the issue

@acdpnk
Copy link
Contributor Author

acdpnk commented Mar 26, 2016

Thanks @gr2m :)

  • Rebase on latest master

@christophwitzko
Copy link
Member

LGTM 👍

@christophwitzko christophwitzko merged commit 40a5186 into hoodiehq:master Mar 26, 2016
@acdpnk acdpnk deleted the test-coverage branch March 26, 2016 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants