2022-10-13 23:27:46 +00:00
|
|
|
|
|
|
|
// Exclusivo de un unico dia
|
2022-10-14 17:05:15 +00:00
|
|
|
import { GrupoDia, TableInput } from "../src/Views/SistemasMovil/Table";
|
|
|
|
import { generarMapaCeldas, MapaCeldas } from "../src/Views/SistemasMovil/mapaCeldas";
|
2022-10-13 23:27:46 +00:00
|
|
|
|
2022-10-14 17:05:15 +00:00
|
|
|
type Input = {
|
|
|
|
offsetVertical: number,
|
2022-10-13 23:27:46 +00:00
|
|
|
nroHoras: number,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
describe("generarMapaCeldas", () => {
|
|
|
|
it("vacio si input es vacio", () => {
|
2022-10-14 17:05:15 +00:00
|
|
|
const input: Array<GrupoDia> = [];
|
2022-10-13 23:27:46 +00:00
|
|
|
const output = generarMapaCeldas(input);
|
|
|
|
expect(output.length).toBe(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("funciona con 1 curso", () => {
|
2022-10-14 17:05:15 +00:00
|
|
|
const input: Array<any> = [
|
2022-10-13 23:27:46 +00:00
|
|
|
{
|
2022-10-14 17:05:15 +00:00
|
|
|
offsetVertical: 0,
|
2022-10-13 23:27:46 +00:00
|
|
|
nroHoras: 2,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
const output = generarMapaCeldas(input)[0];
|
|
|
|
expect(output).not.toBeUndefined();
|
2022-10-14 17:05:15 +00:00
|
|
|
expect(output.offsetHorizontal).toBe(0);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(output.fraccion).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("funciona con 2 cursos", () => {
|
2022-10-14 17:05:15 +00:00
|
|
|
const input: Array<any> = [
|
2022-10-13 23:27:46 +00:00
|
|
|
{
|
2022-10-14 17:05:15 +00:00
|
|
|
offsetVertical: 0,
|
2022-10-13 23:27:46 +00:00
|
|
|
nroHoras: 2,
|
|
|
|
},
|
|
|
|
{
|
2022-10-14 17:05:15 +00:00
|
|
|
offsetVertical: 1,
|
2022-10-13 23:27:46 +00:00
|
|
|
nroHoras: 3,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const output1 = generarMapaCeldas(input)[0];
|
2022-10-14 17:05:15 +00:00
|
|
|
expect(output1.offsetHorizontal).toBe(0);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(output1.fraccion).toBe(2);
|
|
|
|
|
|
|
|
const output2 = generarMapaCeldas(input)[1];
|
2022-10-14 17:05:15 +00:00
|
|
|
expect(output2.offsetHorizontal).toBe(1);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(output2.fraccion).toBe(2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("MapaCeldas", () => {
|
|
|
|
it("crea 1", () => {
|
|
|
|
const mapa = new MapaCeldas();
|
|
|
|
const input = {} as unknown as Input;
|
2022-10-13 23:29:19 +00:00
|
|
|
const offset = mapa.solicitar(0, 2);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("crea varios que no se solapan", () => {
|
|
|
|
const mapa = new MapaCeldas();
|
|
|
|
const input = {} as unknown as Input;
|
2022-10-13 23:29:19 +00:00
|
|
|
let offset = mapa.solicitar(0, 2);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(0);
|
2022-10-13 23:29:19 +00:00
|
|
|
offset = mapa.solicitar(4, 3);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(0);
|
2022-10-13 23:29:19 +00:00
|
|
|
offset = mapa.solicitar(7, 4);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("crea varios que se solapan", () => {
|
|
|
|
const mapa = new MapaCeldas();
|
|
|
|
const input = {} as unknown as Input;
|
2022-10-13 23:29:19 +00:00
|
|
|
let offset = mapa.solicitar(0, 2);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(0);
|
2022-10-13 23:29:19 +00:00
|
|
|
offset = mapa.solicitar(0, 2);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(1);
|
2022-10-13 23:29:19 +00:00
|
|
|
offset = mapa.solicitar(0, 4);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("crea varios que se solapan de formas diferentes", () => {
|
|
|
|
/*
|
|
|
|
x
|
|
|
|
x x x
|
|
|
|
y x x
|
|
|
|
y x x
|
|
|
|
y z x
|
|
|
|
z
|
|
|
|
z
|
|
|
|
*/
|
|
|
|
const mapa = new MapaCeldas();
|
|
|
|
const input = {} as unknown as Input;
|
2022-10-13 23:29:19 +00:00
|
|
|
let offset = mapa.solicitar(0, 2);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(0);
|
2022-10-13 23:29:19 +00:00
|
|
|
offset = mapa.solicitar(1, 3);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(1);
|
2022-10-13 23:29:19 +00:00
|
|
|
offset = mapa.solicitar(1, 4);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(2);
|
2022-10-13 23:29:19 +00:00
|
|
|
offset = mapa.solicitar(2, 3);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(0);
|
2022-10-13 23:29:19 +00:00
|
|
|
offset = mapa.solicitar(4, 2);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("genera offsets", () => {
|
|
|
|
const mapa = new MapaCeldas();
|
|
|
|
const input = {} as unknown as Input;
|
2022-10-13 23:29:19 +00:00
|
|
|
let offset = mapa.solicitar(0, 2);
|
2022-10-13 23:27:46 +00:00
|
|
|
expect(offset).toBe(0);
|
|
|
|
let fraccion = mapa.generarFraccion(0, offset, 2);
|
|
|
|
expect(fraccion).toBe(1);
|
|
|
|
|
2022-10-13 23:29:19 +00:00
|
|
|
offset = mapa.solicitar(1, 3);
|
2022-10-13 23:27:46 +00:00
|
|
|
fraccion = mapa.generarFraccion(1, offset, 3);
|
|
|
|
expect(fraccion).toBe(2);
|
|
|
|
|
2022-10-13 23:29:19 +00:00
|
|
|
mapa.solicitar(1, 4);
|
|
|
|
mapa.solicitar(2, 3);
|
|
|
|
offset = mapa.solicitar(4, 2);
|
2022-10-13 23:27:46 +00:00
|
|
|
fraccion = mapa.generarFraccion(4, offset, 2);
|
|
|
|
expect(fraccion).toBe(3);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
export {};
|