-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
966c171
commit fdbdd52
Showing
1 changed file
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import Creators from "@/components/Creators.vue"; | ||
|
||
describe("Creators.vue", () => { | ||
const mockCreators = [ | ||
{ display_name: "Test display_name 1" }, | ||
{ display_name: "Test display_name 2" }, | ||
{ display_name: "Test display_name 3" }, | ||
]; | ||
|
||
it("should display the names of creators when showNames is true", () => { | ||
cy.mount(Creators, { | ||
props: { | ||
creators: mockCreators, | ||
showNames: true, | ||
showBubble: false, | ||
}, | ||
}); | ||
|
||
mockCreators.forEach((creator) => { | ||
cy.contains(creator.display_name).should("exist"); | ||
}); | ||
|
||
cy.get(".display-name").then((elements) => { | ||
expect(elements[0].innerText).to.contain(mockCreators[0].display_name); | ||
expect(elements[1].innerText).to.contain(mockCreators[1].display_name); | ||
expect(elements[2].innerText).to.contain(mockCreators[2].display_name); | ||
}); | ||
}); | ||
|
||
it("should not display names if showNames is false", () => { | ||
cy.mount(Creators, { | ||
props: { | ||
creators: mockCreators, | ||
showNames: false, | ||
showBubble: true, | ||
}, | ||
}); | ||
|
||
mockCreators.forEach((creator) => { | ||
cy.contains(creator.display_name).should("not.exist"); | ||
}); | ||
}); | ||
|
||
it("should display user bubbles when showBubble is true", () => { | ||
cy.mount(Creators, { | ||
props: { | ||
creators: mockCreators, | ||
showNames: false, | ||
showBubble: true, | ||
}, | ||
}); | ||
|
||
cy.get("img").should("have.length", mockCreators.length); | ||
}); | ||
|
||
it("should not display user bubbles if showBubble is false", () => { | ||
cy.mount(Creators, { | ||
props: { | ||
creators: mockCreators, | ||
showNames: true, | ||
showBubble: false, | ||
}, | ||
}); | ||
|
||
cy.get("img").should("not.exist"); | ||
}); | ||
|
||
it("should display nothing when creators list is empty", () => { | ||
cy.mount(Creators, { | ||
props: { | ||
creators: [], | ||
showNames: true, | ||
showBubble: true, | ||
}, | ||
}); | ||
|
||
cy.get("span").should("not.exist"); | ||
}); | ||
|
||
it("should display user bubbles with the correct size", () => { | ||
const customSize = 32; | ||
|
||
cy.mount(Creators, { | ||
props: { | ||
creators: mockCreators, | ||
showNames: false, | ||
showBubble: true, | ||
size: customSize, | ||
}, | ||
}); | ||
|
||
cy.get("img") | ||
.should("have.length", mockCreators.length) | ||
.then(($images) => { | ||
$images.each((index, img) => { | ||
const imgStyle = window.getComputedStyle(img); | ||
expect(imgStyle.width).to.eq(`${customSize}px`); | ||
expect(imgStyle.height).to.eq(`${customSize}px`); | ||
}); | ||
}); | ||
}); | ||
}); |