完善 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:
parent
2f13ad3055
commit
34a30c1b25
@ -12,7 +12,6 @@ cache:
|
|||||||
directories:
|
directories:
|
||||||
- node_modules
|
- node_modules
|
||||||
script:
|
script:
|
||||||
- npm run test:cov
|
- npm run test:cov && npm run test:sauce
|
||||||
- npm run test:sauce
|
|
||||||
after_script:
|
after_script:
|
||||||
- npm install coveralls && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
|
- npm install coveralls && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
|
||||||
|
@ -3,6 +3,36 @@
|
|||||||
* @author fe.xiaowu@gmail.com
|
* @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)
|
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||||
basePath: '',
|
basePath: '',
|
||||||
|
|
||||||
// Important: 所有插件必须在此声明
|
|
||||||
plugins: ['karma-*'],
|
|
||||||
|
|
||||||
// frameworks to use
|
// frameworks to use
|
||||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||||
// Important: 下列数组中文件将『逆序载入』
|
// Important: 下列数组中文件将『逆序载入』
|
||||||
@ -136,6 +163,16 @@ module.exports = function (config) {
|
|||||||
// Continuous Integration mode
|
// Continuous Integration mode
|
||||||
// if true, Karma captures browsers, runs the tests and exits
|
// if true, Karma captures browsers, runs the tests and exits
|
||||||
// 脚本调用请设为 true
|
// 脚本调用请设为 true
|
||||||
singleRun: true
|
singleRun: true,
|
||||||
|
|
||||||
|
middleware: ['httpServer'],
|
||||||
|
|
||||||
|
plugins: ['karma-*', {
|
||||||
|
'middleware:httpServer': [
|
||||||
|
'factory', function () {
|
||||||
|
return httpServer;
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -59,6 +59,13 @@ var customLaunchers = {
|
|||||||
version: '11'
|
version: '11'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
sl_edga: {
|
||||||
|
base: 'SauceLabs',
|
||||||
|
browserName: 'microsoftedge',
|
||||||
|
platform: 'Windows 10',
|
||||||
|
version: '15'
|
||||||
|
},
|
||||||
|
|
||||||
sl_firefox: {
|
sl_firefox: {
|
||||||
base: 'SauceLabs',
|
base: 'SauceLabs',
|
||||||
browserName: 'firefox',
|
browserName: 'firefox',
|
||||||
|
@ -162,7 +162,7 @@
|
|||||||
|
|
||||||
//中止冒泡
|
//中止冒泡
|
||||||
lay.stope = function(e){
|
lay.stope = function(e){
|
||||||
e = e || win.event;
|
e = e || window.event;
|
||||||
e.stopPropagation
|
e.stopPropagation
|
||||||
? e.stopPropagation()
|
? e.stopPropagation()
|
||||||
: e.cancelBubble = true;
|
: e.cancelBubble = true;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -194,7 +194,7 @@ describe('layui', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('error callback', function (done) {
|
it('error callback', function (done) {
|
||||||
layui.img('/404/404.gif', function () {}, function (e) {
|
layui.img('/api/mock?statusCode=404', function () {}, function (e) {
|
||||||
expect(e).to.not.undefined;
|
expect(e).to.not.undefined;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user