Skip to content

Commit

Permalink
Merge pull request #124 from joelnet/story/commit-hooks
Browse files Browse the repository at this point in the history
add git hooks
  • Loading branch information
joelnet committed Oct 3, 2018
2 parents dcdd007 + 10e8e76 commit 11ee9cc
Show file tree
Hide file tree
Showing 4 changed files with 297 additions and 5 deletions.
163 changes: 163 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"eslint-plugin-fp": "^2.3.0",
"eslint-plugin-prefer-arrow": "^1.1.2",
"eslint-watch": "^4.0.2",
"husky": "^1.1.0",
"jest": "^23.5.0",
"sanctuary": "^0.15.0"
},
Expand All @@ -38,6 +39,20 @@
"collectCoverageFrom": [
"**/*.{js,jsx,mjs}",
"!coverage/**"
]
],
"coverageThreshold": {
"global": {
"statements": 100,
"branches": 100,
"functions": 100,
"lines": 100
}
}
},
"husky": {
"hooks": {
"pre-commit": "npm run test:coverage",
"pre-push": "npm run test:coverage"
}
}
}
116 changes: 115 additions & 1 deletion types/__tests__/is.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ describe('types/is', () => {
const actual = isBoolean(false)
expect(actual).toBe(expected)
})

test('null', () => {
const expected = false
const actual = isBoolean(null)
expect(actual).toBe(expected)
})
})

describe('function', () => {
describe('Function', () => {
const isFunction = is(Function)

test('function', () => {
Expand All @@ -37,5 +43,113 @@ describe('types/is', () => {
const actual = isFunction(jest.fn())
expect(actual).toBe(expected)
})

test('null', () => {
const expected = false
const actual = isFunction(null)
expect(actual).toBe(expected)
})
})

describe('Object', () => {
const isObject = is(Object)

test('Object', () => {
const expected = true
const actual = isObject({})
expect(actual).toBe(expected)
})

test('new Object', () => {
const expected = true
const actual = isObject(new Object())
expect(actual).toBe(expected)
})

test('null', () => {
const expected = false
const actual = isObject(null)
expect(actual).toBe(expected)
})
})

describe('String', () => {
const isString = is(String)

test('String', () => {
const expected = true
const actual = isString('abc')
expect(actual).toBe(expected)
})

test('empty String', () => {
const expected = true
const actual = isString('')
expect(actual).toBe(expected)
})

test('null', () => {
const expected = false
const actual = isString(null)
expect(actual).toBe(expected)
})
})

describe('Array', () => {
const isArray = is(Array)

test('Array', () => {
const expected = true
const actual = isArray([1, 2, 3])
expect(actual).toBe(expected)
})

test('empty Array', () => {
const expected = true
const actual = isArray([])
expect(actual).toBe(expected)
})

test('new Array', () => {
const expected = true
const actual = isArray(new Array())
expect(actual).toBe(expected)
})

test('null', () => {
const expected = false
const actual = isArray(null)
expect(actual).toBe(expected)
})
})

describe('Promise', () => {
const isPromise = is(Promise)

test('Promise.resolve()', () => {
const expected = true
const actual = isPromise(Promise.resolve())
expect(actual).toBe(expected)
})

test('Promise.reject()', () => {
const expected = true
const reject = Promise.reject()
const actual = isPromise(reject)
reject.catch(() => {}) // silence test errors
expect(actual).toBe(expected)
})

test('thenable', () => {
const expected = true
const actual = isPromise({ then: resolve => resolve() })
expect(actual).toBe(expected)
})

test('null', () => {
const expected = false
const actual = isPromise(null)
expect(actual).toBe(expected)
})
})
})
6 changes: 3 additions & 3 deletions types/is.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable */
const is = ctor => value =>
ctor === Function
? typeof value === 'function'
: value != null && value.constructor === ctor || value instanceof ctor
ctor === Function ? typeof value === 'function'
: value != null && is (Function) (value.then) ? true
: value != null && value.constructor === ctor || value instanceof ctor

module.exports = is

0 comments on commit 11ee9cc

Please sign in to comment.