mirror of https://github.com/layui/layui
添加浏览器端测试 (#55)
* 添加浏览器测试 * 添加静态文件引用, 解决测试时404 * 关闭ie8测试 * 恢复代码 * 添加sauce配置 * 删除sauce配置 * 添加系统配置 * 测试链接sauce * 删除token * 添加编译状态图标 * 添加 layui.js 测试用例pull/56/merge
parent
b644b76ce3
commit
6c2c29cada
10
.travis.yml
10
.travis.yml
|
@ -1,17 +1,15 @@
|
||||||
language: node_js
|
language: node_js
|
||||||
dist: trusty
|
|
||||||
addons:
|
|
||||||
chrome: stable
|
|
||||||
node_js:
|
node_js:
|
||||||
- node
|
- node
|
||||||
#addons:
|
dist: trusty
|
||||||
# sauce_connect: true
|
addons:
|
||||||
|
sauce_connect: true
|
||||||
sudo: false
|
sudo: false
|
||||||
cache:
|
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
|
|
@ -7,6 +7,15 @@
|
||||||
经典模块化前端UI框架
|
经典模块化前端UI框架
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://travis-ci.org/sentsin/layui"><img alt="Build Status" src="https://img.shields.io/travis/sentsin/layui/master.svg"></a>
|
||||||
|
<a href="https://saucelabs.com/beta/builds/7e6196205e4f492496203388fc003b65"><img src="https://saucelabs.com/buildstatus/layui" alt="Build Status"></a>
|
||||||
|
<a href="https://coveralls.io/r/sentsin/layui?branch=master"><img alt="Test Coverage" src="https://img.shields.io/coveralls/sentsin/layui/master.svg"></a>
|
||||||
|
</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://saucelabs.com/beta/builds/7e6196205e4f492496203388fc003b65"><img src="https://saucelabs.com/browser-matrix/layui.svg" alt="Browser Matrix"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Layui 是一款采用自身模块规范编写的情怀型前端UI框架,遵循原生HTML/CSS/JS的书写与组织形式,门槛极低,拿来即用。其外在极简,却又不失饱满的内在,体积轻盈,组件丰盈,从核心代码到API的每一处细节都经过精心雕琢,非常适合界面的快速开发。Layui 首个版本发布于2016年金秋,她区别于那些基于MVVM底层的UI框架,却并非逆道而行,而是信奉返璞归真之道。准确地说,她更多是为服务端程序员量身定做,你无需涉足各种前端工具的复杂配置,只需面对浏览器本身,让一切你所需要的元素与交互,从这里信手拈来。
|
Layui 是一款采用自身模块规范编写的情怀型前端UI框架,遵循原生HTML/CSS/JS的书写与组织形式,门槛极低,拿来即用。其外在极简,却又不失饱满的内在,体积轻盈,组件丰盈,从核心代码到API的每一处细节都经过精心雕琢,非常适合界面的快速开发。Layui 首个版本发布于2016年金秋,她区别于那些基于MVVM底层的UI框架,却并非逆道而行,而是信奉返璞归真之道。准确地说,她更多是为服务端程序员量身定做,你无需涉足各种前端工具的复杂配置,只需面对浏览器本身,让一切你所需要的元素与交互,从这里信手拈来。
|
||||||
|
|
|
@ -57,7 +57,16 @@ module.exports = function (config) {
|
||||||
|
|
||||||
|
|
||||||
// list of files / patterns to load in the browser
|
// list of files / patterns to load in the browser
|
||||||
files: sourceFileMap.concat('test/**/*.js'),
|
files: sourceFileMap.concat('test/**/*.js').concat({
|
||||||
|
pattern: 'src/css/**/*',
|
||||||
|
included: false
|
||||||
|
}, {
|
||||||
|
pattern: 'src/font/**/*',
|
||||||
|
included: false
|
||||||
|
}, {
|
||||||
|
pattern: 'src/images/**/*',
|
||||||
|
included: false
|
||||||
|
}),
|
||||||
|
|
||||||
|
|
||||||
// list of files to exclude
|
// list of files to exclude
|
||||||
|
|
|
@ -35,11 +35,11 @@ var customLaunchers = {
|
||||||
browserName: 'chrome'
|
browserName: 'chrome'
|
||||||
},
|
},
|
||||||
|
|
||||||
sl_ie_8: {
|
// sl_ie_8: {
|
||||||
base: 'SauceLabs',
|
// base: 'SauceLabs',
|
||||||
browserName: 'internet explorer',
|
// browserName: 'internet explorer',
|
||||||
version: '8'
|
// version: '8'
|
||||||
},
|
// },
|
||||||
sl_ie_9: {
|
sl_ie_9: {
|
||||||
base: 'SauceLabs',
|
base: 'SauceLabs',
|
||||||
browserName: 'internet explorer',
|
browserName: 'internet explorer',
|
||||||
|
@ -84,7 +84,7 @@ module.exports = function (config) {
|
||||||
var options = Object.assign(base(config), {
|
var options = Object.assign(base(config), {
|
||||||
reporters: ['mocha', 'saucelabs'],
|
reporters: ['mocha', 'saucelabs'],
|
||||||
sauceLabs: {
|
sauceLabs: {
|
||||||
'testName': 'layui test case',
|
'testName': 'layui',
|
||||||
'recordVideo': false,
|
'recordVideo': false,
|
||||||
'recordScreenshots': false,
|
'recordScreenshots': false,
|
||||||
'startConnect': false,
|
'startConnect': false,
|
||||||
|
@ -92,7 +92,7 @@ module.exports = function (config) {
|
||||||
'no-ssl-bump-domains': 'all'
|
'no-ssl-bump-domains': 'all'
|
||||||
},
|
},
|
||||||
'public': 'public',
|
'public': 'public',
|
||||||
'build': process.env.CIRCLE_BUILD_NUM || process.env.SAUCE_BUILD_ID || 'build-' + Date.now(),
|
'build': 'layui-build-' + process.env.TRAVIS_BUILD_NUMBER,
|
||||||
'tunnelIdentifier': process.env.TRAVIS_JOB_NUMBER
|
'tunnelIdentifier': process.env.TRAVIS_JOB_NUMBER
|
||||||
},
|
},
|
||||||
customLaunchers: customLaunchers,
|
customLaunchers: customLaunchers,
|
||||||
|
|
17
package.json
17
package.json
|
@ -18,28 +18,28 @@
|
||||||
"author": "贤心",
|
"author": "贤心",
|
||||||
"homepage": "http://www.layui.com",
|
"homepage": "http://www.layui.com",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"chai": "^4.1.1",
|
||||||
|
"del": "^2.2.2",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-uglify": "^1.5.4",
|
|
||||||
"gulp-concat": "^2.6.0 ",
|
"gulp-concat": "^2.6.0 ",
|
||||||
"gulp-header": "^1.8.8",
|
"gulp-header": "^1.8.8",
|
||||||
"gulp-if": "^2.0.1",
|
"gulp-if": "^2.0.1",
|
||||||
"gulp-minify-css": "^1.2.4",
|
"gulp-minify-css": "^1.2.4",
|
||||||
"gulp-rename": "^1.2.2",
|
"gulp-rename": "^1.2.2",
|
||||||
"del": "^2.2.2",
|
"gulp-uglify": "^1.5.4",
|
||||||
"gulp-zip": "^4.0.0",
|
"gulp-zip": "^4.0.0",
|
||||||
"minimist": "^1.2.0",
|
|
||||||
"chai": "^3.5.0",
|
|
||||||
"karma": "^1.5.0",
|
"karma": "^1.5.0",
|
||||||
"karma-chai": "^0.1.0",
|
"karma-chai": "^0.1.0",
|
||||||
"karma-chai-sinon": "^0.1.5",
|
"karma-chai-sinon": "^0.1.5",
|
||||||
"karma-coverage": "^1.1.1",
|
"karma-coverage": "^1.1.1",
|
||||||
"karma-mocha": "^1.3.0",
|
"karma-mocha": "^1.3.0",
|
||||||
"karma-sauce-launcher": "^1.1.0",
|
|
||||||
"karma-mocha-reporter": "^2.2.3",
|
"karma-mocha-reporter": "^2.2.3",
|
||||||
"karma-phantomjs-launcher": "^1.0.4",
|
"karma-phantomjs-launcher": "^1.0.4",
|
||||||
|
"karma-sauce-launcher": "^1.1.0",
|
||||||
|
"minimist": "^1.2.0",
|
||||||
"mocha": "^3.2.0",
|
"mocha": "^3.2.0",
|
||||||
"sinon": "^2.0.0",
|
"sinon": "^3.2.1",
|
||||||
"sinon-chai": "^2.8.0"
|
"sinon-chai": "^2.13.0"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/sentsin/layui/issues"
|
"url": "https://github.com/sentsin/layui/issues"
|
||||||
|
@ -48,8 +48,7 @@
|
||||||
"doc": "doc",
|
"doc": "doc",
|
||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {},
|
||||||
},
|
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"layui",
|
"layui",
|
||||||
"ui"
|
"ui"
|
||||||
|
|
|
@ -213,7 +213,8 @@ describe('laytpl', function () {
|
||||||
it('error var', function () {
|
it('error var', function () {
|
||||||
var result = laytpl('{{ data.xxoo }}').render({});
|
var result = laytpl('{{ data.xxoo }}').render({});
|
||||||
|
|
||||||
expect(result).to.have.string('Can\'t find variable: data');
|
expect(result).to.have.string('data');
|
||||||
|
expect(result).to.have.string('ReferenceError');
|
||||||
expect(result).to.have.string('Laytpl Error');
|
expect(result).to.have.string('Laytpl Error');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -221,7 +222,7 @@ describe('laytpl', function () {
|
||||||
var result = laytpl('{{# var xxoo = ; }}').render({});
|
var result = laytpl('{{# var xxoo = ; }}').render({});
|
||||||
|
|
||||||
expect(result).to.have.string('Laytpl Error');
|
expect(result).to.have.string('Laytpl Error');
|
||||||
expect(result).to.have.string('Unexpected token \';\'');
|
expect(result).to.have.string('SyntaxError');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -0,0 +1,174 @@
|
||||||
|
/**
|
||||||
|
* @file layui - 测试
|
||||||
|
* @author xuexb <fe.xiaowu@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* global layui */
|
||||||
|
/* eslint-disable max-nested-callbacks */
|
||||||
|
|
||||||
|
var $ = layui.$;
|
||||||
|
|
||||||
|
describe('layui', function () {
|
||||||
|
it('version', function () {
|
||||||
|
expect(layui.v).to.be.a('string');
|
||||||
|
expect(layui.v).to.not.be.empty;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('layui.config', function () {
|
||||||
|
expect(layui.config()).to.deep.equal(layui);
|
||||||
|
expect(layui.config({
|
||||||
|
testName: 'layui'
|
||||||
|
})).to.deep.equal(layui);
|
||||||
|
expect(layui.cache.testName).to.equal('layui');
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('layui.router', function () {
|
||||||
|
var defaultData = {
|
||||||
|
path: [],
|
||||||
|
search: {},
|
||||||
|
hash: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
it('default params', function () {
|
||||||
|
expect(layui.router).to.be.a('function');
|
||||||
|
expect(layui.router()).to.be.a('object').and.deep.equal(defaultData);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('error router', function () {
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
'',
|
||||||
|
'#123',
|
||||||
|
'123',
|
||||||
|
'##'
|
||||||
|
].forEach(function (key) {
|
||||||
|
expect(layui.router(key)).to.deep.equal(defaultData);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('router querystring', function () {
|
||||||
|
expect(layui.router('#/a=1/b=2/c=')).to.deep.equal($.extend({}, defaultData, {
|
||||||
|
search: {
|
||||||
|
a: '1',
|
||||||
|
b: '2',
|
||||||
|
c: ''
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
expect(layui.router('#/a=测试/b=2').search).to.deep.equal({
|
||||||
|
a: '测试',
|
||||||
|
b: '2'
|
||||||
|
});
|
||||||
|
|
||||||
|
// todo
|
||||||
|
// urlencode
|
||||||
|
// urldecode
|
||||||
|
});
|
||||||
|
|
||||||
|
it('router hash', function () {
|
||||||
|
expect(layui.router('#/name#layui')).to.deep.equal($.extend({}, defaultData, {
|
||||||
|
hash: '#layui',
|
||||||
|
path: ['name']
|
||||||
|
}));
|
||||||
|
expect(layui.router('#/name#layui').hash).to.equal('#layui');
|
||||||
|
expect(layui.router('#/name#layui=1').hash).to.equal('#layui=1');
|
||||||
|
expect(layui.router('#/name##layui').hash).to.equal('##layui');
|
||||||
|
expect(layui.router('#/name=1#layui').hash).to.equal('#layui');
|
||||||
|
expect(layui.router('#/name=1/b=2#layui').hash).to.equal('#layui');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('router path', function () {
|
||||||
|
expect(layui.router('#/a/b/c=2#hash')).to.deep.equal({
|
||||||
|
path: ['a', 'b'],
|
||||||
|
search: {
|
||||||
|
c: '2'
|
||||||
|
},
|
||||||
|
hash: '#hash'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('layui.each', function () {
|
||||||
|
it('check params', function () {
|
||||||
|
expect(layui.each).to.be.a('function');
|
||||||
|
expect(layui.each()).to.deep.equal(layui);
|
||||||
|
expect(layui.each({})).to.deep.equal(layui);
|
||||||
|
expect(layui.each([])).to.deep.equal(layui);
|
||||||
|
expect(layui.each({}, function () {})).to.deep.equal(layui);
|
||||||
|
expect(layui.each([], function () {})).to.deep.equal(layui);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('null params', function (done) {
|
||||||
|
var index = 0;
|
||||||
|
layui.each(null, function (index) {
|
||||||
|
index += 1;
|
||||||
|
});
|
||||||
|
setTimeout(function () {
|
||||||
|
expect(index).to.equal(0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('object each', function (done) {
|
||||||
|
layui.each({
|
||||||
|
name: 'layui'
|
||||||
|
}, function (key, value) {
|
||||||
|
expect(this + '').to.deep.equal(value).and.equal('layui');
|
||||||
|
expect(key).to.equal('name');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('array each', function (done) {
|
||||||
|
layui.each([
|
||||||
|
'layui'
|
||||||
|
], function (index, value) {
|
||||||
|
expect(this + '').to.deep.equal(value).and.equal('layui')
|
||||||
|
expect(index).to.equal(0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('break array each', function () {
|
||||||
|
var arr = new Array(100).join(',').split(',');
|
||||||
|
var flag = -1;
|
||||||
|
layui.each(arr, function (index) {
|
||||||
|
flag = index;
|
||||||
|
if (index > 5) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(flag).to.equal(6);
|
||||||
|
|
||||||
|
flag = -1;
|
||||||
|
layui.each(arr, function (index) {
|
||||||
|
flag = index;
|
||||||
|
if (index > 5) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(flag).to.equal(99);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('break object each', function () {
|
||||||
|
var obj = {
|
||||||
|
name: 'layui',
|
||||||
|
version: '2.x'
|
||||||
|
};
|
||||||
|
var flag = null;
|
||||||
|
layui.each(obj, function (key) {
|
||||||
|
flag = key;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
expect(flag).to.equal('name');
|
||||||
|
|
||||||
|
flag = null;
|
||||||
|
layui.each(obj, function (key) {
|
||||||
|
flag = key;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
expect(flag).to.equal('version');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
/* eslint-enable max-nested-callbacks */
|
Loading…
Reference in New Issue