Skip to content

Commit

Permalink
docs: factory - fix traits example
Browse files Browse the repository at this point in the history
The code snippet changed in this PR is described with the following text `Here we define a withComments trait that creates 3 comments for a newly created post:`

Creating a post requires having a factory on the path `mirage/factories/post.js` as opposed to `mirage/factories/user.js`

Also to keep it consistent with the rest of the examples where posts have a property called `title`, as opposed to `name`, I went ahead and updated the `name` property on the factory to be `title`.
  • Loading branch information
canrozanes authored Apr 29, 2021
1 parent b24f066 commit 3e2a6bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/dummy/app/pods/docs/data-layer/factories/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,11 @@ When combined with the `afterCreate()` hook, traits simplify the process of sett
Here we define a `withComments` trait that creates 3 comments for a newly created post:

``` js
// mirage/factories/user.js
// mirage/factories/post.js
import { Factory, trait } from 'ember-cli-mirage';

export default Factory.extend({
name: 'Lorem ipsum',
title: 'Lorem ipsum',

withComments: trait({
afterCreate(post, server) {
Expand Down

0 comments on commit 3e2a6bb

Please sign in to comment.