Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamkrishnar committed Aug 9, 2020
1 parent 35aa44e commit 6d7d0d9
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
23 changes: 20 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Blog post workflow tests', function () {
fs.writeFileSync(path.join(__dirname, 'test', README_FILE), TEMPLATE);
const envObj = {
...process.env,
INPUT_MAX_POST_COUNT: "5",
INPUT_MAX_POST_COUNT: "10",
INPUT_FEED_LIST: "http://localhost:8080",
INPUT_README_PATH: path.join(__dirname, 'test', README_FILE),
INPUT_DISABLE_SORT: "false",
Expand All @@ -42,7 +42,7 @@ describe('Blog post workflow tests', function () {
fs.writeFileSync(path.join(__dirname, 'test', README_FILE), TEMPLATE);
const envObj = {
...process.env,
INPUT_MAX_POST_COUNT: "5",
INPUT_MAX_POST_COUNT: "10",
INPUT_FEED_LIST: "http://localhost:8080",
INPUT_README_PATH: path.join(__dirname, 'test', README_FILE),
INPUT_DISABLE_SORT: "true",
Expand All @@ -61,7 +61,7 @@ describe('Blog post workflow tests', function () {
fs.writeFileSync(path.join(__dirname, 'test', README_FILE), TEMPLATE);
const envObj = {
...process.env,
INPUT_MAX_POST_COUNT: "5",
INPUT_MAX_POST_COUNT: "10",
INPUT_FEED_LIST: "http://localhost:8080",
INPUT_README_PATH: path.join(__dirname, 'test', README_FILE),
INPUT_DISABLE_SORT: "false",
Expand All @@ -74,4 +74,21 @@ describe('Blog post workflow tests', function () {
const newReadme = fs.readFileSync(path.join(__dirname, 'test' , README_FILE), "utf-8");
assert.equal(snapshot, newReadme);
});
it('Generated readme without filters should match the snapshot',async function () {
const README_FILE = 'Readme.comments.md';
fs.writeFileSync(path.join(__dirname, 'test', README_FILE), TEMPLATE);
const envObj = {
...process.env,
INPUT_MAX_POST_COUNT: "10",
INPUT_FEED_LIST: "http://localhost:8080",
INPUT_README_PATH: path.join(__dirname, 'test', README_FILE),
INPUT_DISABLE_SORT: "false",
INPUT_TEMPLATE: "$newline[$title]($url) $newline",
TEST_MODE: "true",
};
await exec('node', [TEST_FILE],{env: envObj});
const snapshot = fs.readFileSync(path.join(__dirname, 'test' , README_FILE + '.snap'), "utf-8");
const newReadme = fs.readFileSync(path.join(__dirname, 'test' , README_FILE), "utf-8");
assert.equal(snapshot, newReadme);
});
});
24 changes: 24 additions & 0 deletions test/Readme.comments.md.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Readme test
Post list example:
<!-- BLOG-POST-LIST:START -->
[God Mode in browsers: document.designMode = "on"](https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo)

[
Should be ignored!
](https://medium.com/@user/should-be-ignored-ec0567da7d68?source=rss-84c42a22cef7------2)

[Skipping the Chrome "Your connection is not private" warning](https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1)

[Microsoft Student PartnersGeek is the new rockstar](https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar)

[An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy)

[Comment by Gautam Krishna R on test](https://stackoverflow.com/questions/49310909/omniauth-facebook-login-does-not-work/49311637?cid=85720166#49311637)

[Hi, I'm Gautam krishna.R](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar)

[DuckDuckGoThe search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d)
<!-- BLOG-POST-LIST:END -->

# Other contents
Test content
2 changes: 2 additions & 0 deletions test/Readme.custom.md.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Post list example:
[An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy)

[Hi, I'm Gautam krishna.R](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar)

[DuckDuckGoThe search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d)
<!-- BLOG-POST-LIST:END -->

# Other contents
Expand Down
1 change: 1 addition & 0 deletions test/Readme.md.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Post list example:
- [Microsoft Student PartnersGeek is the new rockstar](https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar)
- [An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy)
- [Hi, I'm Gautam krishna.R](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar)
- [DuckDuckGoThe search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d)
<!-- BLOG-POST-LIST:END -->

# Other contents
Expand Down
1 change: 1 addition & 0 deletions test/Readme.sort.md.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Post list example:
- [Microsoft Student PartnersGeek is the new rockstar](https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar)
- [DuckDuckGoThe search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d)
- [Skipping the Chrome "Your connection is not private" warning](https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1)
- [An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy)
<!-- BLOG-POST-LIST:END -->

# Other contents
Expand Down

0 comments on commit 6d7d0d9

Please sign in to comment.