mirror of
https://gitee.com/layui/layui.git
synced 2025-10-15 18:55:04 +08:00
完善 laydate 测试 (#61)
* 添加 laydate 测试 * 添加 options.format 和 options.value 叠加时的验证 * 修改必须单元测试通过后再进行浏览器测试 * 添加判断css是否加载成功 * 优化 options.elem 测试 * 完善laydate测试 * 更新事件回调测试 * 先把 options.format 注释了, 依赖 master 的修复 * 添加 mock server * 更新404地址 * 使用 show api 来显示日历 * 测试火狐浏览器 * 修复火狐报错 * add callback test case * fix firefox error * fix win var * add window.lay test case * fix firefox test error * add edga test * update `laydate.render({value})` test case * update options.dateTime test case
This commit is contained in:
@@ -3,6 +3,36 @@
|
||||
* @author fe.xiaowu@gmail.com
|
||||
*/
|
||||
|
||||
var url = require('url');
|
||||
|
||||
/**
|
||||
* mock一个server供测试使用
|
||||
*
|
||||
* @param {Object} req request
|
||||
* @param {Object} res response
|
||||
* @param {Function} next 下一路由
|
||||
*
|
||||
* @example
|
||||
* 请求 /api/mock 参数如:
|
||||
* timeout - 超时时间, 默认 0
|
||||
* statusCode - 状态码, 默认 200
|
||||
* response - 响应内容, 默认 {}
|
||||
* dataType - 响应格式, 默认 json
|
||||
*/
|
||||
var httpServer = function (req, res, next) {
|
||||
if (req.url.indexOf('/api/mock') === -1) {
|
||||
return next();
|
||||
}
|
||||
|
||||
var data = url.parse(req.url, true).query;
|
||||
|
||||
setTimeout(function () {
|
||||
res.statusCode = data.statusCode || 200;
|
||||
res.setHeader('content-type', data.contentType || 'json');
|
||||
res.end(data.response || '{}');
|
||||
}, data.timeout || 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* 源文件
|
||||
*
|
||||
@@ -47,9 +77,6 @@ module.exports = function (config) {
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '',
|
||||
|
||||
// Important: 所有插件必须在此声明
|
||||
plugins: ['karma-*'],
|
||||
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
// Important: 下列数组中文件将『逆序载入』
|
||||
@@ -136,6 +163,16 @@ module.exports = function (config) {
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
// 脚本调用请设为 true
|
||||
singleRun: true
|
||||
singleRun: true,
|
||||
|
||||
middleware: ['httpServer'],
|
||||
|
||||
plugins: ['karma-*', {
|
||||
'middleware:httpServer': [
|
||||
'factory', function () {
|
||||
return httpServer;
|
||||
}
|
||||
]
|
||||
}]
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user