-
Notifications
You must be signed in to change notification settings - Fork 0
Initial JS Tests (paginationScript.js) #69
base: master
Are you sure you want to change the base?
Conversation
…into ethan-dev-tests
…nto ethan-dev-tests
…nto ethan-dev-tests
| let testResultsContent = []; | ||
| let testResultsCardsList = []; | ||
|
|
||
| for (let i = 0; i < 6; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just filling the testResultsCardList with 6 cards, enough to test what I need it to.
| test('If the moveNext function works as expected', () => { | ||
|
|
||
| // Move next (what is being tested) | ||
| testDisplayCards(TOTAL_CARDS_TO_DISPLAY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's highlight what the list augment should be here, as opposed to using TOTAL_CARDS_TO_DISPLAY.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha
| test(' If the navigatePrevious works as expected', () => { | ||
|
|
||
| // Move Backwards (what is being tested) | ||
| testDisplayCards((-TOTAL_CARDS_TO_DISPLAY)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
| testResultsCardsList.push(testCardObject); | ||
| } | ||
|
|
||
| function testDisplayCards(listAugment){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than rewriting this logic here, can you reference the displayCards method in pagination.js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would, but the changing from DOM elements to an array of objects wouldn't lend itself to this, so I had to copy and update it for arrays (simple things like appending to an array, etc, no big changes)
…nto ethan-dev-tests
…nto ethan-dev-tests
…nto ethan-dev-tests
…nto ethan-dev-tests
…nto ethan-dev-tests
…update tests to match
|
These new tests should work but they will not run on my computer as Jest seems to have cached the old tests, and is trying to run those instead. Need to sync with shaquilleh@ tomorrow to figure this out. |
| test('It calculateAugment performs as expected given certain inputs', () => { | ||
| //Beginning of list | ||
| currentFirstCardIndex = 0; | ||
| expect(calculateListAugment(-TOTAL_CARDS_TO_DISPLAY)).toEqual(0); | ||
|
|
||
| //End of list | ||
| currentFirstCardIndex = MAX_LIST_VIEW_NUMER - TOTAL_CARDS_TO_DISPLAY; | ||
| expect(calculateListAugment(TOTAL_CARDS_TO_DISPLAY)).toEqual(0); | ||
|
|
||
| //Some random acceptable location in list, next | ||
| currentFirstCardIndex = 3; | ||
| expect(calculateListAugment(TOTAL_CARDS_TO_DISPLAY)).toEqual(3); | ||
|
|
||
| //Some random acceptable location in list, previous | ||
| currentFirstCardIndex = 3; | ||
| expect(calculateListAugment(-TOTAL_CARDS_TO_DISPLAY)).toEqual(0); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each of these expects should be a different test. i.e. testMoveNext(), testMovePrevious, testUserAtEndofList etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| const TOTAL_CARDS_TO_DISPLAY = 3; | ||
| const MAX_LIST_VIEW_NUMER = 15; | ||
|
|
||
| test('It calculateListAugment performs as expected when at beginning of list', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this say "If calculateListAugment ..."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, yes it should ... it really is a Friday isn't it
| const MAX_LIST_VIEW_NUMER = 15; | ||
|
|
||
| test('It calculateListAugment performs as expected when at beginning of list', () => { | ||
| currentFirstCardIndex = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this variable? I don't see it being used anywhere. Perhaps you intended for calculateListAugment to receive it as a parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's being used in the second test, line 26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...Mispelled oops
|
As mentioned in the issue for this, the tests are effectively done. I wasn't able to actually run them due to issues with something caching old tests and not running the new ones, which is why this PR hasn't been approved. |
TL;DR: Added the first of the JS frontend tests, focusing on paginationScript.js
Note: I may have done these terribly if I'm totally honest - please let me know what I can improve and change :)
,gitignore - Added ignore for node_modules/ , as I had to install Node.js to utilize Jest
package.json package-lock.json - two files needed for Node and Jest
paginationScript.test.js - the actual testing file. Spoke with shaquilleh@ and decided to test the working of the algorithm, rather than the DOM elements themselves. This file contains tests of the main functions, using arrays and objects instead of DOM elements.
Another Note: I also realize these may be lacking, but I wanted to make sure that I get review on the initial ones to make sure I am on the right track.