diff --git a/README.md b/README.md index 1e942c3..cc6699d 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ This library assumes: Add `sequelize-test-helpers` as a `devDependency`: -``` +```sh npm i -D sequelize-test-helpers ``` @@ -43,7 +43,7 @@ Let's say you have a Sequelize model `User` as follows: #### `src/models/User.js` -``` +```js const model = (sequelize, DataTypes) => { const User = sequelize.define( 'User', @@ -104,7 +104,7 @@ You can use `sequelize-test-helpers` to unit-test this as follows: #### `test/unit/models/User.spec.js` -``` +```js const { expect } = require('chai') const { @@ -124,13 +124,9 @@ describe('src/models/User', () => { checkModelName(User)('User') context('properties', () => { - ;[ - 'age', - 'firstname', - 'lastname', - 'email', - 'token' - ].forEach(checkPropertyExists(user)) + ;['age', 'firstname', 'lastname', 'email', 'token'].forEach( + checkPropertyExists(user) + ) }) context('associations', () => { @@ -169,7 +165,7 @@ The various association functions are stubbed so you can simply invoke the the m #### `hasOne` -``` +```js it("defined a hasOne association with Image as 'profilePic'", () => { expect(User.hasOne).to.have.been.calledWith(Image, { as: 'profilePic' @@ -179,7 +175,7 @@ it("defined a hasOne association with Image as 'profilePic'", () => { #### `belongsTo` -``` +```js it('defined a belongsTo association with Company', () => { expect(User.belongsTo).to.have.been.calledWith(Company) }) @@ -187,7 +183,7 @@ it('defined a belongsTo association with Company', () => { #### `hasMany` -``` +```js it("defined a hasMany association with User as 'employees'", () => { expect(Company.hasMany).to.have.been.calledWith(User, { as: 'employees' @@ -197,7 +193,7 @@ it("defined a hasMany association with User as 'employees'", () => { #### `belongsToMany` -``` +```js it("defined a belongsToMany association with Category through CategoriesCompanies as 'categories'", () => { expect(Company.belongsToMany).to.have.been.calledWith(Category, { through: CategoriesCompanies, @@ -212,7 +208,7 @@ Let's say you have a utility function that takes some data and uses it to update #### `src/utils/save.js` -``` +```js const { User } = require('../models') const save = async ({ id, ...data }) => { @@ -230,7 +226,7 @@ This is where `makeMockModels`, `sinon`, and [`proxyquire`](https://github.com/t #### `test/unit/utils/save.spec.js` -``` +```js const { expect } = require('chai') const { match, stub } = require('sinon') const proxyquire = require('proxyquire') @@ -309,7 +305,7 @@ As a convenience, `makeMockModels` will automatically populate your `mockModels` It's useful to be able to generate a list of the names of your models. -``` +```js const { listModels } = require('sequelize-test-helpers') console.log(listModels()) // will spit out a list of your model names. diff --git a/package-lock.json b/package-lock.json index 0699009..c40fc9d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -255,6 +255,16 @@ "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", "dev": true }, + "array-includes": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", + "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.7.0" + } + }, "array-union": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", @@ -1098,11 +1108,12 @@ } }, "eslint-plugin-import": { - "version": "2.16.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.16.0.tgz", - "integrity": "sha512-z6oqWlf1x5GkHIFgrSvtmudnqM6Q60KM4KvpWi5ubonMjycLjndvd5+8VAZIsTlHC03djdgJuyKG6XO577px6A==", + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.17.0.tgz", + "integrity": "sha512-JCsOtNwPYUoeZPlSr8t0+uCU5OVlHh+dIBn8Rw7FiOPjCECG+QzDIKDqshbyJE6CYoj9wpcstEl8vUY7rXkqVA==", "dev": true, "requires": { + "array-includes": "^3.0.3", "contains-path": "^0.1.0", "debug": "^2.6.9", "doctrine": "1.5.0", @@ -1112,7 +1123,7 @@ "lodash": "^4.17.11", "minimatch": "^3.0.4", "read-pkg-up": "^2.0.0", - "resolve": "^1.9.0" + "resolve": "^1.10.0" }, "dependencies": { "debug": { @@ -4288,9 +4299,9 @@ "dev": true }, "prettier": { - "version": "1.16.4", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.16.4.tgz", - "integrity": "sha512-ZzWuos7TI5CKUeQAtFd6Zhm2s6EpAD/ZLApIhsF9pRvRtM1RFo61dM/4MSRUA0SuLugA/zgrZD8m0BaY46Og7g==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.17.0.tgz", + "integrity": "sha512-sXe5lSt2WQlCbydGETgfm1YBShgOX4HxQkFPvbxkcwgDvGDeqVau8h+12+lmSVlP3rHPz0oavfddSZg/q+Szjw==", "dev": true }, "prettier-linter-helpers": { diff --git a/package.json b/package.json index d0f608b..8b2ab9c 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "eslint": "^5.16.0", "eslint-config-prettier": "^4.1.0", "eslint-config-standard": "^12.0.0", - "eslint-plugin-import": "^2.16.0", + "eslint-plugin-import": "^2.17.0", "eslint-plugin-mocha": "^5.3.0", "eslint-plugin-node": "^8.0.1", "eslint-plugin-prettier": "^3.0.1", @@ -54,7 +54,7 @@ "lint-staged": "^8.1.5", "mocha": "^6.1.3", "nyc": "^13.3.0", - "prettier": "^1.16.4", + "prettier": "^1.17.0", "proxyquire": "^2.1.0", "sinon": "^7.3.1", "sinon-chai": "^3.3.0"