Skip to content

Commit

Permalink
Test case is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
darsan-in committed Nov 22, 2024
1 parent 69ad1cc commit 5ea41d2
Show file tree
Hide file tree
Showing 17 changed files with 478 additions and 31 deletions.
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
"bundle": "node ./dev/bundler.js",
"dev": "rimraf dist && tsc -p tscdev.json && yarn bundle -dev && yarn ncp ./bin/userconfig-template.js ./dist/bin/userconfig-template.js",
"build": "cls && rimraf dist && tsc -p tsconfig.json && yarn bundle -prod && yarn ncp ./bin/userconfig-template.js ./dist/bin/userconfig-template.js",
"test": "jest",
"clean": "cls && rimraf dist",
"deploy": "yarn build && yarn publish --access public && git push"
"deploy": "yarn build && yarn publish --access public && git push",
"test": "jest",
"start-server": "npx http-server test/test-sample -p 8080",
"ci": "start-server-and-test start-server http://localhost:8080 test"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -71,7 +73,6 @@
"prettier": "^3.3.3"
},
"devDependencies": {
"ncp": "^2.0.0",
"@babel/core": "7.26.0",
"@babel/preset-env": "7.26.0",
"@babel/preset-typescript": "7.26.0",
Expand All @@ -85,9 +86,12 @@
"babel-jest": "29.7.0",
"esbuild": "^0.24.0",
"eslint": "^9.15.0",
"http-server": "^14.1.1",
"jest": "29.7.0",
"ncp": "^2.0.0",
"puppeteer": "^23.8.0",
"rimraf": "6.0.1",
"start-server-and-test": "^2.0.8",
"ts-node": "10.9.2",
"typescript": "^5.6.3"
}
Expand Down
9 changes: 5 additions & 4 deletions test/browser.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
import { dirname, join, relative, resolve } from "node:path";
import { dirname, join, relative } from "node:path";
import puppeteer, { type Browser } from "puppeteer";
import { richies } from "../lib/types";

Expand All @@ -13,10 +13,11 @@ async function _RenderResult(
try {
const page = await browser.newPage();

// Load the HTML file or page
await page.goto(resolve(htmlPath), { waitUntil: "networkidle0" });
// Use the http-server to access the file
const url = `http://localhost:8080/${relative("test/test-sample", htmlPath)}`;
await page.goto(url, { waitUntil: "networkidle0" });

// Wait until the expected number of "application/ld+json" script tags are present
// Wait for the expected number of "application/ld+json" script tags
await page.waitForFunction(
(numberOfRichResults: number) =>
document.querySelectorAll('script[type="application/ld+json"]')
Expand Down
2 changes: 1 addition & 1 deletion test/outputs/browser-env/Sitesearch/searchpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
});
</script>

<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebSite","url":"https://www.cresteem.com/","potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://www.cresteem.com//A:/Git/cresteem/Richie-JS/test/test-sample/Sitesearch/searchpage?q={searchTerm}"},"query-input":"required name=searchTerm"}}</script></head>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebSite","url":"https://www.cresteem.com/","potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://www.cresteem.com//Sitesearch/searchpage?q={searchTerm}"},"query-input":"required name=searchTerm"}}</script></head>

<body>
<h1>Search Form</h1>
Expand Down
2 changes: 1 addition & 1 deletion test/outputs/browser-env/carousels/courses.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
RichieJS.default({ richieNames: ['ccourse', 'course'] })
});
</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"ItemList","itemListElement":[{"@type":"ListItem","position":"1","item":{"@type":"Course","url":"https://www.cresteem.com//A:/Git/cresteem/Richie-JS/test/test-sample/carousels/courses#rjs-course-1","name":"Python Crash Course","description":"This course serves as an introduction to Python programming, covering essential concepts and skills necessary for beginners to start coding in Python. Participants will learn about basic syntax, data types, control flow structures, functions, and file handling. Additionally, the course will cover key Python libraries and modules for common tasks such as data manipulation, visualization, and working with external files. Throughout the course, hands-on exercises and projects will reinforce learning objectives, allowing participants to apply their newfound knowledge to real-world scenarios.","provider":{"@type":"Organization","name":"LMS","sameAs":"https://lms.com/"},"offers":{"@type":"Offer","category":"Fees","price":100,"priceCurrency":"USD"},"hasCourseInstance":{"@type":"CourseInstance","courseMode":"online","instructor":{"@type":"Person","name":"Saravanan"},"inLanguage":["English"],"courseSchedule":{"@type":"Schedule","duration":"PT68H","repeatFrequency":"monthly","repeatCount":8}}}},{"@type":"ListItem","position":"2","item":{"@type":"Course","url":"https://www.cresteem.com//A:/Git/cresteem/Richie-JS/test/test-sample/carousels/courses#rjs-course-2","name":"Node.Js introduction","description":"This course provides a comprehensive introduction to Node.js, a popular runtime environment for executing JavaScript code server-side. Participants will learn how to build scalable, high-performance web applications using Node.js, leveraging its asynchronous, event-driven architecture. The course covers essential concepts such as event loops, modules, package management, and asynchronous programming patterns. Additionally, participants will explore key Node.js frameworks and libraries for web development, including Express.js for building web servers and handling HTTP requests. Hands-on exercises and projects will reinforce learning objectives, allowing participants to apply their knowledge to real-world scenarios.","provider":{"@type":"Organization","name":"Edutube","sameAs":"https://edutube.com/"},"offers":{"@type":"Offer","category":"Fees","price":2000,"priceCurrency":"USD"},"hasCourseInstance":{"@type":"CourseInstance","courseMode":"onsite","instructor":{"@type":"Person","name":"Ram"},"inLanguage":["Tamil","French"],"courseSchedule":{"@type":"Schedule","duration":"PT24H","repeatFrequency":"daily","repeatCount":4}}}},{"@type":"ListItem","position":"3","item":{"@type":"Course","url":"https://www.cresteem.com//A:/Git/cresteem/Richie-JS/test/test-sample/carousels/courses#rjs-course-3","name":"Java Intermediate to Advanced","description":"This course offers a comprehensive introduction to Java programming, covering core concepts and principles essential for beginners to embark on their journey in Java development. Participants will learn about Java syntax, object-oriented programming (OOP), control flow structures, exception handling, and input/output operations. Additionally, the course will cover key Java libraries and frameworks, providing a solid foundation for developing robust, scalable applications. Hands-on exercises and projects will reinforce learning objectives, enabling participants to apply their knowledge to practical scenarios.","provider":{"@type":"Organization","name":"Notoracle","sameAs":"https://notoracle.com/"},"offers":{"@type":"Offer","category":"Fees","price":2000,"priceCurrency":"INR"},"hasCourseInstance":{"@type":"CourseInstance","courseMode":"blended","instructor":{"@type":"Person","name":"Peter"},"inLanguage":["Tamil","English","Hindi"],"courseSchedule":{"@type":"Schedule","duration":"PT720H","repeatFrequency":"daily","repeatCount":7}}}}]}</script><script type="application/ld+json">[{"@context":"https://schema.org","@type":"Course","url":"https://www.cresteem.com//A:/Git/cresteem/Richie-JS/test/test-sample/carousels/courses#rjs-course-1","name":"Python Crash Course","description":"This course serves as an introduction to Python programming, covering essential concepts and skills necessary for beginners to start coding in Python. Participants will learn about basic syntax, data types, control flow structures, functions, and file handling. Additionally, the course will cover key Python libraries and modules for common tasks such as data manipulation, visualization, and working with external files. Throughout the course, hands-on exercises and projects will reinforce learning objectives, allowing participants to apply their newfound knowledge to real-world scenarios.","provider":{"@type":"Organization","name":"LMS","sameAs":"https://lms.com/"},"offers":{"@type":"Offer","category":"Fees","price":100,"priceCurrency":"USD"},"hasCourseInstance":{"@type":"CourseInstance","courseMode":"online","instructor":{"@type":"Person","name":"Saravanan"},"inLanguage":["English"],"courseSchedule":{"@type":"Schedule","duration":"PT68H","repeatFrequency":"monthly","repeatCount":8}}},{"@context":"https://schema.org","@type":"Course","url":"https://www.cresteem.com//A:/Git/cresteem/Richie-JS/test/test-sample/carousels/courses#rjs-course-2","name":"Node.Js introduction","description":"This course provides a comprehensive introduction to Node.js, a popular runtime environment for executing JavaScript code server-side. Participants will learn how to build scalable, high-performance web applications using Node.js, leveraging its asynchronous, event-driven architecture. The course covers essential concepts such as event loops, modules, package management, and asynchronous programming patterns. Additionally, participants will explore key Node.js frameworks and libraries for web development, including Express.js for building web servers and handling HTTP requests. Hands-on exercises and projects will reinforce learning objectives, allowing participants to apply their knowledge to real-world scenarios.","provider":{"@type":"Organization","name":"Edutube","sameAs":"https://edutube.com/"},"offers":{"@type":"Offer","category":"Fees","price":2000,"priceCurrency":"USD"},"hasCourseInstance":{"@type":"CourseInstance","courseMode":"onsite","instructor":{"@type":"Person","name":"Ram"},"inLanguage":["Tamil","French"],"courseSchedule":{"@type":"Schedule","duration":"PT24H","repeatFrequency":"daily","repeatCount":4}}},{"@context":"https://schema.org","@type":"Course","url":"https://www.cresteem.com//A:/Git/cresteem/Richie-JS/test/test-sample/carousels/courses#rjs-course-3","name":"Java Intermediate to Advanced","description":"This course offers a comprehensive introduction to Java programming, covering core concepts and principles essential for beginners to embark on their journey in Java development. Participants will learn about Java syntax, object-oriented programming (OOP), control flow structures, exception handling, and input/output operations. Additionally, the course will cover key Java libraries and frameworks, providing a solid foundation for developing robust, scalable applications. Hands-on exercises and projects will reinforce learning objectives, enabling participants to apply their knowledge to practical scenarios.","provider":{"@type":"Organization","name":"Notoracle","sameAs":"https://notoracle.com/"},"offers":{"@type":"Offer","category":"Fees","price":2000,"priceCurrency":"INR"},"hasCourseInstance":{"@type":"CourseInstance","courseMode":"blended","instructor":{"@type":"Person","name":"Peter"},"inLanguage":["Tamil","English","Hindi"],"courseSchedule":{"@type":"Schedule","duration":"PT720H","repeatFrequency":"daily","repeatCount":7}}}]</script></head>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"ItemList","itemListElement":[{"@type":"ListItem","position":"1","item":{"@type":"Course","url":"https://www.cresteem.com//carousels/courses#rjs-course-1","name":"Python Crash Course","description":"This course serves as an introduction to Python programming, covering essential concepts and skills necessary for beginners to start coding in Python. Participants will learn about basic syntax, data types, control flow structures, functions, and file handling. Additionally, the course will cover key Python libraries and modules for common tasks such as data manipulation, visualization, and working with external files. Throughout the course, hands-on exercises and projects will reinforce learning objectives, allowing participants to apply their newfound knowledge to real-world scenarios.","provider":{"@type":"Organization","name":"LMS","sameAs":"https://lms.com/"},"offers":{"@type":"Offer","category":"Fees","price":100,"priceCurrency":"USD"},"hasCourseInstance":{"@type":"CourseInstance","courseMode":"online","instructor":{"@type":"Person","name":"Saravanan"},"inLanguage":["English"],"courseSchedule":{"@type":"Schedule","duration":"PT68H","repeatFrequency":"monthly","repeatCount":8}}}},{"@type":"ListItem","position":"2","item":{"@type":"Course","url":"https://www.cresteem.com//carousels/courses#rjs-course-2","name":"Node.Js introduction","description":"This course provides a comprehensive introduction to Node.js, a popular runtime environment for executing JavaScript code server-side. Participants will learn how to build scalable, high-performance web applications using Node.js, leveraging its asynchronous, event-driven architecture. The course covers essential concepts such as event loops, modules, package management, and asynchronous programming patterns. Additionally, participants will explore key Node.js frameworks and libraries for web development, including Express.js for building web servers and handling HTTP requests. Hands-on exercises and projects will reinforce learning objectives, allowing participants to apply their knowledge to real-world scenarios.","provider":{"@type":"Organization","name":"Edutube","sameAs":"https://edutube.com/"},"offers":{"@type":"Offer","category":"Fees","price":2000,"priceCurrency":"USD"},"hasCourseInstance":{"@type":"CourseInstance","courseMode":"onsite","instructor":{"@type":"Person","name":"Ram"},"inLanguage":["Tamil","French"],"courseSchedule":{"@type":"Schedule","duration":"PT24H","repeatFrequency":"daily","repeatCount":4}}}},{"@type":"ListItem","position":"3","item":{"@type":"Course","url":"https://www.cresteem.com//carousels/courses#rjs-course-3","name":"Java Intermediate to Advanced","description":"This course offers a comprehensive introduction to Java programming, covering core concepts and principles essential for beginners to embark on their journey in Java development. Participants will learn about Java syntax, object-oriented programming (OOP), control flow structures, exception handling, and input/output operations. Additionally, the course will cover key Java libraries and frameworks, providing a solid foundation for developing robust, scalable applications. Hands-on exercises and projects will reinforce learning objectives, enabling participants to apply their knowledge to practical scenarios.","provider":{"@type":"Organization","name":"Notoracle","sameAs":"https://notoracle.com/"},"offers":{"@type":"Offer","category":"Fees","price":2000,"priceCurrency":"INR"},"hasCourseInstance":{"@type":"CourseInstance","courseMode":"blended","instructor":{"@type":"Person","name":"Peter"},"inLanguage":["Tamil","English","Hindi"],"courseSchedule":{"@type":"Schedule","duration":"PT720H","repeatFrequency":"daily","repeatCount":7}}}}]}</script><script type="application/ld+json">[{"@context":"https://schema.org","@type":"Course","url":"https://www.cresteem.com//carousels/courses#rjs-course-1","name":"Python Crash Course","description":"This course serves as an introduction to Python programming, covering essential concepts and skills necessary for beginners to start coding in Python. Participants will learn about basic syntax, data types, control flow structures, functions, and file handling. Additionally, the course will cover key Python libraries and modules for common tasks such as data manipulation, visualization, and working with external files. Throughout the course, hands-on exercises and projects will reinforce learning objectives, allowing participants to apply their newfound knowledge to real-world scenarios.","provider":{"@type":"Organization","name":"LMS","sameAs":"https://lms.com/"},"offers":{"@type":"Offer","category":"Fees","price":100,"priceCurrency":"USD"},"hasCourseInstance":{"@type":"CourseInstance","courseMode":"online","instructor":{"@type":"Person","name":"Saravanan"},"inLanguage":["English"],"courseSchedule":{"@type":"Schedule","duration":"PT68H","repeatFrequency":"monthly","repeatCount":8}}},{"@context":"https://schema.org","@type":"Course","url":"https://www.cresteem.com//carousels/courses#rjs-course-2","name":"Node.Js introduction","description":"This course provides a comprehensive introduction to Node.js, a popular runtime environment for executing JavaScript code server-side. Participants will learn how to build scalable, high-performance web applications using Node.js, leveraging its asynchronous, event-driven architecture. The course covers essential concepts such as event loops, modules, package management, and asynchronous programming patterns. Additionally, participants will explore key Node.js frameworks and libraries for web development, including Express.js for building web servers and handling HTTP requests. Hands-on exercises and projects will reinforce learning objectives, allowing participants to apply their knowledge to real-world scenarios.","provider":{"@type":"Organization","name":"Edutube","sameAs":"https://edutube.com/"},"offers":{"@type":"Offer","category":"Fees","price":2000,"priceCurrency":"USD"},"hasCourseInstance":{"@type":"CourseInstance","courseMode":"onsite","instructor":{"@type":"Person","name":"Ram"},"inLanguage":["Tamil","French"],"courseSchedule":{"@type":"Schedule","duration":"PT24H","repeatFrequency":"daily","repeatCount":4}}},{"@context":"https://schema.org","@type":"Course","url":"https://www.cresteem.com//carousels/courses#rjs-course-3","name":"Java Intermediate to Advanced","description":"This course offers a comprehensive introduction to Java programming, covering core concepts and principles essential for beginners to embark on their journey in Java development. Participants will learn about Java syntax, object-oriented programming (OOP), control flow structures, exception handling, and input/output operations. Additionally, the course will cover key Java libraries and frameworks, providing a solid foundation for developing robust, scalable applications. Hands-on exercises and projects will reinforce learning objectives, enabling participants to apply their knowledge to practical scenarios.","provider":{"@type":"Organization","name":"Notoracle","sameAs":"https://notoracle.com/"},"offers":{"@type":"Offer","category":"Fees","price":2000,"priceCurrency":"INR"},"hasCourseInstance":{"@type":"CourseInstance","courseMode":"blended","instructor":{"@type":"Person","name":"Peter"},"inLanguage":["Tamil","English","Hindi"],"courseSchedule":{"@type":"Schedule","duration":"PT720H","repeatFrequency":"daily","repeatCount":7}}}]</script></head>

<body>
<main>
Expand Down
Loading

0 comments on commit 5ea41d2

Please sign in to comment.