Stephanevg / PSHTML

Cross platform Powershell module to generate HTML markup language
https://pshtml.readthedocs.io/en/latest/
Other
167 stars 43 forks source link

Add pester tests for Asset / Includes 'locations' #243

Closed Stephanevg closed 5 years ago

Stephanevg commented 5 years ago

In title

datenschieber commented 5 years ago

@Stephanevg Thanks for this useful enhancement! I'd like to do some testing. You marked it as "beginner friendly". I am not familiar with Github and your testing requirements. Do you have any hints how to start? What outcome do you expect?

Sorry for these stupid beginner questions... ;-)

Stephanevg commented 5 years ago

Awesome @datenschieber !

Don't worry everybody was a beginner at some point, right? ;)

Are you familiar with the pester framework? (if not here is an introduction blog post I wrote a while back --> http://powershelldistrict.com/pester-in-3-blog-posts-install-pester/ )

Basically, I do have tests already for the includes and assets in general. Now that I added 'Locations' I want to be sure that the functionality works as expected, and that I don't break it in the future with a new version.

There are a few things I need to be sure to test:

Script

The main script called MyScript.ps1

html {
  P {"main"}
  Include footer
}

Includes

Footer.ps1


p "This is footer from project"

1)considering the files above, if footer.ps1 is set in an Includes folder in the $PsScriptRoot location (in other words, in the same folder as you script 'MyScript.ps1') We want to be sure that the output of the myScript.ps1 contains the content 'this is footer from project'

2) Delete the includes folder from pspscriptroot, and create it in the folder of the module.

Create a file Footer.ps1 in the $PsModuleRoot\Includes\Footer.ps1 with all


p "This is footer from Module"

Call MyScript.ps1 than, it we should validate that the content of the footer this time, is the one from the module.

3) same exercice as before, but there should be the same include file in module and in project includes folder, except the content must be different in each of them. We must validate that the one in the project get output.

If you are not familiar with Pester, this issue could be a bit challenging for a pester beginner. Worse case, I can find you something else you could work on. Let me know!

Stephanevg commented 5 years ago

Adde this commit. https://github.com/Stephanevg/PSHTML/commit/16b645ae5f5b404752ba8ac489f30ca03d09e5a0 Will be merged in master with https://github.com/Stephanevg/PSHTML/milestone/1