Skip to content

Commit

Permalink
test: 1. 完善测试代码
Browse files Browse the repository at this point in the history
  • Loading branch information
shinn-lancelot committed Jun 6, 2019
1 parent 0a47be0 commit eb305c7
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 56 deletions.
2 changes: 1 addition & 1 deletion dist/ytools.cjs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* ytools v0.0.0
* ytools v0.0.1-alpha
* (c) 2019-2019 shinn_lancelot
* Released under the MIT License.
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/ytools.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* ytools v0.0.0
* ytools v0.0.1-alpha
* (c) 2019-2019 shinn_lancelot
* Released under the MIT License.
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/ytools.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* ytools v0.0.0
* ytools v0.0.1-alpha
* (c) 2019-2019 shinn_lancelot
* Released under the MIT License.
*/
Expand Down
60 changes: 60 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,68 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>example</title>
<style>
* {
margin: 0;
padding: 0;
border: 0;
}

.result-box {
width: 100vw;
height: 100vh;
padding: 10px;
box-sizing: border-box;
}

.result-box div {
margin: 5px auto;
}
</style>
</head>
<body>
<div class="result-box">
</div>
<script src="../dist/ytools.js"></script>
<script>
var boxObj = document.getElementsByClassName('result-box')[0],
el = '',
domArr = [];

// is.js
domArr.push('是否支持触摸:' + ytools.isSupportTouch());
domArr.push('是否支持本地存储:' + ytools.isSupportLocalStorage());
domArr.push('是否支持cookie:' + ytools.isSupportCookie());
domArr.push('18888888888是否为手机号:' + ytools.isMobilePhone(18888888888));
domArr.push('6.6是否为Number类型:' + ytools.isNumber(6.6));
domArr.push('44是否为整数:' + ytools.isInteger(44));
domArr.push('-------------------------');

// number.js
domArr.push('随机获取1-10之间的整数:' + ytools.getRandomInteger(1, 10));
domArr.push('-------------------------');

// object.js
domArr.push('扩展对象:' + JSON.stringify(ytools.extendObj({ a: 1, b: 2 }, { a: 11 })));
domArr.push('深度拷贝:' + JSON.stringify(ytools.deepCopy({ name: 'shinn_lancelot' })));
domArr.push('-------------------------');

// storage.js
domArr.push('设置存储(name:shinn_lancelot):' + ytools.setStore('name', 'shinn_lancelot'));
domArr.push('获取存储(name):' + ytools.getStore('name'));
domArr.push('删除存储(name):' + ytools.delStore('name'));

// string.js
domArr.push('获取随机字符串:' + ytools.getRandomString());

// time.js
domArr.push('格式化时间戳:' + ytools.timestampFormat(new Date().getTime() / 1000));

for (var i = 0, len = domArr.length; i < len; i++) {
el = document.createElement('div');
el.innerHTML = domArr[i];
boxObj.appendChild(el);
}
</script>
</body>
</html>
Loading

0 comments on commit eb305c7

Please sign in to comment.