Debian Codegraph @

__tests__/external/shared/orm/has-many/6-one-way-reflexive/association-create-test.js

raw
1 import Helper, { states } from "./_helper";
2
3 describe("External | Shared | ORM | Has Many | One-Way Reflexive | association #create", () => {
4 let helper;
5 beforeEach(() => {
6 helper = new Helper();
7 });
8 afterEach(() => {
9 helper.shutdown();
10 });
11
12 /*
13 The model can create a has-many association, for all states
14 */
15 states.forEach((state) => {
16 test(`a ${state} can create an associated child`, () => {
17 let [tag] = helper[state]();
18 let initialCount = tag.tags.models.length;
19
20 let orangeTag = tag.createTag({ name: "Orange" });
21
22 expect(orangeTag.id).toBeTruthy();
23 expect(tag.tags.models).toHaveLength(initialCount + 1);
24 expect(tag.tags.includes(orangeTag)).toBeTruthy();
25 expect(tag.tagIds.indexOf(orangeTag.id) > -1).toBeTruthy();
26 expect(tag.attrs.tagIds.indexOf(orangeTag.id) > -1).toBeTruthy();
27 expect(orangeTag.tags.includes(tag)).toBeFalsy();
28 });
29 });
30 });