Skip to content

Commit 432d4c0

Browse files
test(divider): adds new tests for new divider
1 parent e56f0ac commit 432d4c0

File tree

44 files changed

+179
-130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+179
-130
lines changed

core/api.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,22 @@ ion-datetime-button,prop,mode,"ios" | "md",undefined,false,false
730730
ion-datetime-button,prop,theme,"ios" | "md" | "ionic",undefined,false,false
731731
ion-datetime-button,part,native
732732

733+
ion-divider,shadow
734+
ion-divider,prop,inset,boolean | undefined,false,false,false
735+
ion-divider,prop,spacing,"large" | "medium" | "small" | "xlarge" | "xsmall" | "xxlarge" | "xxsmall" | undefined,undefined,false,true
736+
ion-divider,css-prop,--margin-bottom,ionic
737+
ion-divider,css-prop,--margin-bottom,ios
738+
ion-divider,css-prop,--margin-bottom,md
739+
ion-divider,css-prop,--margin-top,ionic
740+
ion-divider,css-prop,--margin-top,ios
741+
ion-divider,css-prop,--margin-top,md
742+
ion-divider,css-prop,--padding-end,ionic
743+
ion-divider,css-prop,--padding-end,ios
744+
ion-divider,css-prop,--padding-end,md
745+
ion-divider,css-prop,--padding-start,ionic
746+
ion-divider,css-prop,--padding-start,ios
747+
ion-divider,css-prop,--padding-start,md
748+
733749
ion-fab,shadow
734750
ion-fab,prop,activated,boolean,false,false,false
735751
ion-fab,prop,edge,boolean,false,false,false

core/src/components.d.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,8 +1161,14 @@ export namespace Components {
11611161
"theme"?: "ios" | "md" | "ionic";
11621162
}
11631163
interface IonDivider {
1164+
/**
1165+
* If `true`, the divider will have horizontal margins By default, it's `false`
1166+
*/
11641167
"inset"?: boolean;
1165-
"spacing"?: 'xxsmall' | 'xsmall' | 'small' | 'large' | 'xlarge' | 'xxlarge';
1168+
/**
1169+
* Set to `"xxsmall"` for the smallest spacing. Set to "xsmall" for a very small spacing. Set to `"small"` for a small spacing. Set to "medium" for a medium spacing. Set to "large" for a large spacing. Set to `"xlarge"` for the largest spacing. Defaults to `"small"` for the `ionic` theme, undefined for all other themes.
1170+
*/
1171+
"spacing"?: 'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';
11661172
}
11671173
interface IonFab {
11681174
/**
@@ -6623,8 +6629,14 @@ declare namespace LocalJSX {
66236629
"theme"?: "ios" | "md" | "ionic";
66246630
}
66256631
interface IonDivider {
6632+
/**
6633+
* If `true`, the divider will have horizontal margins By default, it's `false`
6634+
*/
66266635
"inset"?: boolean;
6627-
"spacing"?: 'xxsmall' | 'xsmall' | 'small' | 'large' | 'xlarge' | 'xxlarge';
6636+
/**
6637+
* Set to `"xxsmall"` for the smallest spacing. Set to "xsmall" for a very small spacing. Set to `"small"` for a small spacing. Set to "medium" for a medium spacing. Set to "large" for a large spacing. Set to `"xlarge"` for the largest spacing. Defaults to `"small"` for the `ionic` theme, undefined for all other themes.
6638+
*/
6639+
"spacing"?: 'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';
66286640
}
66296641
interface IonFab {
66306642
/**

core/src/components/divider/divider.scss

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,23 @@
1313
--padding-start: 0px;
1414
--padding-end: 0px;
1515

16-
padding-right: var(--padding-end);
17-
padding-left: calc(var(--padding-start) + var(--ion-safe-area-left, 0px));
18-
1916
display: block;
2017

2118
width: 100%;
19+
20+
/* stylelint-disable */
21+
padding-right: var(--padding-end);
22+
padding-left: calc(var(--padding-start) + var(--ion-safe-area-left, 0px));
2223
}
2324

2425
:host hr {
25-
margin-top: var(--margin-top);
26-
margin-bottom: var(--margin-bottom);
27-
2826
display: block;
2927

3028
width: 100%;
3129

30+
margin-top: var(--margin-top);
31+
margin-bottom: var(--margin-bottom);
32+
3233
border: none;
3334
border-top: #{globals.$ion-border-size-025} solid #{globals.$ion-border-default};
3435
}

core/src/components/divider/divider.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import { Component, Prop, Host, h } from '@stencil/core';
1212
shadow: true,
1313
})
1414
export class Divider implements ComponentInterface {
15-
16-
/**
15+
/**
1716
* Set to `"xxsmall"` for the smallest spacing.
1817
* Set to "xsmall" for a very small spacing.
1918
* Set to `"small"` for a small spacing.
@@ -25,7 +24,7 @@ export class Divider implements ComponentInterface {
2524
*/
2625
@Prop({ reflect: true }) spacing?: 'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';
2726

28-
/**
27+
/**
2928
* If `true`, the divider will have horizontal margins
3029
* By default, it's `false`
3130
*/
@@ -50,7 +49,8 @@ export class Divider implements ComponentInterface {
5049
[theme]: true,
5150
[`divider-space-${spacing}`]: spacing !== undefined,
5251
[`divider-inset`]: this.inset || false,
53-
}}>
52+
}}
53+
>
5454
<hr />
5555
</Host>
5656
);
Lines changed: 6 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,14 @@
11
import { expect } from '@playwright/test';
22
import { configs, test } from '@utils/test/playwright';
33

4-
configs().forEach(({ title, screenshot, config }) => {
5-
test.describe(title('item-divider: basic'), () => {
6-
test('should display an item divider with text', async ({ page }) => {
7-
await page.setContent(
8-
`
9-
<ion-item-divider>
10-
<ion-label>Item Divider</ion-label>
11-
</ion-item-divider>
12-
`,
13-
config
14-
);
4+
configs().forEach(({ config, screenshot, title }) => {
5+
test.describe(title('divider: rendering'), () => {
6+
test('should not have visual regressions', async ({ page }) => {
7+
await page.goto('/src/components/divider/test/basic', config);
158

16-
const divider = page.locator('ion-item-divider');
17-
await expect(divider).toHaveScreenshot(screenshot(`item-divider-text`));
18-
});
19-
20-
test('should display an item divider with a button in the end slot', async ({ page }) => {
21-
await page.setContent(
22-
`
23-
<ion-item-divider>
24-
<ion-label>Item Divider</ion-label>
25-
<ion-button slot="end">Button</ion-button>
26-
</ion-item-divider>
27-
`,
28-
config
29-
);
30-
31-
const divider = page.locator('ion-item-divider');
32-
await expect(divider).toHaveScreenshot(screenshot(`item-divider-button-end`));
33-
});
34-
35-
test('should display an item divider with an icon in the start slot', async ({ page }) => {
36-
await page.setContent(
37-
`
38-
<ion-item-divider>
39-
<ion-icon slot="start" name="star"></ion-icon>
40-
<ion-label>Item Divider</ion-label>
41-
</ion-item-divider>
42-
`,
43-
config
44-
);
45-
46-
const divider = page.locator('ion-item-divider');
47-
await expect(divider).toHaveScreenshot(screenshot(`item-divider-icon-start`));
48-
});
49-
50-
/**
51-
* This behavior needs to be tested for all modes & directions
52-
* Safe padding should stay on the same side when the direction changes
53-
*/
54-
test('should have safe area padding', async ({ page }) => {
55-
await page.setContent(
56-
`
57-
<style>
58-
:root {
59-
--ion-safe-area-left: 40px;
60-
--ion-safe-area-right: 20px;
61-
}
62-
</style>
63-
<ion-list>
64-
<ion-item-divider>
65-
<ion-label>Item Divider</ion-label>
66-
<ion-button slot="end">Button</ion-button>
67-
</ion-item-divider>
68-
</ion-list>
69-
`,
70-
config
71-
);
72-
73-
const list = page.locator('ion-list');
9+
await page.setIonViewport();
7410

75-
await expect(list).toHaveScreenshot(screenshot('item-divider-safe-area'));
11+
await expect(page).toHaveScreenshot(screenshot(`divider-basic`));
7612
});
7713
});
7814
});
10.2 KB
16.4 KB
11.2 KB
10.1 KB
16.3 KB

0 commit comments

Comments
 (0)