Skip to content

Commit 9a91034

Browse files
authored
Add files via upload
1 parent c5de54b commit 9a91034

File tree

6 files changed

+182
-0
lines changed

6 files changed

+182
-0
lines changed

postcss.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
plugins: {
3+
autoprefixer: {},
4+
stylelint: {
5+
fix: true,
6+
},
7+
},
8+
};

tests/props.spec.ts

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { mount } from '@vue/test-utils';
2+
import SecurityCode from '../src';
3+
4+
describe('props', () => {
5+
describe('modelValue', () => {
6+
it('should apply the given modelValue', () => {
7+
const wrapper = mount(SecurityCode, {
8+
props: {
9+
modelValue: '123456',
10+
},
11+
});
12+
13+
expect(wrapper.props('modelValue')).toEqual('123456');
14+
});
15+
});
16+
17+
describe('blurOnComplete', () => {
18+
it('should not be blurOnComplete by false', () => {
19+
const wrapper = mount(SecurityCode);
20+
21+
expect(wrapper.props('blurOnComplete')).toBe(false);
22+
});
23+
24+
it('should be blurOnComplete', () => {
25+
const wrapper = mount(SecurityCode, {
26+
props: {
27+
blurOnComplete: true,
28+
},
29+
});
30+
31+
expect(wrapper.props('blurOnComplete')).toBe(true);
32+
});
33+
});
34+
35+
describe('len', () => {
36+
it('should not display the len by default', () => {
37+
const wrapper = mount(SecurityCode);
38+
39+
expect(wrapper.props('len')).toBe(6);
40+
});
41+
42+
it('should display the len four', () => {
43+
const wrapper = mount(SecurityCode, {
44+
props: {
45+
len: 4,
46+
},
47+
});
48+
49+
expect(wrapper.props('len')).toBe(4);
50+
});
51+
});
52+
53+
describe('isArray', () => {
54+
it('should not be isArray by false', () => {
55+
const wrapper = mount(SecurityCode, {
56+
props: {
57+
isArray: false,
58+
},
59+
});
60+
61+
expect(wrapper.props('isArray')).toBe(false);
62+
});
63+
64+
it('should by isArray', () => {
65+
const wrapper = mount(SecurityCode, {
66+
props: {
67+
isArray: true,
68+
},
69+
});
70+
71+
expect(wrapper.props('isArray')).toBe(true);
72+
});
73+
});
74+
75+
describe('size', () => {
76+
it('should not be size by default', () => {
77+
const wrapper = mount(SecurityCode);
78+
79+
expect(wrapper.props('size')).toBe('default');
80+
});
81+
82+
it('should be size by md', () => {
83+
const wrapper = mount(SecurityCode, {
84+
props: {
85+
size: 'md',
86+
},
87+
});
88+
89+
expect(wrapper.props('size')).toBe('md');
90+
});
91+
});
92+
});

tsconfig.eslint.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./tsconfig",
3+
"include": ["*.js", ".*.js", "docs", "src", "tests", "types"]
4+
}

tsconfig.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"allowSyntheticDefaultImports": true,
4+
"moduleResolution": "node",
5+
"resolveJsonModule": true,
6+
"strict": true,
7+
"target": "esnext"
8+
},
9+
"include": ["docs", "src", "types"]
10+
}

types/index.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
declare module '@ofcold/security-code' {
2+
import { Component } from 'vue';
3+
4+
const SecurityCode: Component;
5+
6+
export default SecurityCode;
7+
}

webpack.config.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
const HtmlWebpackPlugin = require('html-webpack-plugin');
4+
const VueLoaderPlugin = require('vue-loader/dist/plugin').default;
5+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6+
7+
module.exports = (env) => ({
8+
mode: env.production ? 'production' : 'development',
9+
entry: './docs',
10+
output: {
11+
path: path.resolve(__dirname, './docs/dist'),
12+
},
13+
module: {
14+
rules: [
15+
{
16+
test: /\.js$/,
17+
use: 'babel-loader',
18+
},
19+
{
20+
test: /\.ts$/,
21+
loader: 'ts-loader',
22+
options: {
23+
appendTsSuffixTo: [/\.vue$/],
24+
},
25+
},
26+
{
27+
test: /\.vue$/,
28+
loader: 'vue-loader',
29+
},
30+
{
31+
test: /\.scss$/,
32+
use: [
33+
MiniCssExtractPlugin.loader,
34+
'css-loader',
35+
'sass-loader',
36+
],
37+
},
38+
],
39+
},
40+
plugins: [
41+
new HtmlWebpackPlugin({
42+
filename: 'index.html',
43+
template: './docs/index.html',
44+
}),
45+
new MiniCssExtractPlugin(),
46+
new VueLoaderPlugin(),
47+
new webpack.DefinePlugin({
48+
__VUE_OPTIONS_API__: true,
49+
__VUE_PROD_DEVTOOLS__: false,
50+
}),
51+
],
52+
externals: env.production ? {
53+
vue: 'Vue',
54+
} : {},
55+
resolve: {
56+
alias: {
57+
vue$: 'vue/dist/vue.esm-bundler',
58+
},
59+
extensions: ['.js', '.json', '.ts', '.d.ts', '.vue'],
60+
},
61+
});

0 commit comments

Comments
 (0)