|
| 1 | +import { formatInputTag } from '../src/plugins/input' |
| 2 | + |
| 3 | +describe('test input tag', () => { |
| 4 | + test('with end input tag', () => { |
| 5 | + expect( |
| 6 | + formatInputTag(` |
| 7 | + <template> |
| 8 | + <view class="content"> |
| 9 | + <image class="logo" src="/static/logo.png"></image> |
| 10 | + <view class="text-area"> |
| 11 | + <text class="title">{{ title }}</text> |
| 12 | + </view> |
| 13 | + </view> |
| 14 | + </template>`) |
| 15 | + ).toBe(` |
| 16 | + <template> |
| 17 | + <view class="content"> |
| 18 | + <image class="logo" src="/static/logo.png"></image> |
| 19 | + <view class="text-area"> |
| 20 | + <text class="title">{{ title }}</text> |
| 21 | + </view> |
| 22 | + </view> |
| 23 | + </template>`) |
| 24 | + |
| 25 | + expect( |
| 26 | + formatInputTag( |
| 27 | + `<template><view type="text"><input type="text" /></view></template>` |
| 28 | + ) |
| 29 | + ).toBe( |
| 30 | + `<template><view type="text"><input type="text" /></view></template>` |
| 31 | + ) |
| 32 | + |
| 33 | + expect(formatInputTag(`<template><input type="text" /></template>`)).toBe( |
| 34 | + `<template><input type="text" /></template>` |
| 35 | + ) |
| 36 | + |
| 37 | + expect( |
| 38 | + formatInputTag(` |
| 39 | + <template> |
| 40 | + <input class="hidden-input" hold-keyboard type="digit" > |
| 41 | + <keyboard-accessory> |
| 42 | + <cover-view class="custom__list"> |
| 43 | + <cover-view class="custom__item" v-for="i in 4" :key="i" @click="change(i)">{{i * 5}}</cover-view> |
| 44 | + </cover-view> |
| 45 | + </keyboard-accessory> |
| 46 | + </input> |
| 47 | + </template>`) |
| 48 | + ).toBe(` |
| 49 | + <template> |
| 50 | + <input class="hidden-input" hold-keyboard type="digit" > |
| 51 | + <keyboard-accessory> |
| 52 | + <cover-view class="custom__list"> |
| 53 | + <cover-view class="custom__item" v-for="i in 4" :key="i" @click="change(i)">{{i * 5}}</cover-view> |
| 54 | + </cover-view> |
| 55 | + </keyboard-accessory> |
| 56 | + </input> |
| 57 | + </template>`) |
| 58 | + }) |
| 59 | + |
| 60 | + test('no end input tag', () => { |
| 61 | + expect(formatInputTag(`<template><input ></template>`)).toBe( |
| 62 | + `<template><input /></template>` |
| 63 | + ) |
| 64 | + |
| 65 | + expect( |
| 66 | + formatInputTag( |
| 67 | + `<template><input id="input1" class="test" type="text" ></template>` |
| 68 | + ) |
| 69 | + ).toBe( |
| 70 | + `<template><input id="input1" class="test" type="text" /></template>` |
| 71 | + ) |
| 72 | + |
| 73 | + expect( |
| 74 | + formatInputTag( |
| 75 | + `<template><input id="input1" class="test" type="text" ><input type="text" /></template>` |
| 76 | + ) |
| 77 | + ).toBe( |
| 78 | + `<template><input id="input1" class="test" type="text" /><input type="text" /></template>` |
| 79 | + ) |
| 80 | + |
| 81 | + expect( |
| 82 | + formatInputTag(` |
| 83 | + <template> |
| 84 | + <input type="text"> |
| 85 | + <input type="checkbox"></input> |
| 86 | + <input type="radio" /> |
| 87 | + <input type="file">Some content</input> |
| 88 | + <input type="text">xxx</input> |
| 89 | + <input> |
| 90 | + <keyboard-accessory> |
| 91 | + 234 |
| 92 | + </keyboard-accessory> |
| 93 | + </input> |
| 94 | + <input type="text" disabled></template>`) |
| 95 | + ).toBe(` |
| 96 | + <template> |
| 97 | + <input type="text" /> |
| 98 | + <input type="checkbox"></input> |
| 99 | + <input type="radio" /> |
| 100 | + <input type="file">Some content</input> |
| 101 | + <input type="text">xxx</input> |
| 102 | + <input> |
| 103 | + <keyboard-accessory> |
| 104 | + 234 |
| 105 | + </keyboard-accessory> |
| 106 | + </input> |
| 107 | + <input type="text" disabled /></template>`) |
| 108 | + }) |
| 109 | +}) |
0 commit comments