| 1 |
import Helper, { states } from "./_helper"; |
| 2 |
|
| 3 |
describe("External | Shared | ORM | Belongs To | Named One-Way Reflexive | 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 [user, parent] = helper[state](); |
| 18 |
|
| 19 |
// We use .attrs here to avoid infinite recursion |
| 20 |
if (parent) { |
| 21 |
expect(user.parent.attrs).toEqual(parent.attrs); |
| 22 |
expect(user.parentId).toEqual(parent.id); |
| 23 |
} else { |
| 24 |
expect(user.parent).toBeNil(); |
| 25 |
expect(user.parentId).toBeNil(); |
| 26 |
} |
| 27 |
}); |
| 28 |
}); |
| 29 |
}); |