Debian Codegraph @

__tests__/external/shared/orm/has-many/4-named-reflexive/association-create-test.js

raw
1 import Helper, { states } from "./_helper";
2
3 describe("External | Shared | ORM | Has Many | Named 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.labels.models.length;
19
20 let orangeTag = tag.createLabel({ name: "Orange" });
21
22 expect(orangeTag.id).toBeTruthy();
23 expect(tag.labels.models).toHaveLength(initialCount + 1);
24 expect(tag.labels.includes(orangeTag)).toBeTruthy();
25 expect(tag.labelIds.indexOf(orangeTag.id) > -1).toBeTruthy();
26 expect(tag.attrs.labelIds.indexOf(orangeTag.id) > -1).toBeTruthy();
27 expect(orangeTag.labels.includes(tag)).toBeTruthy();
28 });
29 });
30 });