Skip to content

Commit 4e25470

Browse files
committed
Merge branch 'release/1.2.3'
2 parents 7620790 + a2ae043 commit 4e25470

9 files changed

+7764
-3650
lines changed

.circleci/config.yml

+1-9
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ jobs:
1414

1515
- run:
1616
name: Install global packages
17-
command: sudo npm install -g codecov greenkeeper-lockfile@1
18-
19-
- run:
20-
name: Greenkeeper Lockfile
21-
command: greenkeeper-lockfile-update
17+
command: sudo npm install -g codecov
2218

2319
- run:
2420
name: Install dependencies
@@ -42,10 +38,6 @@ jobs:
4238
# name: Mutation Tests
4339
# command: npm run test:mutants
4440

45-
- run:
46-
name: Push any lockfile changes
47-
command: greenkeeper-lockfile-upload
48-
4941
- run:
5042
name: Send reports to codecov.io
5143
command: codecov

.snyk

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
2+
version: v1.14.1
3+
ignore: {}
4+
patch: {}

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,13 @@ By default `makeMockModels` and `listModels` will both look for your models in f
386386

387387
## Development
388388

389-
[![Greenkeeper badge](https://badges.greenkeeper.io/davesag/sequelize-test-helpers.svg)](https://greenkeeper.io/)
390-
391-
## Branches
389+
### Branches
392390

393391
<!-- prettier-ignore -->
394-
| Branch | Status | Coverage | |
395-
| ------ | ------ | -------- | - |
396-
| `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 |
397-
| `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 |
392+
| Branch | Status | Coverage | Audit | Notes |
393+
| ------ | ------ | -------- | ----- | ----- |
394+
| `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 |
395+
| `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 |
398396

399397
### Prerequisites
400398

package-lock.json

+7,672-3,598
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+29-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sequelize-test-helpers",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"description": "A collection of utilities to help with unit-testing sequelize models",
55
"author": "Dave Sag <[email protected]>",
66
"type": "commonjs",
@@ -29,7 +29,8 @@
2929
"test": "npm run test:unit",
3030
"test:unit": "NODE_ENV=test mocha ./test/unit/ --require ./test/unitTestHelper.js --recursive",
3131
"test:unit:cov": "NODE_ENV=test nyc mocha ./test/unit/ --require ./test/unitTestHelper.js --recursive",
32-
"test:mutants": "NODE_ENV=test npx stryker run"
32+
"test:mutants": "NODE_ENV=test npx stryker run",
33+
"snyk-protect": "snyk protect"
3334
},
3435
"repository": {
3536
"type": "git",
@@ -49,30 +50,31 @@
4950
"chai"
5051
],
5152
"devDependencies": {
52-
"@stryker-mutator/core": "^2.4.0",
53-
"@stryker-mutator/javascript-mutator": "^2.4.0",
54-
"@stryker-mutator/mocha-framework": "^2.4.0",
55-
"@stryker-mutator/mocha-runner": "^2.4.0",
56-
"ajv": "^6.10.2",
53+
"@stryker-mutator/core": "^3.3.1",
54+
"@stryker-mutator/javascript-mutator": "^3.3.1",
55+
"@stryker-mutator/mocha-framework": "^3.3.1",
56+
"@stryker-mutator/mocha-runner": "^3.3.1",
57+
"ajv": "^6.12.3",
5758
"chai": "^4.2.0",
5859
"chai-as-promised": "^7.1.1",
59-
"eslint": "^6.8.0",
60-
"eslint-config-prettier": "^6.9.0",
61-
"eslint-config-standard": "^14.1.0",
62-
"eslint-plugin-import": "^2.19.1",
63-
"eslint-plugin-mocha": "^6.2.2",
64-
"eslint-plugin-node": "^11.0.0",
65-
"eslint-plugin-prettier": "^3.1.2",
60+
"eslint": "^7.4.0",
61+
"eslint-config-prettier": "^6.11.0",
62+
"eslint-config-standard": "^14.1.1",
63+
"eslint-plugin-import": "^2.22.0",
64+
"eslint-plugin-mocha": "^7.0.1",
65+
"eslint-plugin-node": "^11.1.0",
66+
"eslint-plugin-prettier": "^3.1.4",
6667
"eslint-plugin-promise": "^4.2.1",
6768
"eslint-plugin-standard": "^4.0.1",
68-
"husky": "^3.1.0",
69-
"lint-staged": "^9.5.0",
70-
"mocha": "^6.2.2",
71-
"nyc": "^15.0.0",
72-
"prettier": "^1.19.1",
69+
"husky": "^4.2.5",
70+
"lint-staged": "^10.2.11",
71+
"mocha": "^8.0.1",
72+
"nyc": "^15.1.0",
73+
"prettier": "^2.0.5",
7374
"proxyquire": "^2.1.3",
74-
"sinon": "^8.0.1",
75-
"sinon-chai": "^3.4.0"
75+
"sinon": "^9.0.2",
76+
"sinon-chai": "^3.5.0",
77+
"snyk": "^1.360.0"
7678
},
7779
"peerDependencies": {
7880
"chai": ">= 4",
@@ -81,12 +83,13 @@
8183
"prettier": {
8284
"semi": false,
8385
"singleQuote": true,
84-
"proseWrap": "never"
86+
"proseWrap": "never",
87+
"arrowParens": "avoid",
88+
"trailingComma": "none"
8589
},
8690
"lint-staged": {
8791
"**/*.{js,json,md}": [
88-
"prettier --write",
89-
"git add"
92+
"prettier --write"
9093
]
9194
},
9295
"husky": {
@@ -113,5 +116,6 @@
113116
],
114117
"all": true,
115118
"cache": true
116-
}
119+
},
120+
"snyk": true
117121
}

src/constants/staticModelMethods.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const syncMethods = [
2+
'addScope',
3+
'belongsTo',
4+
'belongsToMany',
5+
'build',
6+
'getTableName',
7+
'hasMany',
8+
'hasOne',
9+
'init',
10+
'removeAttribute',
11+
'schema',
12+
'scope',
13+
'unscoped'
14+
]
15+
16+
const asyncMethods = [
17+
'aggregate',
18+
'bulkCreate',
19+
'count',
20+
'create',
21+
'decrement',
22+
'describe',
23+
'destroy',
24+
'drop',
25+
'findAll',
26+
'findAndCountAll',
27+
'findByPk',
28+
'findCreateFind',
29+
'findOne',
30+
'findOrBuild',
31+
'findOrCreate',
32+
'increment',
33+
'max',
34+
'min',
35+
'restore',
36+
'sum',
37+
'sync',
38+
'truncate',
39+
'update',
40+
'upsert'
41+
]
42+
43+
module.exports = { syncMethods, asyncMethods }

src/mockModels.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ const listToObject = (acc, elem) => {
3030
const listModels = (
3131
/* istanbul ignore next */ folder = DEFAULT_MODELS_FOLDER,
3232
suffix = DEFAULT_SUFFIX
33-
) =>
34-
fs
35-
.readdirSync(folder)
36-
.filter(fileFilter(suffix))
37-
.map(makeName(suffix))
33+
) => fs.readdirSync(folder).filter(fileFilter(suffix)).map(makeName(suffix))
3834

3935
const finder = (folder, suffix) =>
4036
listModels(folder, suffix).reduce(listToObject, {})

src/sequelize.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
const sinon = require('sinon')
22
const hooks = require('./constants/hooks')
33
const staticMethods = require('./constants/staticMethods')
4+
const { syncMethods, asyncMethods } = require('./constants/staticModelMethods')
45

56
const sequelize = {
67
define: (modelName, modelDefn, metaData = {}) => {
7-
const model = function() {}
8+
const model = function () {}
89
model.modelName = modelName
910

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

21+
const addStatic = key => {
22+
model[key] = sinon.stub()
23+
}
24+
2025
hooks.forEach(hook => {
2126
model[hook] = attachHook(hook)
2227
})
@@ -28,10 +33,8 @@ const sequelize = {
2833

2934
model.hook = model.addHook
3035

31-
model.belongsToMany = sinon.spy()
32-
model.belongsTo = sinon.spy()
33-
model.hasMany = sinon.spy()
34-
model.hasOne = sinon.spy()
36+
syncMethods.forEach(addStatic)
37+
asyncMethods.forEach(addStatic)
3538

3639
model.isHierarchy = sinon.spy()
3740

stryker.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function(config) {
1+
module.exports = function (config) {
22
config.set({
33
mutate: ['src/**/*.js', '!src/checks/check*.js', '!src/mockModels.js'],
44
mutator: 'javascript',

0 commit comments

Comments
 (0)