mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-15 02:40:46 +08:00
feat: add tests dir to template
This commit is contained in:
parent
1ae9f46357
commit
bf022e3862
@ -7,7 +7,7 @@
|
||||
"build": "vite build",
|
||||
"cz": "npx git-cz",
|
||||
"test": "jest",
|
||||
"gc": "sh ./scripts/gc.sh"
|
||||
"gc": "bash ./scripts/gc.sh"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "^3.0.0-rc.1",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {mount, config} from '@vue/test-utils'
|
||||
import {mount} from '@vue/test-utils'
|
||||
import Button from '../src/index.vue'
|
||||
|
||||
const AXIOM = 'Rem is the best girl'
|
||||
|
@ -25,42 +25,65 @@ for i in $(echo $NAME | sed 's/[_|-]\([a-z]\)/\ \1/;s/^\([a-z]\)/\ \1/'); do
|
||||
done
|
||||
NAME=$NORMALIZED_NAME
|
||||
|
||||
TEMPLATE_INDEX_VUE="<template>\n
|
||||
<div>\n
|
||||
</div>\n
|
||||
</template>\n
|
||||
<script lang='ts'>\n
|
||||
export default {\n
|
||||
NAME: 'El${NAME}',\n
|
||||
props: {\n
|
||||
},\n
|
||||
setup(props,ctx) { }\n
|
||||
};\n
|
||||
</script>\n
|
||||
<style>\n
|
||||
</style>\n
|
||||
"
|
||||
|
||||
TEMPLATE_INDEX_TS="\n
|
||||
import { App } from 'vue'\n
|
||||
import ${NAME} from './src/index.vue'\n
|
||||
export default (app: App) => {\n
|
||||
app.component(${NAME}.name, ${NAME})\n
|
||||
}
|
||||
"
|
||||
TEMPLATE_PKG_JSON="\n
|
||||
{\n
|
||||
\"name\": \"@element-plus/${INPUT_NAME}\",\n
|
||||
\"description\": \"\",\n
|
||||
\"version\": \"0.1.0\",\n
|
||||
\"main\": \"./index.ts\",\n
|
||||
\"license\": \"MIT\",\n
|
||||
\"dependencies\": {}\n
|
||||
}\n
|
||||
"
|
||||
|
||||
mkdir -p "$DIRNAME"
|
||||
mkdir -p "$DIRNAME/src"
|
||||
echo $TEMPLATE_INDEX_VUE >>"$DIRNAME/src/index.vue"
|
||||
echo $TEMPLATE_INDEX_TS >>"$DIRNAME/index.ts"
|
||||
echo $TEMPLATE_PKG_JSON >>"$DIRNAME/package.json"
|
||||
mkdir -p "$DIRNAME/__tests__"
|
||||
|
||||
cat > $DIRNAME/src/index.vue <<EOF
|
||||
<template>
|
||||
<div>
|
||||
<slot/>
|
||||
</div>
|
||||
</template>
|
||||
<script lang='ts'>
|
||||
export default {
|
||||
NAME: 'El${NAME}',
|
||||
props: {
|
||||
},
|
||||
setup(props,ctx) { }
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
</style>
|
||||
EOF
|
||||
|
||||
cat > $DIRNAME/index.ts <<EOF
|
||||
import { App } from 'vue'
|
||||
import ${NAME} from './src/index.vue'
|
||||
export default (app: App) => {
|
||||
app.component(${NAME}.name, ${NAME})
|
||||
}
|
||||
EOF
|
||||
|
||||
cat > $DIRNAME/package.json <<EOF
|
||||
{
|
||||
"name": "@element-plus/$INPUT_NAME",
|
||||
"version": "0.0.0",
|
||||
"main": "dist/index.js",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"vue": "^3.0.0-rc.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/test-utils": "^2.0.0-beta.0"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cat > $DIRNAME/__tests__/$INPUT_NAME.spec.ts <<EOF
|
||||
import {mount} from '@vue/test-utils'
|
||||
import $NAME from '../src/index.vue'
|
||||
|
||||
const AXIOM = 'Rem is the best girl'
|
||||
|
||||
describe('$NAME.vue', () => {
|
||||
test('render test', () => {
|
||||
const instance = mount($NAME, {
|
||||
slots: {
|
||||
default: AXIOM
|
||||
},
|
||||
})
|
||||
expect(instance.text()).toEqual(AXIOM)
|
||||
})
|
||||
})
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user