Debian Codegraph @

__tests__/external/shared/orm/belongs-to/8-one-to-one/association-set-id-test.js

raw
1 import Helper, { states } from "./_helper";
2
3 describe("External | Shared | ORM | Belongs To | One To One | association #setId", () => {
4 let helper;
5 beforeEach(() => {
6 helper = new Helper();
7 });
8 afterEach(() => {
9 helper.shutdown();
10 });
11
12 /*
13 The model can update its association via parentId, for all states
14 */
15 states.forEach((state) => {
16 test(`a ${state} can update its association to a saved parent via parentId`, () => {
17 let [user] = helper[state]();
18 let profile = helper.savedParent();
19
20 user.profileId = profile.id;
21
22 expect(user.profileId).toEqual(profile.id);
23 expect(user.profile.attrs).toEqual(profile.attrs);
24
25 user.save();
26 profile.reload();
27
28 expect(profile.userId).toEqual(user.id);
29 expect(profile.user.attrs).toEqual(user.attrs);
30 });
31 });
32 });