Skip to content

add: some unit tests#315

Merged
peterramsing merged 6 commits intopeterramsing:masterfrom
wbruno:improve-unit-tests
Aug 10, 2016
Merged

add: some unit tests#315
peterramsing merged 6 commits intopeterramsing:masterfrom
wbruno:improve-unit-tests

Conversation

@wbruno
Copy link
Copy Markdown
Contributor

@wbruno wbruno commented Jul 6, 2016

Adding some unit tests for better code coverage.

I also changed the test/check.js, to show properly the expected and the result.

@peterramsing
Copy link
Copy Markdown
Owner

Woah. This is fun!

...I should probably use more "help wanted" tags instead of assuming nobody wants to help. 👍

I find there is a ton of work that goes into just managing a project like this by the time I have time to get to things like this I just want to go to bed.


I need to get working at the "paid gig" but will check in on this at lunch. My wife and I have guests coming over tonight but will get some LostGrid time in after that late this evening (PST).

If this solves the issues I was having with getting the lost-utility: clearfix; to pass without refactoring too much I don't see why we can't get a patch out in the next few days at the latest.

Comment thread test/check.js
module.exports = function check( input, output, opts ) {
var processor = postcss([lost(opts)]);

expect(processor.process(input).css).to.equal(output);
Copy link
Copy Markdown
Owner

@peterramsing peterramsing Jul 6, 2016

Choose a reason for hiding this comment

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

I'm doing some smoke testing of this and I'm not sure I'm understanding the reasoning for this.

It causes a slight readability issue in the test output.
For example:

+ expected - actual
 -a { *zoom: 1 }
 +a { *zoom: 2 }
 a:before { content: ''; display: table }
 a:after { content: ''; display: table; clear: both }

I set the code to output *zoom: 2 so that should be the "actual" but instead it's reading as the "expected".

Typically when I'm working with tests I have the test represent the "expected".

Copy link
Copy Markdown
Owner

@peterramsing peterramsing Jul 6, 2016

Choose a reason for hiding this comment

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

...okay, now I might be confusing myself. This change is correct. 🤔

http://chaijs.com/guide/styles/#expect

...for some reason reading through the failing tests has me pondering what "expected" and "actual" mean.

Copy link
Copy Markdown
Contributor Author

@wbruno wbruno Jul 6, 2016

Choose a reason for hiding this comment

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

the expected is what the result should be (the right result)
the actual is what your script is responding

expect(actual_result).toBe(expected_result);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

So looking at it again I still think there is something going on here that's not correct. I don't think it's the syntax that you changed...but I'm not sure what it is.

Here's a screencast that explains my thoughts.
http://quick.as/2LkHp0rQ

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@wbruno Any thoughts to this syntax is correct but the output is incorrect? ...am I mistaken in my understanding of what the output is suppose to be?

@peterramsing
Copy link
Copy Markdown
Owner

On another note: I've been doing a lot of soul searching about these tests. They're awesome but I also don't really know how practical they are for testing whether or not things are broken. They simply check whether or not the output matches what we want it to. (which isn't bad at all)

Since most of the time the output is exactly the same as the input, the test written is sort of just a double check (which certainly isn't bad) instead of actually ensuring that LostGrid is performing properly.

I want to look into getting some tests that actually will use LostGrid on a DOM and ensure the output is as expected visually not simply that the CSS matches.

I'm looking into Sauce Labs to see if we might be able to get something going there that will check whether or not LostGrid is performing well visually.

@wbruno
Copy link
Copy Markdown
Contributor Author

wbruno commented Jul 6, 2016

Yes! I will be great to have such tests, but for now, I was just focus in improve the coverage.

@peterramsing
Copy link
Copy Markdown
Owner

@wbruno I don't disagree with improving coverage. 😄

@peterramsing
Copy link
Copy Markdown
Owner

@wbruno Is this still a WIP?

@wbruno
Copy link
Copy Markdown
Contributor Author

wbruno commented Jul 6, 2016

It's ready. I will do more tests on another PR, and think about others ways to test.

@peterramsing
Copy link
Copy Markdown
Owner

@wbruno Thanks, William!

Do you have any additional thoughts on #315 (comment)?

Before merging, I really want to understand what's happening with that.

Other than that I'm super excited about improved coverage! 😄 Thank you!

@wbruno
Copy link
Copy Markdown
Contributor Author

wbruno commented Jul 6, 2016

I saw the video and you are right, I'm sorry 😅

@peterramsing
Copy link
Copy Markdown
Owner

@wbruno I got really confused...the syntax there with what Chai is looking for isn't as straight-forward...

If this is just adding tests I don't see any reason to not merge.

Is this good to merge?

🍾

@wbruno
Copy link
Copy Markdown
Contributor Author

wbruno commented Jul 6, 2016

yep!! lets merge!

@peterramsing
Copy link
Copy Markdown
Owner

@wbruno Want to update this with master and then it can be merged. It'l then slot in with the next release. 👍🏻

@wbruno
Copy link
Copy Markdown
Contributor Author

wbruno commented Jul 7, 2016

done

@peterramsing peterramsing merged commit cbbe3ac into peterramsing:master Aug 10, 2016
@wbruno wbruno deleted the improve-unit-tests branch August 10, 2016 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants