| 1 |
import Helper, { states } from "./_helper"; |
| 2 |
|
| 3 |
describe("External | Shared | ORM | Belongs To | One-way Polymorphic | accessor", () => { |
| 4 |
let helper; |
| 5 |
beforeEach(() => { |
| 6 |
helper = new Helper(); |
| 7 |
}); |
| 8 |
afterEach(() => { |
| 9 |
helper.shutdown(); |
| 10 |
}); |
| 11 |
|
| 12 |
/* |
| 13 |
The reference to a belongs-to association is correct, for all states |
| 14 |
*/ |
| 15 |
states.forEach((state) => { |
| 16 |
test(`the references of a ${state} are correct`, () => { |
| 17 |
let [comment, post] = helper[state](); |
| 18 |
|
| 19 |
expect(comment.commentable).toEqual(post ? post : null); |
| 20 |
expect(comment.commentableId).toEqual( |
| 21 |
post ? { id: post.id, type: "post" } : null |
| 22 |
); |
| 23 |
}); |
| 24 |
}); |
| 25 |
}); |