Skip to content

Commit 0977817

Browse files
committed
test(nvue-styler): border 展开时候不展开错误内容 issues_14277
1 parent 5b80058 commit 0977817

File tree

3 files changed

+271
-256
lines changed

3 files changed

+271
-256
lines changed

packages/uni-nvue-styler/__tests__/expand.spec.ts

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ describe('nvue-styler: expand', () => {
230230
})
231231
})
232232
})
233-
test('transform border', function () {
233+
test('transform border simple', function () {
234234
// simple
235235
expect(
236236
createTransformBorder({ type: 'uvue' })(
@@ -325,13 +325,13 @@ describe('nvue-styler: expand', () => {
325325
value: 'red',
326326
},
327327
])
328-
329-
const types = ['border', ...postionTypes]
328+
})
329+
test('transform border', function () {
330330
const createBorders = (
331331
border: string
332332
): Record<string, Record<string, string>[]> => {
333333
return {
334-
'1px': fillBorderPostion([
334+
'1px': [
335335
{
336336
type: 'decl',
337337
prop: `${border}-width`,
@@ -347,8 +347,8 @@ describe('nvue-styler: expand', () => {
347347
prop: `${border}-color`,
348348
value: '#000000',
349349
},
350-
]),
351-
'#ffffff': fillBorderPostion([
350+
],
351+
'#ffffff': [
352352
{
353353
type: 'decl',
354354
prop: `${border}-width`,
@@ -364,8 +364,8 @@ describe('nvue-styler: expand', () => {
364364
prop: `${border}-color`,
365365
value: '#ffffff',
366366
},
367-
]),
368-
thick: fillBorderPostion([
367+
],
368+
thick: [
369369
{
370370
type: 'decl',
371371
prop: `${border}-width`,
@@ -381,8 +381,8 @@ describe('nvue-styler: expand', () => {
381381
prop: `${border}-color`,
382382
value: '#000000',
383383
},
384-
]),
385-
'2px dashed': fillBorderPostion([
384+
],
385+
'2px dashed': [
386386
{
387387
type: 'decl',
388388
prop: `${border}-width`,
@@ -398,8 +398,8 @@ describe('nvue-styler: expand', () => {
398398
prop: `${border}-color`,
399399
value: '#000000',
400400
},
401-
]),
402-
'3px dotted #ffffff': fillBorderPostion([
401+
],
402+
'3px dotted #ffffff': [
403403
{
404404
type: 'decl',
405405
prop: `${border}-width`,
@@ -415,20 +415,19 @@ describe('nvue-styler: expand', () => {
415415
prop: `${border}-color`,
416416
value: '#ffffff',
417417
},
418-
]),
418+
],
419419
}
420420
}
421-
422-
types.forEach((type) => {
421+
postionTypes.forEach((type) => {
423422
const borders = createBorders(type)
424423
Object.keys(borders).forEach((b) => {
425424
const decl = parseDecl(`.test {
426-
${type}: ${b}
427-
}`)
425+
${type}: ${b}
426+
}`)
427+
428428
const transformBorder = createTransformBorder({
429429
type: 'uvue',
430430
})
431-
432431
expect(transformBorder(decl)).toEqual(
433432
borders[b].map((node) => {
434433
const val = Object.assign(
@@ -441,6 +440,38 @@ describe('nvue-styler: expand', () => {
441440
})
442441
})
443442
})
443+
test('transform border-left', () => {
444+
expect(
445+
createTransformBorder({ type: 'uvue' })(
446+
parseDecl(`
447+
.test{
448+
border-left:1px solid red;
449+
}`)
450+
)
451+
).toEqual([
452+
{
453+
prop: 'border-left-width',
454+
raws: expect.any(Object),
455+
source: expect.any(Object),
456+
type: 'decl',
457+
value: '1px',
458+
},
459+
{
460+
prop: 'border-left-style',
461+
raws: expect.any(Object),
462+
source: expect.any(Object),
463+
type: 'decl',
464+
value: 'solid',
465+
},
466+
{
467+
prop: 'border-left-color',
468+
raws: expect.any(Object),
469+
source: expect.any(Object),
470+
type: 'decl',
471+
value: 'red',
472+
},
473+
])
474+
})
444475
test(`transform border-style`, () => {
445476
const borderStyles: Record<string, Record<string, string>[]> = {
446477
dotted: fillBorderPostion([

0 commit comments

Comments
 (0)