Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed dom.js utility and test to match new Jest version #135

Merged
merged 6 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

"onCreateCommand": "npm i jest@24.8.0 -g && npm i @learnpack/[email protected].39 -g && learnpack plugins:install @learnpack/[email protected].5 && learnpack plugins:install @learnpack/[email protected].2"
"onCreateCommand": "npm i jest@29.7.0 [email protected] -g && npm i @learnpack/[email protected].47 -g && learnpack plugins:install @learnpack/[email protected].11 && learnpack plugins:install @learnpack/[email protected].7"

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",
Expand Down
4 changes: 2 additions & 2 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ FROM gitpod/workspace-full

USER gitpod

RUN npm i jest@24.8.0 -g
RUN npm i @learnpack/[email protected].26 -g && learnpack plugins:install @learnpack/[email protected].1 && learnpack plugins:install learnpack-html@0.0.20
RUN npm i jest@29.7.0 [email protected].0 -g
RUN npm i @learnpack/[email protected].47 -g && learnpack plugins:install @learnpack/[email protected].11 && learnpack plugins:install @learnpack/html@1.1.17
2 changes: 2 additions & 0 deletions .learn/exercises/11-postcard-divisions/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ test("Create a div with class postcard-header as child of .postcard", function()
})

test("Create a div with class postcard-body as child of .postcard", function(){
dom = fromFile();
const e=dom.querySelector('.postcard').inside().querySelector('.postcard-body')
expect(e).toBeTruthy();
})

test("Create a div with class postcard-footer as child of .postcard", function(){
dom = fromFile();
const e=dom.querySelector('.postcard').inside().querySelector('.postcard-footer')
expect(e).toBeTruthy();
})
3 changes: 3 additions & 0 deletions .learn/exercises/11.1-header-content/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ test("Create an image inside the .postcard-header <div>", function(){
})

test("Create an <h1> inside the .postcard-header <div>", function(){
dom = fromFile();
const e=dom.querySelector('.postcard-header').inside().querySelector('h1')
expect(e).toBeTruthy();
})

test("The <h1> inside .postcard-header should say 'My Postcard'", function(){
dom = fromFile();
const e =dom.querySelector('.postcard-header').inside().querySelector('h1')
expect(e.innerHTML.toLowerCase()).toEqual("My Postcard".toLowerCase());
})

test("The <img> tag should contain the given URL as src, E.g: <img src='the_image_src_goes_here' />", function(){
dom = fromFile();
const e =dom.querySelector('.postcard-header').inside().querySelector('img')
expect(e.src).toEqual('https://raw.githubusercontent.com/breatheco-de/exercise-postcard/e63a7916530cc850bd92aa1c2e19191837fb5c80/.learn/assets/4geeks.png');
})
1 change: 1 addition & 0 deletions .learn/exercises/12-split-postcard-body/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ test("Create a <div> inside the .postcard-body and add the class .body-left to i
})

test("Create another <div> inside the .postcard-body and add the class .body-right to it", function(){
dom = fromFile();
const e=dom.querySelector('.postcard-body').inside().querySelector('div.body-right')
expect(e).toBeTruthy();
})
Expand Down
1 change: 1 addition & 0 deletions .learn/exercises/12.1-body-content/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ test("Create a <div> inside the .postcard-body and add the class .body-left to i
})

test("Create a <div> inside the .postcard-body and add the class .body-right to it", function(){
dom = fromFile();
const e=dom.querySelector('.postcard-body').inside().querySelector('div.body-right')
expect(e).toBeTruthy();
})
Expand Down
3 changes: 2 additions & 1 deletion .learn/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const DOM = (path=null, html=null, context) => {
htmlContent = fs.readFileSync(path, 'utf8')
}
document.documentElement.innerHTML = htmlContent.toString();
let _document = document.cloneNode(true);
let _document = document // The current version of jest doesn't fully support the stylesheets in cloned elements
// let _document = document.cloneNode(true);

return {
raw: htmlContent,
Expand Down
Loading