| 1 |
import Helper, { states } from "./_helper"; |
| 2 |
|
| 3 |
describe("External | Shared | ORM | Has Many | Named Reflexive | accessor", () => { |
| 4 |
let helper; |
| 5 |
beforeEach(() => { |
| 6 |
helper = new Helper(); |
| 7 |
}); |
| 8 |
afterEach(() => { |
| 9 |
helper.shutdown(); |
| 10 |
}); |
| 11 |
|
| 12 |
states.forEach((state) => { |
| 13 |
test(`the references of a ${state} are correct`, () => { |
| 14 |
let [tag, tags] = helper[state](); |
| 15 |
|
| 16 |
expect(tag.labels.models).toHaveLength(tags.length); |
| 17 |
expect(tag.labelIds).toHaveLength(tags.length); |
| 18 |
|
| 19 |
tags.forEach((t) => { |
| 20 |
expect(tag.labels.includes(t)).toBeTruthy(); |
| 21 |
|
| 22 |
if (t.isSaved()) { |
| 23 |
expect(tag.labelIds.indexOf(t.id) > -1).toBeTruthy(); |
| 24 |
} |
| 25 |
|
| 26 |
// Check the inverse |
| 27 |
expect(t.labels.includes(tag)).toBeTruthy(); |
| 28 |
}); |
| 29 |
}); |
| 30 |
}); |
| 31 |
}); |