Skip to content

Commit

Permalink
Merge branch 'release/1.2.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
davesag committed Jul 7, 2020
2 parents 7620790 + a2ae043 commit 4e25470
Show file tree
Hide file tree
Showing 9 changed files with 7,764 additions and 3,650 deletions.
10 changes: 1 addition & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ jobs:

- run:
name: Install global packages
command: sudo npm install -g codecov greenkeeper-lockfile@1

- run:
name: Greenkeeper Lockfile
command: greenkeeper-lockfile-update
command: sudo npm install -g codecov

- run:
name: Install dependencies
Expand All @@ -42,10 +38,6 @@ jobs:
# name: Mutation Tests
# command: npm run test:mutants

- run:
name: Push any lockfile changes
command: greenkeeper-lockfile-upload

- run:
name: Send reports to codecov.io
command: codecov
4 changes: 4 additions & 0 deletions .snyk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.14.1
ignore: {}
patch: {}
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,13 @@ By default `makeMockModels` and `listModels` will both look for your models in f

## Development

[![Greenkeeper badge](https://badges.greenkeeper.io/davesag/sequelize-test-helpers.svg)](https://greenkeeper.io/)

## Branches
### Branches

<!-- prettier-ignore -->
| Branch | Status | Coverage | |
| ------ | ------ | -------- | - |
| `develop` | [![CircleCI](https://circleci.com/gh/davesag/sequelize-test-helpers/tree/develop.svg?style=svg)](https://circleci.com/gh/davesag/sequelize-test-helpers/tree/develop) | [![codecov](https://codecov.io/gh/davesag/sequelize-test-helpers/branch/develop/graph/badge.svg)](https://codecov.io/gh/davesag/sequelize-test-helpers) | Work in progress |
| `master` | [![CircleCI](https://circleci.com/gh/davesag/sequelize-test-helpers/tree/master.svg?style=svg)](https://circleci.com/gh/davesag/sequelize-test-helpers/tree/master) | [![codecov](https://codecov.io/gh/davesag/sequelize-test-helpers/branch/master/graph/badge.svg)](https://codecov.io/gh/davesag/sequelize-test-helpers) | Latest stable release |
| Branch | Status | Coverage | Audit | Notes |
| ------ | ------ | -------- | ----- | ----- |
| `develop` | [![CircleCI](https://circleci.com/gh/davesag/sequelize-test-helpers/tree/develop.svg?style=svg)](https://circleci.com/gh/davesag/sequelize-test-helpers/tree/develop) | [![codecov](https://codecov.io/gh/davesag/sequelize-test-helpers/branch/develop/graph/badge.svg)](https://codecov.io/gh/davesag/sequelize-test-helpers) | [![Vulnerabilities](https://snyk.io/test/github/davesag/sequelize-test-helpers/develop/badge.svg)](https://snyk.io/test/github/davesag/sequelize-test-helpers/develop) | Work in progress |
| `master` | [![CircleCI](https://circleci.com/gh/davesag/sequelize-test-helpers/tree/master.svg?style=svg)](https://circleci.com/gh/davesag/sequelize-test-helpers/tree/master) | [![codecov](https://codecov.io/gh/davesag/sequelize-test-helpers/branch/master/graph/badge.svg)](https://codecov.io/gh/davesag/sequelize-test-helpers) | [![Vulnerabilities](https://snyk.io/test/github/davesag/sequelize-test-helpers/master/badge.svg)](https://snyk.io/test/github/davesag/sequelize-test-helpers/master) | Latest stable release |

### Prerequisites

Expand Down
11,270 changes: 7,672 additions & 3,598 deletions package-lock.json

Large diffs are not rendered by default.

54 changes: 29 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sequelize-test-helpers",
"version": "1.2.2",
"version": "1.2.3",
"description": "A collection of utilities to help with unit-testing sequelize models",
"author": "Dave Sag <[email protected]>",
"type": "commonjs",
Expand Down Expand Up @@ -29,7 +29,8 @@
"test": "npm run test:unit",
"test:unit": "NODE_ENV=test mocha ./test/unit/ --require ./test/unitTestHelper.js --recursive",
"test:unit:cov": "NODE_ENV=test nyc mocha ./test/unit/ --require ./test/unitTestHelper.js --recursive",
"test:mutants": "NODE_ENV=test npx stryker run"
"test:mutants": "NODE_ENV=test npx stryker run",
"snyk-protect": "snyk protect"
},
"repository": {
"type": "git",
Expand All @@ -49,30 +50,31 @@
"chai"
],
"devDependencies": {
"@stryker-mutator/core": "^2.4.0",
"@stryker-mutator/javascript-mutator": "^2.4.0",
"@stryker-mutator/mocha-framework": "^2.4.0",
"@stryker-mutator/mocha-runner": "^2.4.0",
"ajv": "^6.10.2",
"@stryker-mutator/core": "^3.3.1",
"@stryker-mutator/javascript-mutator": "^3.3.1",
"@stryker-mutator/mocha-framework": "^3.3.1",
"@stryker-mutator/mocha-runner": "^3.3.1",
"ajv": "^6.12.3",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.9.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-mocha": "^6.2.2",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint": "^7.4.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-mocha": "^7.0.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"husky": "^3.1.0",
"lint-staged": "^9.5.0",
"mocha": "^6.2.2",
"nyc": "^15.0.0",
"prettier": "^1.19.1",
"husky": "^4.2.5",
"lint-staged": "^10.2.11",
"mocha": "^8.0.1",
"nyc": "^15.1.0",
"prettier": "^2.0.5",
"proxyquire": "^2.1.3",
"sinon": "^8.0.1",
"sinon-chai": "^3.4.0"
"sinon": "^9.0.2",
"sinon-chai": "^3.5.0",
"snyk": "^1.360.0"
},
"peerDependencies": {
"chai": ">= 4",
Expand All @@ -81,12 +83,13 @@
"prettier": {
"semi": false,
"singleQuote": true,
"proseWrap": "never"
"proseWrap": "never",
"arrowParens": "avoid",
"trailingComma": "none"
},
"lint-staged": {
"**/*.{js,json,md}": [
"prettier --write",
"git add"
"prettier --write"
]
},
"husky": {
Expand All @@ -113,5 +116,6 @@
],
"all": true,
"cache": true
}
},
"snyk": true
}
43 changes: 43 additions & 0 deletions src/constants/staticModelMethods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const syncMethods = [
'addScope',
'belongsTo',
'belongsToMany',
'build',
'getTableName',
'hasMany',
'hasOne',
'init',
'removeAttribute',
'schema',
'scope',
'unscoped'
]

const asyncMethods = [
'aggregate',
'bulkCreate',
'count',
'create',
'decrement',
'describe',
'destroy',
'drop',
'findAll',
'findAndCountAll',
'findByPk',
'findCreateFind',
'findOne',
'findOrBuild',
'findOrCreate',
'increment',
'max',
'min',
'restore',
'sum',
'sync',
'truncate',
'update',
'upsert'
]

module.exports = { syncMethods, asyncMethods }
6 changes: 1 addition & 5 deletions src/mockModels.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ const listToObject = (acc, elem) => {
const listModels = (
/* istanbul ignore next */ folder = DEFAULT_MODELS_FOLDER,
suffix = DEFAULT_SUFFIX
) =>
fs
.readdirSync(folder)
.filter(fileFilter(suffix))
.map(makeName(suffix))
) => fs.readdirSync(folder).filter(fileFilter(suffix)).map(makeName(suffix))

const finder = (folder, suffix) =>
listModels(folder, suffix).reduce(listToObject, {})
Expand Down
13 changes: 8 additions & 5 deletions src/sequelize.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const sinon = require('sinon')
const hooks = require('./constants/hooks')
const staticMethods = require('./constants/staticMethods')
const { syncMethods, asyncMethods } = require('./constants/staticModelMethods')

const sequelize = {
define: (modelName, modelDefn, metaData = {}) => {
const model = function() {}
const model = function () {}
model.modelName = modelName

const attachHook = name => hook => {
Expand All @@ -17,6 +18,10 @@ const sequelize = {
model.prototype[key] = modelDefn[key]
}

const addStatic = key => {
model[key] = sinon.stub()
}

hooks.forEach(hook => {
model[hook] = attachHook(hook)
})
Expand All @@ -28,10 +33,8 @@ const sequelize = {

model.hook = model.addHook

model.belongsToMany = sinon.spy()
model.belongsTo = sinon.spy()
model.hasMany = sinon.spy()
model.hasOne = sinon.spy()
syncMethods.forEach(addStatic)
asyncMethods.forEach(addStatic)

model.isHierarchy = sinon.spy()

Expand Down
2 changes: 1 addition & 1 deletion stryker.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function(config) {
module.exports = function (config) {
config.set({
mutate: ['src/**/*.js', '!src/checks/check*.js', '!src/mockModels.js'],
mutator: 'javascript',
Expand Down

0 comments on commit 4e25470

Please sign in to comment.