Debian Codegraph @

__tests__/external/shared/orm/belongs-to/regressions/pr-1312-test.js

raw
1 import { Server, Model, belongsTo, hasMany } from "miragejs";
2
3 describe("External | Shared | ORM | Belongs To | Regressions | pr-1312", function () {
4 test(`creating and using a record with a polymorphic hasMany and explicit inverse does not fail when accessing the association`, () => {
5 let server = new Server({
6 environment: "test",
7 models: {
8 comment: Model.extend({
9 commentable: belongsTo({ polymorphic: true, inverse: "comments" }),
10 }),
11
12 post: Model.extend({
13 comments: hasMany("comment", { inverse: "commentable" }),
14 }),
15 },
16 });
17
18 let post = server.schema.posts.create();
19 post.createComment();
20
21 expect(post.comments.models).toHaveLength(1);
22 });
23 });