Skip to content

Commit

Permalink
test(nvue-styler): border 展开时候不展开错误内容 issues_14277
Browse files Browse the repository at this point in the history
  • Loading branch information
Otto-J committed Jan 8, 2025
1 parent 5b80058 commit 0977817
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 256 deletions.
67 changes: 49 additions & 18 deletions packages/uni-nvue-styler/__tests__/expand.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ describe('nvue-styler: expand', () => {
})
})
})
test('transform border', function () {
test('transform border simple', function () {
// simple
expect(
createTransformBorder({ type: 'uvue' })(
Expand Down Expand Up @@ -325,13 +325,13 @@ describe('nvue-styler: expand', () => {
value: 'red',
},
])

const types = ['border', ...postionTypes]
})
test('transform border', function () {
const createBorders = (
border: string
): Record<string, Record<string, string>[]> => {
return {
'1px': fillBorderPostion([
'1px': [
{
type: 'decl',
prop: `${border}-width`,
Expand All @@ -347,8 +347,8 @@ describe('nvue-styler: expand', () => {
prop: `${border}-color`,
value: '#000000',
},
]),
'#ffffff': fillBorderPostion([
],
'#ffffff': [
{
type: 'decl',
prop: `${border}-width`,
Expand All @@ -364,8 +364,8 @@ describe('nvue-styler: expand', () => {
prop: `${border}-color`,
value: '#ffffff',
},
]),
thick: fillBorderPostion([
],
thick: [
{
type: 'decl',
prop: `${border}-width`,
Expand All @@ -381,8 +381,8 @@ describe('nvue-styler: expand', () => {
prop: `${border}-color`,
value: '#000000',
},
]),
'2px dashed': fillBorderPostion([
],
'2px dashed': [
{
type: 'decl',
prop: `${border}-width`,
Expand All @@ -398,8 +398,8 @@ describe('nvue-styler: expand', () => {
prop: `${border}-color`,
value: '#000000',
},
]),
'3px dotted #ffffff': fillBorderPostion([
],
'3px dotted #ffffff': [
{
type: 'decl',
prop: `${border}-width`,
Expand All @@ -415,20 +415,19 @@ describe('nvue-styler: expand', () => {
prop: `${border}-color`,
value: '#ffffff',
},
]),
],
}
}

types.forEach((type) => {
postionTypes.forEach((type) => {
const borders = createBorders(type)
Object.keys(borders).forEach((b) => {
const decl = parseDecl(`.test {
${type}: ${b}
}`)
${type}: ${b}
}`)

const transformBorder = createTransformBorder({
type: 'uvue',
})

expect(transformBorder(decl)).toEqual(
borders[b].map((node) => {
const val = Object.assign(
Expand All @@ -441,6 +440,38 @@ describe('nvue-styler: expand', () => {
})
})
})
test('transform border-left', () => {
expect(
createTransformBorder({ type: 'uvue' })(
parseDecl(`
.test{
border-left:1px solid red;
}`)
)
).toEqual([
{
prop: 'border-left-width',
raws: expect.any(Object),
source: expect.any(Object),
type: 'decl',
value: '1px',
},
{
prop: 'border-left-style',
raws: expect.any(Object),
source: expect.any(Object),
type: 'decl',
value: 'solid',
},
{
prop: 'border-left-color',
raws: expect.any(Object),
source: expect.any(Object),
type: 'decl',
value: 'red',
},
])
})
test(`transform border-style`, () => {
const borderStyles: Record<string, Record<string, string>[]> = {
dotted: fillBorderPostion([
Expand Down
Loading

0 comments on commit 0977817

Please sign in to comment.