update for add unittest
Showing
4 changed files
with
26 additions
and
17 deletions
@@ -14,7 +14,19 @@ | @@ -14,7 +14,19 @@ | ||
14 | "debug": "DEBUG=\"express:*\" node app.js", | 14 | "debug": "DEBUG=\"express:*\" node app.js", |
15 | "lint-js": "./node_modules/.bin/eslint -c .eslintrc --cache --fix .", | 15 | "lint-js": "./node_modules/.bin/eslint -c .eslintrc --cache --fix .", |
16 | "lint-css": "./node_modules/.bin/stylelint --config .stylelintrc public/**/*.css", | 16 | "lint-css": "./node_modules/.bin/stylelint --config .stylelintrc public/**/*.css", |
17 | - "precommit": "node lint.js" | 17 | + "precommit": "node lint.js", |
18 | + "test": "ava" | ||
19 | + }, | ||
20 | + "ava": { | ||
21 | + "tap": true, | ||
22 | + "require": [ | ||
23 | + "babel-register" | ||
24 | + ], | ||
25 | + "babel": { | ||
26 | + "presets": [ | ||
27 | + "es2015" | ||
28 | + ] | ||
29 | + } | ||
18 | }, | 30 | }, |
19 | "license": "MIT", | 31 | "license": "MIT", |
20 | "dependencies": { | 32 | "dependencies": { |
@@ -32,6 +44,8 @@ | @@ -32,6 +44,8 @@ | ||
32 | }, | 44 | }, |
33 | "devDependencies": { | 45 | "devDependencies": { |
34 | "autoprefixer": "^6.3.6", | 46 | "autoprefixer": "^6.3.6", |
47 | + "ava": "^0.14.0", | ||
48 | + "babel-register": "^6.8.0", | ||
35 | "eslint": "^2.9.0", | 49 | "eslint": "^2.9.0", |
36 | "eslint-config-yoho": "^1.0.1", | 50 | "eslint-config-yoho": "^1.0.1", |
37 | "gulp": "^3.9.1", | 51 | "gulp": "^3.9.1", |
test/library/commonmodel.test.js
0 → 100644
1 | +const headerModel = require('../../doraemon/models/header'); | ||
2 | + | ||
3 | +const test = require('ava').test; | ||
4 | + | ||
5 | +test('test setNavHeader method', t => { | ||
6 | + const headerData = headerModel.setNavHeader('逛'); | ||
7 | + | ||
8 | + t.is(headerData.navTitle, '逛'); | ||
9 | + t.true(headerData.backUrl); | ||
10 | + t.true(headerData.navBtn); | ||
11 | +}); |
test/library/timer.test.js
deleted
100644 → 0
1 | -let expect = require('expect.js'); | ||
2 | -let Timer = require('../../library/timer'); | ||
3 | - | ||
4 | - | ||
5 | -describe('/library/timer', function() { | ||
6 | - it('延迟100ms,期望大于或等于100ms', function(done) { | ||
7 | - let t = new Timer(); | ||
8 | - t.put('aa'); | ||
9 | - setTimeout(function() { | ||
10 | - let time = t.put('aa'); | ||
11 | - expect(Math.round(time) >= 100).to.be.ok(); | ||
12 | - done(); | ||
13 | - }, 100); | ||
14 | - }); | ||
15 | -}); |
test/run.js
deleted
100644 → 0
1 | -require('./library/timer.test'); |
-
Please register or login to post a comment