Skip to content

Commit 2cbb397

Browse files
committed
Setup ava testing
1 parent aa73e16 commit 2cbb397

7 files changed

Lines changed: 43 additions & 17 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ coverage/
77
.coveralls.yml
88
npm-debug.log
99

10-
dist
10+
dist

package.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"scripts": {},
44
"dependencies": {},
55
"devDependencies": {
6+
"ava": "^0.16.0",
67
"concurrently": "^3.1.0",
78
"conventional-changelog-cli": "1.1.1",
89
"coveralls": "^2.2.0",
9-
"jest-cli": "^16.0.1",
1010
"eslint-config-ionic": "0.0.2",
1111
"lerna": "2.0.0-beta.30",
1212
"rollup": "^0.36.1",
@@ -16,14 +16,5 @@
1616
"tslint": "^4.0.0-dev.0",
1717
"tslint-ionic-rules": "^0.0.8",
1818
"typescript": "^2.1.0-dev.20161005"
19-
},
20-
"jest": {
21-
"moduleFileExtensions": [
22-
"ts",
23-
"tsx",
24-
"js"
25-
],
26-
"scriptPreprocessor": "<rootDir>/preprocessor.js",
27-
"testRegex": "/__tests__/.*\\.(ts|tsx|js)$"
2819
}
2920
}

packages/cli/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
src/**/*.js
2+
test/**/*.js

packages/cli/__tests__/ionic.ts

Whitespace-only changes.

packages/cli/package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@
1414
"main": "./dist/ionic.js",
1515
"types": "./dist/ionic.d.ts",
1616
"scripts": {
17-
"build": "npm run lint && npm run clean && ../../node_modules/.bin/tsc",
17+
"build": "npm run lint && npm run clean && ../../node_modules/.bin/concurrently -p '[{name}]' -n 'src,test' '../../node_modules/.bin/tsc' '../../node_modules/.bin/tsc -p test/tsconfig.json'",
1818
"clean": "rm -rf ./dist",
1919
"prepublish": "npm run build",
2020
"changelog": "conventional-changelog -i CHANGELOG.md -s -p angular",
2121
"coveralls": "istanbul cover node_modules/jasmine-node/bin/jasmine-node --captureExceptions spec/ && cat coverage/lcov.info | node_modules/coveralls/bin/coveralls.js && rm -rf coverage",
2222
"jasmine": "jasmine-node --captureExceptions ./spec",
23-
"lint": "../../node_modules/.bin/concurrently 'npm run lint:js' 'npm run lint:ts'",
24-
"lint:js": "eslint .",
25-
"lint:ts": "../../node_modules/.bin/tslint -c ../../tslint.json 'src/**/*.ts'",
26-
"test": "npm run lint && istanbul cover node_modules/jasmine-node/bin/jasmine-node --captureExceptions spec/",
27-
"watch": "npm run clean && ../../node_modules/.bin/tsc --watch"
23+
"lint": "../../node_modules/.bin/tslint -c ../../tslint.json 'src/**/*.ts'",
24+
"test": "../../node_modules/.bin/ava",
25+
"watch": "npm run clean && ../../node_modules/.bin/concurrently -p '[{name}]' -n 'src,test' '../../node_modules/.bin/tsc --watch' '../../node_modules/.bin/tsc -p test/tsconfig.json --watch'"
2826
},
2927
"keywords": [
3028
"ionic",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as chalk from 'chalk';
2+
import test from 'ava';
3+
4+
import { validators } from '../../src/lib/validators';
5+
6+
test('required validator', t => {
7+
const r1 = validators.required('');
8+
t.true(typeof r1 === 'string' && r1 === 'Must not be empty.');
9+
const r2 = validators.required('', 'my_key');
10+
t.true(typeof r2 === 'string' && chalk.stripColor(r2) === 'my_key must not be empty.');
11+
const r3 = validators.required('value!');
12+
t.true(typeof r3 === 'boolean' && r3);
13+
});
14+
15+
test('email validator', t => {
16+
const r1 = validators.email('');
17+
t.true(typeof r1 === 'string' && r1 === 'Invalid email address.');
18+
const r2 = validators.email('', 'my_key');
19+
t.true(typeof r2 === 'string' && chalk.stripColor(r2) === 'my_key is an invalid email address.');
20+
const r3 = validators.email('asdf')
21+
t.true(typeof r3 === 'string' && r3 === 'Invalid email address.');
22+
const r4 = validators.email('foo@foo')
23+
t.true(typeof r4 === 'string' && r4 === 'Invalid email address.');
24+
const r5 = validators.email('[email protected]')
25+
t.true(typeof r5 === 'boolean' && r5);
26+
});

packages/cli/test/tsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"moduleResolution": "node",
5+
"noImplicitAny": true,
6+
"strictNullChecks": true,
7+
"target": "es6"
8+
}
9+
}

0 commit comments

Comments
 (0)