Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
webpack2 配置测试环境
Browse files Browse the repository at this point in the history
  • Loading branch information
xxapp committed Jun 7, 2017
1 parent bbaf74e commit eb9bc60
Show file tree
Hide file tree
Showing 16 changed files with 293 additions and 350 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ Temporary Items
!.vscode/launch.json

dist/*
output/*
bin/*
2 changes: 0 additions & 2 deletions components/ms-calendar/ms-calendar.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as avalon from 'avalon2';
import * as moment from 'moment';
//import 'moment/locale/zh-cn';
import '../ms-select';
import './ms-calendar-year-view';
//moment.locale('zh-cn');

avalon.component('ms-calendar', {
template: require('./ms-calendar.html'),
Expand Down
18 changes: 8 additions & 10 deletions components/ms-input/test/ms-input.test.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<template>
<div>
<xmp is="ms-form" :widget="{$form: @$form}">
<ms-form-item :widget="{label:'名字'}">
<ms-input :widget="{id:'test-value',col:'name',value:@value,$rules:{required:true,message:'请输入名字'}}"></ms-input>
</ms-form-item>
</xmp>
<pre>{{@json}}</pre>
</div>
</template>
<div>
<xmp is="ms-form" :widget="{$form: @$form}">
<ms-form-item :widget="{label:'名字'}">
<ms-input :widget="{id:'test-value',col:'name',value:@value,$rules:{required:true,message:'请输入名字'}}"></ms-input>
</ms-form-item>
</xmp>
<pre>{{@json}}</pre>
</div>
2 changes: 1 addition & 1 deletion components/ms-input/test/ms-input.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
'input value': function (browser) {
browser
.url(browser.launchUrl + '/tests/index.html')
.url(browser.launchUrl + '/#!/ms-input')
.waitForElementVisible('input', 1000)
.assert.value('input', '123');
},
Expand Down
38 changes: 9 additions & 29 deletions components/ms-select/test/ms-select.test.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title>Document</title>
<link href="../../../node_modules/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
<link href="../../../node_modules/font-awesome/css/font-awesome.css" rel="stylesheet">
<script src="../../../tests/mod.js"></script>
</head>
<body>
<div :controller="test">
<div>
<xmp is="ms-select" :widget="{showSearch:true,mode:'multiple'}">
<div>
<xmp is="ms-form" :widget="{$form: @$form}">
<ms-form-item :widget="{label:'想看的动漫'}">
<ms-select :widget="{col:'comic',showSearch:true,mode:'multiple'}">
<ms-select-option :widget="{value:'onepiece'}">海贼王</ms-select-option>
<ms-select-option :widget="{value:'conna'}">名侦探柯南</ms-select-option>
<ms-select-option :widget="{value:'titan'}">进击的巨人</ms-select-option>
<ms-select-option :widget="{value:'disabled', disabled:true}">禁用</ms-select-option>
<ms-select-option :widget="{value:'onepunchman'}">一拳超人</ms-select-option>
</xmp>
</div>
</div>
<script>
require(['../../../tests/index.js'], function () {
require('../');

var vm = avalon.define({
$id: 'test'
});
});
</script>
</body>
</html>
</ms-select>
</ms-form-item>
</xmp>
<pre>{{@json}}</pre>
</div>
19 changes: 19 additions & 0 deletions components/ms-select/test/ms-select.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as avalon from 'avalon2';
import { createForm } from '../../ms-form/create-form';
import '../../ms-form';
import '../';

export const name = 'component-demo-select';

avalon.component(name, {
template: require('./ms-select.test.html'),
defaults: {
json: '',
$form: createForm(),
onInit() {
this.$form.onFieldsChange = (fields, record) => {
this.json = JSON.stringify(record);
}
}
}
});
4 changes: 2 additions & 2 deletions nightwatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

"test_settings": {
"default": {
"launch_url": "http://127.0.0.1:8081",
"launch_url": "http://127.0.0.1:9000",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"desiredCapabilities": {
Expand All @@ -24,7 +24,7 @@
},

"ie": {
"launch_url": "http://127.0.0.1:8081",
"launch_url": "http://127.0.0.1:9000",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"desiredCapabilities": {
Expand Down
21 changes: 15 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
"name": "ane",
"version": "0.0.3",
"description": "avalonjs components package",
"main": "output/ane.js",
"main": "dist/ane.js",
"scripts": {
"start": "fis3 server start -p 8081 && fis3 release",
"dev": "fis3 server start -p 8081 && fis3 release -wL",
"test": "npm start && nightwatch ./tests/nightwatch.js",
"pack": "webpack"
"start": "webpack --config webpack.test.config.js",
"dev": "webpack-dev-server --open --config webpack.test.config.js -w false",
"test": "npm-run-all -p -r server nightwatch",
"server": "http-server dist -s -p 9000",
"nightwatch": "nightwatch ./tests/nightwatch.js",
"pub": "webpack"
},
"dependencies": {
"avalon2": "^2.2.7",
Expand All @@ -25,12 +27,19 @@
"es5-shim": "^4.5.9",
"es6-promise": "^4.1.0",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.11.2",
"font-awesome": "^4.7.0",
"html-webpack-plugin": "^2.28.0",
"http-server": "^0.10.0",
"mmRouter": "^0.9.6",
"npm-run-all": "^4.0.2",
"raw-loader": "^0.5.1",
"sass-loader": "^6.0.5",
"style-loader": "^0.18.2",
"ts-loader": "^2.1.0",
"webpack": "^2.6.1"
"typescript": "^2.3.4",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5"
},
"keywords": [
"avalonjs",
Expand Down
10 changes: 2 additions & 8 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title>Document</title>
<link href="../node_modules/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
<link href="../node_modules/font-awesome/css/font-awesome.css" rel="stylesheet">
<script src="./mod.js"></script>
</head>
<body :controller="root">
<xmp is="component-demo-input"></xmp>
<script>
require(['./index']);
</script>
<div ms-html="@currentPage"></div>
</body>
</html>
18 changes: 15 additions & 3 deletions tests/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require('bootstrap/dist/css/bootstrap.css');
require('font-awesome/css/font-awesome.css');

require('es5-shim');
require('es6-promise/dist/es6-promise.auto');

Expand All @@ -7,6 +10,8 @@ require('bootstrap');
var bootbox = require('bootbox');
bootbox.setLocale('zh_CN');

require('./router');

var avalon = require('avalon2');
avalon.config({
debug: true
Expand All @@ -17,8 +22,15 @@ if (avalon.msie === 8) {
}
}
require('es5-shim/es5-sham');
require('../components/ms-input/test/ms-input.test.ts');

avalon.define({
$id: 'root'
});
$id: 'root',
currentPage: ''
});
avalon.history.start({
fireAnchor: false
});
if (!/#!/.test(global.location.hash)) {
avalon.router.navigate('/', 2);
}
avalon.scan(document.body);
Loading

0 comments on commit eb9bc60

Please sign in to comment.