Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve overall test coverage #287

Merged
merged 91 commits into from
Sep 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
3a699a2
test: improve overall test coverage
zacharygolba Aug 7, 2016
733246d
style: consistent descriptions in freezeable tests
zacharygolba Aug 7, 2016
86e61f1
test: add more unit tests
zacharygolba Aug 7, 2016
fff404d
test: add more unit tests
zacharygolba Aug 7, 2016
a79e410
Merge branch 'master' into test-coverage
zacharygolba Aug 8, 2016
c565b14
Merge branch 'master' into test-coverage
zacharygolba Aug 10, 2016
cb45c9f
test: complete test coverage for utils
zacharygolba Aug 10, 2016
cc6ded8
refactor: do not rely on global mocha functions
zacharygolba Aug 10, 2016
9e29e49
Merge branch 'master' into test-coverage
zacharygolba Aug 10, 2016
75ed059
test: add unit test for jsonapi, serializer, and more
zacharygolba Aug 11, 2016
77a704d
Merge branch 'master' into test-coverage
zacharygolba Aug 11, 2016
ccd2e1c
test: add unit tests for Router and Config
zacharygolba Aug 11, 2016
2e7a4e4
test: start adding fs unit tests
zacharygolba Aug 11, 2016
9a0052a
test: add unit tests for loader
zacharygolba Aug 12, 2016
9688d15
Merge branch 'master' into test-coverage
zacharygolba Aug 12, 2016
0763522
Merge branch 'master' into test-coverage
zacharygolba Aug 12, 2016
eeba9c1
Merge branch 'master' into test-coverage
zacharygolba Aug 13, 2016
ff6df88
Merge branch 'master' into test-coverage
zacharygolba Aug 14, 2016
ce6d6ce
Merge branch 'master' into test-coverage
zacharygolba Aug 16, 2016
56af49c
Merge branch 'master' into test-coverage
zacharygolba Aug 17, 2016
19f7f3e
Merge branch 'master' into test-coverage
zacharygolba Aug 20, 2016
c97a3b5
add unit test for fs#exists
javamonn Aug 22, 2016
0f78fac
test: add unit test for fs#rmrf
javamonn Aug 22, 2016
d1559f2
Merge branch 'master' into test-coverage
zacharygolba Aug 22, 2016
ce04911
test: add unit tests for Logger
javamonn Aug 23, 2016
ecd1b7f
test: add initial Route unit tests
javamonn Aug 23, 2016
a230ac8
test: add unit tests for route utils
javamonn Aug 24, 2016
5ed3741
test: add unit test for filter-param
javamonn Aug 24, 2016
08c4c25
Merge branch 'master' into test-coverage
zacharygolba Aug 25, 2016
1b4a722
Merge branch 'test-coverage' of https://github.com/postlight/lux into…
javamonn Aug 26, 2016
d113025
Merge branch 'master' into test-coverage
zacharygolba Aug 26, 2016
90e2fe9
Merge branch 'master' into test-coverage
zacharygolba Aug 29, 2016
74d35e3
Merge branch 'master' into test-coverage
zacharygolba Aug 30, 2016
3100769
Merge branch 'master' into test-coverage
zacharygolba Sep 1, 2016
a55c269
Merge branch 'master' into test-coverage
zacharygolba Sep 3, 2016
d19b627
Merge branch 'master' into test-coverage
zacharygolba Sep 3, 2016
7810882
fix: get tests passing on windows
zacharygolba Sep 3, 2016
7e13a63
Merge branch 'master' into test-coverage
zacharygolba Sep 3, 2016
9ecb021
fix: ensure tmp dir exists on appveyor builds
zacharygolba Sep 3, 2016
c50baa2
Merge branch 'test-coverage' of https://github.com/postlight/lux into…
zacharygolba Sep 3, 2016
9c8b5ba
Merge branch 'master' into test-coverage
zacharygolba Sep 3, 2016
7aa9644
Merge branch 'master' into test-coverage
zacharygolba Sep 4, 2016
b1e8b29
test: get tests to pass after merge
zacharygolba Sep 4, 2016
4facc70
Merge branch 'master' into test-coverage
zacharygolba Sep 4, 2016
626a036
Merge branch 'master' into test-coverage
zacharygolba Sep 4, 2016
9482ebb
test: use social-network as test-app
zacharygolba Sep 4, 2016
12c6c2a
Merge branch 'master' into test-coverage
zacharygolba Sep 5, 2016
5b35139
Merge branch 'master' into test-coverage
zacharygolba Sep 6, 2016
1860e5a
Merge branch 'master' into test-coverage
zacharygolba Sep 9, 2016
b26a846
Merge branch 'master' into test-coverage
zacharygolba Sep 10, 2016
1507a8f
Merge branch 'master' into test-coverage
zacharygolba Sep 10, 2016
5df47a1
fix: get unit tests passing and remove integration tests for now
zacharygolba Sep 10, 2016
0bab3f0
test: add unit test for route parameters
zacharygolba Sep 11, 2016
8e44706
refactor: change test-app name back to test-app
zacharygolba Sep 11, 2016
7837a96
test: add unit test for route parameter groups
zacharygolba Sep 11, 2016
647cda8
test: add unit test for route action
zacharygolba Sep 11, 2016
ab5ac86
test: start unit test for controller
zacharygolba Sep 11, 2016
7b21ceb
test: complete unit test for controller
zacharygolba Sep 11, 2016
6eeb81d
Merge branch 'master' into test-coverage
zacharygolba Sep 11, 2016
4cdc298
fix: use bcryptjs instead of bcrypt-as-promised in test-app
zacharygolba Sep 11, 2016
4cb1f22
test: add unit test for database validations
zacharygolba Sep 11, 2016
ba4c845
fix: use relative paths in test-app until rollup aliases are fixed
zacharygolba Sep 11, 2016
120107b
fix: use relative file path for windows in test-app
zacharygolba Sep 11, 2016
4137d2d
fix: replace remaining aliased file paths in test-app
zacharygolba Sep 11, 2016
4e098ff
fix: create root tmp dir in appveyor before running tests
zacharygolba Sep 11, 2016
28f9315
test: increase mocha timeout
zacharygolba Sep 11, 2016
4d910f0
test: add unit tests for server/request and server/response
zacharygolba Sep 16, 2016
eb620de
Merge branch 'master' into test-coverage
zacharygolba Sep 16, 2016
a01533e
test: use local timeout in root before hook
zacharygolba Sep 16, 2016
808f8cf
test: add unit tests for server/responder and server
zacharygolba Sep 16, 2016
86e15c8
refactor: run tests without building
zacharygolba Sep 16, 2016
ea4712a
test: add unit tests to fs
javamonn Sep 13, 2016
f1db2de
test: add unit tests for database and static methods of database/model
zacharygolba Sep 17, 2016
7f0608e
test: add unit tests in model for #save() and #update()
zacharygolba Sep 17, 2016
38ec8f7
test: add remaining unit test for model instance methods
zacharygolba Sep 17, 2016
b35c83c
test: improve #save() unit test for model
zacharygolba Sep 18, 2016
3647d6b
test: add unit tests for model hooks
zacharygolba Sep 18, 2016
dea57de
test: add unit test for migration
zacharygolba Sep 18, 2016
6f58e7a
Merge branch 'master' into test-coverage
zacharygolba Sep 18, 2016
ba78a83
test: add unit test for static methods of database/query
zacharygolba Sep 18, 2016
39327ed
test: normalize test naming conventions
zacharygolba Sep 18, 2016
b24f5f9
test: improve unit test for .from() in database/query
zacharygolba Sep 18, 2016
a83eee0
test: add codecov integration
zacharygolba Sep 18, 2016
8756840
Merge branch 'master' into test-coverage
zacharygolba Sep 18, 2016
6e5baf0
test: begin adding unit test for database/query instance methods
zacharygolba Sep 18, 2016
1b00738
Merge branch 'test-coverage' of https://github.com/postlight/lux into…
zacharygolba Sep 18, 2016
0f7f5e0
test: add unit test for logger #line()
zacharygolba Sep 18, 2016
e6877d0
test: do not include custom errors in test coverage
zacharygolba Sep 18, 2016
00ed65b
test: add unit tests for query instance methods and properly extend P…
zacharygolba Sep 19, 2016
4031686
fix: use valid integer to prevent postgres errors in controller test
zacharygolba Sep 20, 2016
f1ce42d
fix: do not user deep equal for query #include() include unit tests
zacharygolba Sep 20, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# compiled output
dist/*
coverage/
dist/
.nyc_output/

# tests
test/*
test/

# docs
docs/*
docs/

# dependencies
node_modules/*
node_modules/

# misc
decl/*
examples/*
decl/
examples/
*interfaces.js
18 changes: 9 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
"plugins": ["flowtype"],
"extends": "eslint:recommended",
"env": {
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"impliedStrict": true
}
},
"globals": {
"T": true,
"Map": true,
"Set": true,
"Class": true,
"Proxy": true,
"Promise": true,
"Reflect": true,
"WeakMap": true,
"WeakSet": true,
"Iterable": true,
"Generator": true,
"$PropertyType": true
},
"settings": {
Expand Down
12 changes: 7 additions & 5 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ decl
.*/lib/.*
.*/dist/.*
.*/docs/.*
.*/test/.*
.*/scripts/.*
.*/examples/.*
.*/node_modules/.*
.*/node_modules/bcryptjs/*

[options]
esproposal.class_instance_fields=enable
esproposal.class_static_fields=enable
suppress_comment=\\(.\\|\n\\)*\\$FlowIgnore

module.name_mapper='LUX_LOCAL' -> '<PROJECT_ROOT>'

unsafe.enable_getters_and_setters=true

esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
*.lcov
coverage/
dist/
docs/
.nyc_output/

# dependencies
node_modules/
Expand Down
13 changes: 8 additions & 5 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# dependencies
/node_modules
node_modules/

# misc
.git
*.DS_Store
/examples
*.lcov
.nyc_output/
coverage/
examples/

# docs
/docs
docs/

# logs
/log
log/
npm-debug.log

# tests
/test
test/
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@ before_script:
install:
- bash -e scripts/travis/install.sh

after_success:
- npm run test:codecov

notifications:
email: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lux

[![Build Status](https://travis-ci.org/postlight/lux.svg?branch=master)](https://travis-ci.org/postlight/lux) [![Build status](https://ci.appveyor.com/api/projects/status/xxwunscfe3rsxdmr/branch/master?svg=true)](https://ci.appveyor.com/project/zacharygolba/lux/branch/master)
[![Build Status](https://travis-ci.org/postlight/lux.svg?branch=master)](https://travis-ci.org/postlight/lux) [![Build status](https://ci.appveyor.com/api/projects/status/xxwunscfe3rsxdmr/branch/master?svg=true)](https://ci.appveyor.com/project/zacharygolba/lux/branch/master) [![codecov](https://codecov.io/gh/postlight/lux/branch/master/graph/badge.svg)](https://codecov.io/gh/postlight/lux)
[![Dependency Status](https://david-dm.org/postlight/lux.svg)](https://david-dm.org/postlight/lux) [![npm version](https://badge.fury.io/js/lux-framework.svg)](https://badge.fury.io/js/lux-framework) [![Join the chat at https://gitter.im/postlight/lux](https://badges.gitter.im/postlight/lux.svg)](https://gitter.im/postlight/lux?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

A MVC style framework for building highly performant, large scale JSON APIs that anybody who knows the JavaScript language and its modern features will understand.
Expand Down
115 changes: 115 additions & 0 deletions decl/chai.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
//@flow
// src: github.com/flowtype/flow-typed/tree/master/definitions/npm/chai_v3.5.x
declare module 'chai' {
declare type ExpectChain<T> = {
and: ExpectChain<T>;
at: ExpectChain<T>;
be: ExpectChain<T>;
been: ExpectChain<T>;
have: ExpectChain<T>;
has: ExpectChain<T>;
is: ExpectChain<T>;
of: ExpectChain<T>;
same: ExpectChain<T>;
that: ExpectChain<T>;
to: ExpectChain<T>;
which: ExpectChain<T>;
with: ExpectChain<T>;

not: ExpectChain<T>;
deep: ExpectChain<T>;
any: ExpectChain<T>;
all: ExpectChain<T>;

a: ExpectChain<T> & (type: string) => ExpectChain<T>;
an: ExpectChain<T> & (type: string) => ExpectChain<T>;

frozen: ExpectChain<T> & (value: mixed) => ExpectChain<T>;
sealed: ExpectChain<T> & (value: mixed) => ExpectChain<T>;
include: ExpectChain<T> & (value: mixed) => ExpectChain<T>;
includes: ExpectChain<T> & (value: mixed) => ExpectChain<T>;
contain: ExpectChain<T> & (value: mixed) => ExpectChain<T>;
contains: ExpectChain<T> & (value: mixed) => ExpectChain<T>;

eql: (value: T) => ExpectChain<T>;
equal: (value: T) => ExpectChain<T>;
equals: (value: T) => ExpectChain<T>;

above: (value: T & number) => ExpectChain<T>;
least: (value: T & number) => ExpectChain<T>;
below: (value: T & number) => ExpectChain<T>;
most: (value: T & number) => ExpectChain<T>;
within: (start: T & number, finish: T & number) => ExpectChain<T>;

instanceof: (constructor: mixed) => ExpectChain<T>;

property: (
<P>(name: string, value?: P) => ExpectChain<P>
& (name: string) => ExpectChain<mixed>
);

length: ExpectChain<number>;
lengthOf: (value: number) => ExpectChain<T>;

match: (regex: RegExp) => ExpectChain<T>;
string: (string: string) => ExpectChain<T>;

key: (key: string) => ExpectChain<T>;

keys: (
key: string | Array<string>,
...keys: Array<string>
) => ExpectChain<T>;

throw: <E>(
err: Class<E> | Error | RegExp | string,
msg?: RegExp | string
) => ExpectChain<T>;

respondTo: (method: string) => ExpectChain<T>;
itself: ExpectChain<T>;

satisfy: (method: (value: T) => bool) => ExpectChain<T>;

closeTo: (expected: T & number, delta: number) => ExpectChain<T>;

members: (set: mixed) => ExpectChain<T>;
oneOf: (list: Array<T>) => ExpectChain<T>;

change: (obj: mixed, key: string) => ExpectChain<T>;
increase: (obj: mixed, key: string) => ExpectChain<T>;
decrease: (obj: mixed, key: string) => ExpectChain<T>;

// dirty-chai
ok: () => ExpectChain<T>;
true: () => ExpectChain<T>;
false: () => ExpectChain<T>;
null: () => ExpectChain<T>;
undefined: () => ExpectChain<T>;
exist: () => ExpectChain<T>;
empty: () => ExpectChain<T>;

// chai-immutable
size: (n: number) => ExpectChain<T>;

// sinon-chai
called: () => ExpectChain<T>;
callCount: (n: number) => ExpectChain<T>;
calledOnce: () => ExpectChain<T>;
calledBefore: (spy: mixed) => ExpectChain<T>;
calledAfter: (spy: mixed) => ExpectChain<T>;
calledWith: (...args: Array<mixed>) => ExpectChain<T>;
calledWithMatch: (...args: Array<mixed>) => ExpectChain<T>;
calledWithExactly: (...args: Array<mixed>) => ExpectChain<T>;
};

declare function expect<T>(actual: T): ExpectChain<T>;

declare function use(plugin: (chai: Object, utils: Object) => void): void;

declare var config: {
includeStack: boolean;
showDiff: boolean;
truncateThreshold: boolean;
};
}
26 changes: 26 additions & 0 deletions decl/mocha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// @flow
// src: github.com/flowtype/flow-typed/tree/master/definitions/npm/mocha_v2.4.x
type $npm$mocha$testFunction = (done: () => void) => void | Promise<mixed>;

declare module 'mocha' {
declare var describe: {
(name: string, spec: () => void): void;
only(description: string, spec: () => void): void;
skip(description: string, spec: () => void): void;
timeout(ms: number): void;
};

declare var context: typeof describe;

declare var it: {
(name: string, spec?: $npm$mocha$testFunction): void;
only(description: string, spec: $npm$mocha$testFunction): void;
skip(description: string, spec: $npm$mocha$testFunction): void;
timeout(ms: number): void;
};

declare function before(method: $npm$mocha$testFunction): void;
declare function beforeEach(method: $npm$mocha$testFunction): void;
declare function after(method: $npm$mocha$testFunction): void;
declare function afterEach(method: $npm$mocha$testFunction): void;
}
56 changes: 56 additions & 0 deletions decl/node-fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// @flow
declare module 'node-fetch' {
declare var exports: (url: string, options?: {
body?: any;
referrer?: string;
integrity?: string;

mode?:
| 'cors'
| 'no-cors'
| 'same-origin';

cache?:
| 'default'
| 'no-store'
| 'reload'
| 'no-cache'
| 'force-cache'
| 'only-if-cached';

method?:
| 'GET'
| 'HEAD'
| 'OPTIONS'
| 'PATCH'
| 'POST'
| 'DELETE';

headers?: {
[key: string]: string;
};

redirect?:
| 'follow'
| 'manual'
| 'error';

credentials?:
| 'omit'
| 'include'
| 'same-origin';

referrerPolicy?:
| 'no-referrer'
| 'no-referrer-when-downgrade'
| 'origin'
| 'origin-when-cross-origin'
| 'unsafe-url';
}) => Promise<{
status: number;
headers: Map<string, string>;

text(): Promise<string>;
json(): Promise<Object>;
}>;
}
11 changes: 11 additions & 0 deletions decl/sinon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @flow

declare module 'sinon' {
declare type Spy = {
calledWith: (...args: Array<any>) => boolean;
calledOnce: boolean;
restore: () => void;
reset: () => void;
};
declare function spy(module: Object, method: string): Spy;
}
49 changes: 34 additions & 15 deletions lib/babel-hook.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
'use strict';

// Require this module to use code in the /src dir prior to transpilation.
/***************************************************************************
* Require this module to use code in the /src dir prior to transpilation. *
***************************************************************************/

const plugins = (...items) => items.concat([
'syntax-flow',
'syntax-trailing-function-commas',
'transform-async-to-generator',
'transform-class-properties',
'transform-es2015-destructuring',
'transform-es2015-parameters',
'transform-es2015-spread',
'transform-exponentiation-operator',
'transform-flow-strip-types',
'transform-object-rest-spread',
'transform-es2015-modules-commonjs'
]);

require('babel-register')({
babelrc: false,

plugins: [
'syntax-flow',
'syntax-trailing-function-commas',
'transform-async-to-generator',
'transform-class-properties',
'transform-es2015-destructuring',
'transform-es2015-parameters',
'transform-es2015-spread',
'transform-exponentiation-operator',
'transform-flow-strip-types',
'transform-object-rest-spread',
'transform-es2015-modules-commonjs'
]
plugins: plugins(),
env: {
test: {
sourceMaps: 'inline',
plugins: plugins(['istanbul', {
include: [
'src/**/*.js'
],
exclude: [
'**/test',
'**/errors',
'**/interfaces.js'
]
}])
}
}
});
Loading