Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb1419f0

Browse files
authored
test: add test for Chip component (qwikifiers#48)
1 parentae3d4b1 commitb1419f0

File tree

4 files changed

+85
-107
lines changed

4 files changed

+85
-107
lines changed

‎apps/website/src/routes/showcases/Chip/ChipWithThumbnail/index.tsx‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎packages/qwik-storefront-ui/src/components/SfCheckbox/index.ts‎

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import{$}from'@builder.io/qwik';
2+
import{SfChip}from'./SfChip';
3+
4+
it('should render label',()=>{
5+
constcontent='label';
6+
cy.mount(<SfChip>{content}</SfChip>);
7+
cy.contains(content).should('be.visible');
8+
});
9+
10+
it('should apply custom class',()=>{
11+
constcontent='label';
12+
constcustomCls='example-class';
13+
14+
cy.mount(<SfChipclass={customCls}>{content}</SfChip>);
15+
cy.contains(content).should('have.class',customCls);
16+
});
17+
18+
it('should be checked programmatically',()=>{
19+
cy.mount(
20+
<SfChip
21+
inputProps={{
22+
checked:true,
23+
}}
24+
/>
25+
);
26+
27+
cy.get('input[type="checkbox"]').check();
28+
cy.get('input[type="checkbox"]').should('be.checked');
29+
});
30+
31+
it('should accepts and apply any inputProps (i.e. "disabled")',()=>{
32+
cy.mount(
33+
<SfChip
34+
inputProps={{
35+
disabled:true,
36+
}}
37+
/>
38+
);
39+
40+
cy.get('input[type="checkbox"]').should('be.disabled');
41+
});
42+
43+
it('should display prefix content',()=>{
44+
cy.mount(
45+
<SfChipsize="sm"class="mr-2"slotPrefix={true}>
46+
<divq:slot="prefix"></div>
47+
Texts
48+
</SfChip>
49+
);
50+
51+
cy.get('[data-testid="chip"]')
52+
.invoke('text')
53+
.should((text)=>{
54+
constregex=/\s*Texts/;
55+
expect(regex.test(text)).to.be.true;
56+
});
57+
});
58+
59+
it('should display suffix content',()=>{
60+
cy.mount(
61+
<SfChipsize="sm"class="mr-2"slotSuffix={true}>
62+
<divq:slot="suffix"></div>
63+
Texts
64+
</SfChip>
65+
);
66+
67+
cy.get('[data-testid="chip"]')
68+
.invoke('text')
69+
.should((text)=>{
70+
constregex=/Texts\s*/;
71+
expect(regex.test(text)).to.be.true;
72+
});
73+
});
74+
75+
it('should invoke onChange$ when clicked',()=>{
76+
constonClickSpy=cy.spy().as('onClickSpy');
77+
78+
constonClickHandler=$(()=>{
79+
cy.get('@onClickSpy').invoke('call');
80+
});
81+
82+
cy.mount(<SfChiponChange$={onClickHandler}>Text</SfChip>);
83+
cy.get('input[type="checkbox"]').check();
84+
cy.get('@onClickSpy').should('have.been.calledOnce');
85+
});

‎packages/qwik-storefront-ui/src/components/SfChip/SfChip.tsx‎

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp