Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
davesag committed Apr 14, 2019
2 parents 3698e37 + aa825e7 commit a7a90d8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 37 deletions.
30 changes: 13 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This library assumes:

Add `sequelize-test-helpers` as a `devDependency`:

```
```sh
npm i -D sequelize-test-helpers
```

Expand All @@ -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',
Expand Down Expand Up @@ -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 {
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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'
Expand All @@ -179,15 +175,15 @@ 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)
})
```

#### `hasMany`

```
```js
it("defined a hasMany association with User as 'employees'", () => {
expect(Company.hasMany).to.have.been.calledWith(User, {
as: 'employees'
Expand All @@ -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,
Expand All @@ -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 }) => {
Expand All @@ -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')
Expand Down Expand Up @@ -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.
Expand Down
52 changes: 36 additions & 16 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sequelize-test-helpers",
"version": "1.0.11",
"version": "1.1.0",
"description": "A collection of utilities to help with unit-testing sequelize models",
"author": "Dave Sag <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -44,17 +44,17 @@
"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",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"husky": "^1.3.1",
"lint-staged": "^8.1.5",
"mocha": "^6.1.1",
"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"
Expand Down

0 comments on commit a7a90d8

Please sign in to comment.