mirror of
https://github.com/bringout/oca-ocb-web.git
synced 2026-04-18 22:32:02 +02:00
web_editor was removed in Odoo 19.0 and replaced by html_editor
and html_builder. The old web_editor was incorrectly included in
the 19.0 vanilla import.
🤖 assisted by claude
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
import {
|
|
after,
|
|
before,
|
|
BEGIN,
|
|
END,
|
|
SNIPPET_SPECIFIC,
|
|
splitBetween,
|
|
} from "@html_builder/utils/option_sequence";
|
|
import { expect, test } from "@odoo/hoot";
|
|
|
|
const ARBITRARY_FAKE_POSITION = 7777777777;
|
|
|
|
test("before throws if position doesn't exist", async () => {
|
|
expect(() => before(ARBITRARY_FAKE_POSITION)).toThrow();
|
|
});
|
|
|
|
test("before throws if position is BEGIN", async () => {
|
|
expect(() => before(BEGIN)).toThrow();
|
|
});
|
|
|
|
test("before returns a smaller position", async () => {
|
|
expect(before(SNIPPET_SPECIFIC)).toBeLessThan(SNIPPET_SPECIFIC);
|
|
expect(before(END)).toBeLessThan(END);
|
|
});
|
|
|
|
test("after throws if position doesn't exist", async () => {
|
|
expect(() => after(ARBITRARY_FAKE_POSITION)).toThrow();
|
|
});
|
|
|
|
test("after throws if position is END", async () => {
|
|
expect(() => after(END)).toThrow();
|
|
});
|
|
|
|
test("after returns a bigger position", async () => {
|
|
expect(after(SNIPPET_SPECIFIC)).toBeGreaterThan(SNIPPET_SPECIFIC);
|
|
expect(after(BEGIN)).toBeGreaterThan(BEGIN);
|
|
});
|
|
|
|
test("splitBetween correctly splits to the right values", async () => {
|
|
expect(splitBetween(0, 3, 2)).toMatch([1, 2]);
|
|
expect(splitBetween(0, 10, 2)).toMatch([10 / 3, (2 * 10) / 3]);
|
|
expect(splitBetween(0, 8, 7)).toMatch([1, 2, 3, 4, 5, 6, 7]);
|
|
expect(splitBetween(1, 5, 3)).toMatch([2, 3, 4]);
|
|
});
|