sm-click-library-ui 0.0.458 → 0.0.463

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,66 +1,66 @@
1
- import { JSDOM } from "jsdom";
2
- import { config } from "@vue/test-utils";
3
- import { setActivePinia, createPinia } from "pinia";
4
-
5
- // Cria um DOM simulado
6
- const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
7
- url: "http://localhost",
8
- });
9
-
10
- // Configura `window` e `document`
11
- global.window = dom.window;
12
- global.document = dom.window.document;
13
- global.navigator = dom.window.navigator;
14
-
15
- // Mock de métodos do DOM que podem ser necessários
16
- global.window.HTMLElement = dom.window.HTMLElement;
17
- global.window.requestAnimationFrame = (cb) => setTimeout(cb, 0);
18
- global.window.cancelAnimationFrame = (id) => clearTimeout(id);
19
-
20
- global.ResizeObserver = vi.fn().mockImplementation(() => ({
21
- observe: vi.fn(),
22
- unobserve: vi.fn(),
23
- disconnect: vi.fn(),
24
- }));
25
-
26
- global.window.matchMedia = vi.fn().mockImplementation(() => ({
27
- matches: false,
28
- addListener: vi.fn(),
29
- removeListener: vi.fn(),
30
- }));
31
-
32
- // Configuração global do Vue Test Utils
33
- config.global.stubs = {
34
- Popper: true, // Evita erro de componente não encontrado
35
- VueAwesomePaginate: true, // Stub para VueAwesomePaginate
36
- SimpleModal: true, // Stub para SimpleModal
37
- datepicker: true, // Stub para datepicker,
38
- Svg: { template: "<svg></svg>" },
39
- Popper: { template: "<div><slot /></div>" },
40
- putVideo: { template: "<div></div>" },
41
- VueAwesomePaginate: { template: "<div></div>" },
42
- SimpleLoader: { template: "<div></div>" },
43
- };
44
-
45
- config.global.directives = {
46
- lazy: () => {},
47
- };
48
-
49
- // Ativando Pinia para os testes
50
- setActivePinia(createPinia()); // Certifica que Pinia está disponível nos testes
51
-
52
- // Mock de axios para evitar chamadas reais de API
53
- import { vi } from "vitest";
54
-
55
- vi.mock("@/router/axios", () => ({
56
- default: {
57
- get: vi.fn().mockResolvedValue({ data: [] }), // Return an empty array (or any default data)
58
- post: vi.fn(),
59
- delete: vi.fn(),
60
- patch: vi.fn(),
61
- },
62
- }));
63
- // Mock de notiwind para evitar notificações em testes
64
- vi.mock("notiwind", () => ({
65
- notify: vi.fn(),
66
- }));
1
+ import { JSDOM } from "jsdom";
2
+ import { config } from "@vue/test-utils";
3
+ import { setActivePinia, createPinia } from "pinia";
4
+
5
+ // Cria um DOM simulado
6
+ const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
7
+ url: "http://localhost",
8
+ });
9
+
10
+ // Configura `window` e `document`
11
+ global.window = dom.window;
12
+ global.document = dom.window.document;
13
+ global.navigator = dom.window.navigator;
14
+
15
+ // Mock de métodos do DOM que podem ser necessários
16
+ global.window.HTMLElement = dom.window.HTMLElement;
17
+ global.window.requestAnimationFrame = (cb) => setTimeout(cb, 0);
18
+ global.window.cancelAnimationFrame = (id) => clearTimeout(id);
19
+
20
+ global.ResizeObserver = vi.fn().mockImplementation(() => ({
21
+ observe: vi.fn(),
22
+ unobserve: vi.fn(),
23
+ disconnect: vi.fn(),
24
+ }));
25
+
26
+ global.window.matchMedia = vi.fn().mockImplementation(() => ({
27
+ matches: false,
28
+ addListener: vi.fn(),
29
+ removeListener: vi.fn(),
30
+ }));
31
+
32
+ // Configuração global do Vue Test Utils
33
+ config.global.stubs = {
34
+ Popper: true, // Evita erro de componente não encontrado
35
+ VueAwesomePaginate: true, // Stub para VueAwesomePaginate
36
+ SimpleModal: true, // Stub para SimpleModal
37
+ datepicker: true, // Stub para datepicker,
38
+ Svg: { template: "<svg></svg>" },
39
+ Popper: { template: "<div><slot /></div>" },
40
+ putVideo: { template: "<div></div>" },
41
+ VueAwesomePaginate: { template: "<div></div>" },
42
+ SimpleLoader: { template: "<div></div>" },
43
+ };
44
+
45
+ config.global.directives = {
46
+ lazy: () => {},
47
+ };
48
+
49
+ // Ativando Pinia para os testes
50
+ setActivePinia(createPinia()); // Certifica que Pinia está disponível nos testes
51
+
52
+ // Mock de axios para evitar chamadas reais de API
53
+ import { vi } from "vitest";
54
+
55
+ vi.mock("@/router/axios", () => ({
56
+ default: {
57
+ get: vi.fn().mockResolvedValue({ data: [] }), // Return an empty array (or any default data)
58
+ post: vi.fn(),
59
+ delete: vi.fn(),
60
+ patch: vi.fn(),
61
+ },
62
+ }));
63
+ // Mock de notiwind para evitar notificações em testes
64
+ vi.mock("notiwind", () => ({
65
+ notify: vi.fn(),
66
+ }));
@@ -1,4 +1,4 @@
1
- import { r as le, C as ge, W as me } from "./index-D5FU4Q1k.js";
1
+ import { r as le, C as ge, W as me } from "./index-BbUS-evp.js";
2
2
  const F = {
3
3
  RECORDING: "RECORDING",
4
4
  PAUSED: "PAUSED",
@@ -58,7 +58,7 @@ var te;
58
58
  n.UTF8 = "utf8", n.ASCII = "ascii", n.UTF16 = "utf16";
59
59
  })(te || (te = {}));
60
60
  const k = le("Filesystem", {
61
- web: () => import("./web-CjvjeoiZ.js").then((n) => new n.FilesystemWeb())
61
+ web: () => import("./web-aHUjRRYj.js").then((n) => new n.FilesystemWeb())
62
62
  });
63
63
  ye();
64
64
  const Ee = le("BlobWriter");
@@ -1,5 +1,5 @@
1
- import { W as P, b as x } from "./index-D5FU4Q1k.js";
2
- import { E } from "./web-DELmqyOO.js";
1
+ import { W as P, b as x } from "./index-BbUS-evp.js";
2
+ import { E } from "./web-1ZN9WaDR.js";
3
3
  function m(w) {
4
4
  const e = w.split("/").filter((t) => t !== "."), r = [];
5
5
  return e.forEach((t) => {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "dist",
6
6
  "src/test-utils"
7
7
  ],
8
- "version": "0.0.458",
8
+ "version": "0.0.463",
9
9
  "main": "dist/sm-click-library-ui.es.js",
10
10
  "module": "dist/sm-click-library-ui.umd.js",
11
11
  "private": false,
@@ -1,85 +1,85 @@
1
- import { mount } from "@vue/test-utils";
2
- import { describe, it, expect, vi, beforeEach } from "vitest";
3
- import listProducts from "../../../components/CRM+/clientsComponents/listProducts.vue";
4
-
5
- describe("Listagem de produtos - incrementação e decrementação", () => {
6
- let wrapper;
7
-
8
- const sampleProducts = {
9
- results: [
10
- { id: 1, name: "Produto A", price: 10, recurrence: "unique" },
11
- { id: 2, name: "Produto B", price: 5, recurrence: "monthly" },
12
- ],
13
- next: null,
14
- previous: null,
15
- };
16
-
17
- beforeEach(() => {
18
- wrapper = mount(listProducts, {
19
- props: {
20
- // começa sem selecionados
21
- modelValue: [],
22
- // injeta produtos locais para evitar chamada à API
23
- allProducts: sampleProducts,
24
- },
25
- });
26
- });
27
-
28
- it("Incrementa a quantidade ao clicar em '+'", async () => {
29
- const items = wrapper.findAll("li");
30
- expect(items.length).toBeGreaterThan(0);
31
-
32
- // Primeiro produto da lista
33
- const firstItem = items[0];
34
- const plusBtn = firstItem.findAll("button").at(1); // ordem: '-' , qty , '+'
35
- const qtyDisplay = firstItem.find("p.w-5");
36
-
37
- expect(qtyDisplay.text()).toBe("0");
38
-
39
- await plusBtn.trigger("click");
40
- await wrapper.vm.$nextTick();
41
-
42
- // quantidade deve ser 1
43
- expect(qtyDisplay.text()).toBe("1");
44
-
45
- // evento emitido com modelo atualizado
46
- const emits = wrapper.emitted("update:modelValue");
47
- expect(emits).toBeTruthy();
48
- const lastEmit = emits[emits.length - 1][0];
49
- expect(Array.isArray(lastEmit)).toBe(true);
50
- expect(lastEmit[0]).toMatchObject({
51
- product: expect.objectContaining({ id: 1 }),
52
- quantity: 1,
53
- });
54
- });
55
-
56
- it("Decrementa a quantidade ao clicar em '-' sem ir abaixo de 0", async () => {
57
- const items = wrapper.findAll("li");
58
- const firstItem = items[0];
59
- const minusBtn = firstItem.findAll("button").at(0); // '-'
60
- const plusBtn = firstItem.findAll("button").at(1); // '+'
61
- // console.log("minusBtn:", minusBtn.html());
62
- const qtyDisplay = firstItem.find("p.w-5");
63
-
64
- // Sobe para 2
65
- await plusBtn.trigger("click");
66
- await plusBtn.trigger("click");
67
- await wrapper.vm.$nextTick();
68
- expect(qtyDisplay.text()).toBe("2");
69
-
70
- // Desce para 1
71
- await minusBtn.trigger("click");
72
- await wrapper.vm.$nextTick();
73
- expect(qtyDisplay.text()).toBe("1");
74
-
75
- // Desce para 0
76
- await minusBtn.trigger("click");
77
- await wrapper.vm.$nextTick();
78
- expect(qtyDisplay.text()).toBe("0");
79
-
80
- // Tenta descer abaixo de 0 (deve continuar 0)
81
- await minusBtn.trigger("click");
82
- await wrapper.vm.$nextTick();
83
- expect(qtyDisplay.text()).toBe("0");
84
- });
85
- });
1
+ import { mount } from "@vue/test-utils";
2
+ import { describe, it, expect, vi, beforeEach } from "vitest";
3
+ import listProducts from "../../../components/CRM+/clientsComponents/listProducts.vue";
4
+
5
+ describe("Listagem de produtos - incrementação e decrementação", () => {
6
+ let wrapper;
7
+
8
+ const sampleProducts = {
9
+ results: [
10
+ { id: 1, name: "Produto A", price: 10, recurrence: "unique" },
11
+ { id: 2, name: "Produto B", price: 5, recurrence: "monthly" },
12
+ ],
13
+ next: null,
14
+ previous: null,
15
+ };
16
+
17
+ beforeEach(() => {
18
+ wrapper = mount(listProducts, {
19
+ props: {
20
+ // começa sem selecionados
21
+ modelValue: [],
22
+ // injeta produtos locais para evitar chamada à API
23
+ allProducts: sampleProducts,
24
+ },
25
+ });
26
+ });
27
+
28
+ it("Incrementa a quantidade ao clicar em '+'", async () => {
29
+ const items = wrapper.findAll("li");
30
+ expect(items.length).toBeGreaterThan(0);
31
+
32
+ // Primeiro produto da lista
33
+ const firstItem = items[0];
34
+ const plusBtn = firstItem.findAll("button").at(1); // ordem: '-' , qty , '+'
35
+ const qtyDisplay = firstItem.find("p.w-5");
36
+
37
+ expect(qtyDisplay.text()).toBe("0");
38
+
39
+ await plusBtn.trigger("click");
40
+ await wrapper.vm.$nextTick();
41
+
42
+ // quantidade deve ser 1
43
+ expect(qtyDisplay.text()).toBe("1");
44
+
45
+ // evento emitido com modelo atualizado
46
+ const emits = wrapper.emitted("update:modelValue");
47
+ expect(emits).toBeTruthy();
48
+ const lastEmit = emits[emits.length - 1][0];
49
+ expect(Array.isArray(lastEmit)).toBe(true);
50
+ expect(lastEmit[0]).toMatchObject({
51
+ product: expect.objectContaining({ id: 1 }),
52
+ quantity: 1,
53
+ });
54
+ });
55
+
56
+ it("Decrementa a quantidade ao clicar em '-' sem ir abaixo de 0", async () => {
57
+ const items = wrapper.findAll("li");
58
+ const firstItem = items[0];
59
+ const minusBtn = firstItem.findAll("button").at(0); // '-'
60
+ const plusBtn = firstItem.findAll("button").at(1); // '+'
61
+ // console.log("minusBtn:", minusBtn.html());
62
+ const qtyDisplay = firstItem.find("p.w-5");
63
+
64
+ // Sobe para 2
65
+ await plusBtn.trigger("click");
66
+ await plusBtn.trigger("click");
67
+ await wrapper.vm.$nextTick();
68
+ expect(qtyDisplay.text()).toBe("2");
69
+
70
+ // Desce para 1
71
+ await minusBtn.trigger("click");
72
+ await wrapper.vm.$nextTick();
73
+ expect(qtyDisplay.text()).toBe("1");
74
+
75
+ // Desce para 0
76
+ await minusBtn.trigger("click");
77
+ await wrapper.vm.$nextTick();
78
+ expect(qtyDisplay.text()).toBe("0");
79
+
80
+ // Tenta descer abaixo de 0 (deve continuar 0)
81
+ await minusBtn.trigger("click");
82
+ await wrapper.vm.$nextTick();
83
+ expect(qtyDisplay.text()).toBe("0");
84
+ });
85
+ });
@@ -1,106 +1,106 @@
1
- import { describe, it, expect, beforeEach } from "vitest";
2
- import { mount } from "@vue/test-utils";
3
- import AttendantSelect from "~/components/selects/attendantSelect/attendantSelect.vue";
4
- import { createTestingPinia } from "@pinia/testing";
5
-
6
- const attendantsMock = [
7
- {
8
- id: 1,
9
- name: "John Doe",
10
- status: true,
11
- department: [{ id: "dept1" }],
12
- photo: "",
13
- selected: false,
14
- },
15
- {
16
- id: 2,
17
- name: "Jane Smith",
18
- status: true,
19
- department: [{ id: "dept1" }],
20
- photo: "",
21
- selected: false,
22
- },
23
- ];
24
-
25
- describe("AttendantSelect Component", () => {
26
- let wrapper;
27
- beforeEach(() => {
28
- wrapper = mount(AttendantSelect, {
29
- props: {
30
- attendance: [],
31
- multiSelect: true,
32
- department: [{ id: "dept1" }],
33
- modal_filter: null,
34
- attDel: { id: null },
35
- method: null,
36
- },
37
- global: {
38
- plugins: [
39
- createTestingPinia({
40
- initialState: {
41
- attendant: {
42
- attendants: attendantsMock,
43
- loaded: true,
44
- },
45
- },
46
- stubActions: false,
47
- }),
48
- ],
49
- },
50
- });
51
- });
52
-
53
- it("renders the correct number of attendants", () => {
54
- const attendantItems = wrapper.findAll(".department-item");
55
- expect(attendantItems.length).toBe(2);
56
- });
57
-
58
- it("selects an attendant on click", async () => {
59
- // Instead of triggering click on the .department-item,
60
- // we find the .department-name element inside it:
61
- const firstItemName = wrapper
62
- .findAll(".department-item")
63
- .at(0)
64
- .find(".department-name");
65
-
66
- await firstItemName.trigger("click");
67
-
68
- const emits = wrapper.emitted("attend");
69
- expect(emits).toBeDefined();
70
-
71
- const selected = emits[emits.length - 1][0];
72
- expect(selected).toHaveLength(1); // ...
73
- });
74
-
75
- it("removes an attendant when the erase button is clicked", async () => {
76
- // Find the correct child that has the @click.
77
- const firstItemName = wrapper
78
- .findAll(".department-item")
79
- .at(0)
80
- .find(".department-name");
81
- await firstItemName.trigger("click");
82
-
83
- // Wait for selection to render
84
- await wrapper.vm.$nextTick();
85
-
86
- // Now .close-btn should appear
87
- const eraseButton = wrapper.find(".close-btn");
88
- await eraseButton.trigger("click");
89
-
90
- // Check latest emitted array
91
- const emits = wrapper.emitted("attend");
92
- const currentSelection = emits[emits.length - 1][0];
93
- expect(currentSelection).toHaveLength(0);
94
- });
95
-
96
- it("filters attendants based on the search input", async () => {
97
- const input = wrapper.find("input");
98
- await input.setValue("Jane");
99
- await wrapper.vm.$nextTick();
100
-
101
- // After filtering, only Jane Smith should be displayed.
102
- const filteredItems = wrapper.findAll(".department-item");
103
- expect(filteredItems.length).toBe(1);
104
- expect(filteredItems[0].text()).toContain("Jane Smith");
105
- });
106
- });
1
+ import { describe, it, expect, beforeEach } from "vitest";
2
+ import { mount } from "@vue/test-utils";
3
+ import AttendantSelect from "~/components/selects/attendantSelect/attendantSelect.vue";
4
+ import { createTestingPinia } from "@pinia/testing";
5
+
6
+ const attendantsMock = [
7
+ {
8
+ id: 1,
9
+ name: "John Doe",
10
+ status: true,
11
+ department: [{ id: "dept1" }],
12
+ photo: "",
13
+ selected: false,
14
+ },
15
+ {
16
+ id: 2,
17
+ name: "Jane Smith",
18
+ status: true,
19
+ department: [{ id: "dept1" }],
20
+ photo: "",
21
+ selected: false,
22
+ },
23
+ ];
24
+
25
+ describe("AttendantSelect Component", () => {
26
+ let wrapper;
27
+ beforeEach(() => {
28
+ wrapper = mount(AttendantSelect, {
29
+ props: {
30
+ attendance: [],
31
+ multiSelect: true,
32
+ department: [{ id: "dept1" }],
33
+ modal_filter: null,
34
+ attDel: { id: null },
35
+ method: null,
36
+ },
37
+ global: {
38
+ plugins: [
39
+ createTestingPinia({
40
+ initialState: {
41
+ attendant: {
42
+ attendants: attendantsMock,
43
+ loaded: true,
44
+ },
45
+ },
46
+ stubActions: false,
47
+ }),
48
+ ],
49
+ },
50
+ });
51
+ });
52
+
53
+ it("renders the correct number of attendants", () => {
54
+ const attendantItems = wrapper.findAll(".department-item");
55
+ expect(attendantItems.length).toBe(2);
56
+ });
57
+
58
+ it("selects an attendant on click", async () => {
59
+ // Instead of triggering click on the .department-item,
60
+ // we find the .department-name element inside it:
61
+ const firstItemName = wrapper
62
+ .findAll(".department-item")
63
+ .at(0)
64
+ .find(".department-name");
65
+
66
+ await firstItemName.trigger("click");
67
+
68
+ const emits = wrapper.emitted("attend");
69
+ expect(emits).toBeDefined();
70
+
71
+ const selected = emits[emits.length - 1][0];
72
+ expect(selected).toHaveLength(1); // ...
73
+ });
74
+
75
+ it("removes an attendant when the erase button is clicked", async () => {
76
+ // Find the correct child that has the @click.
77
+ const firstItemName = wrapper
78
+ .findAll(".department-item")
79
+ .at(0)
80
+ .find(".department-name");
81
+ await firstItemName.trigger("click");
82
+
83
+ // Wait for selection to render
84
+ await wrapper.vm.$nextTick();
85
+
86
+ // Now .close-btn should appear
87
+ const eraseButton = wrapper.find(".close-btn");
88
+ await eraseButton.trigger("click");
89
+
90
+ // Check latest emitted array
91
+ const emits = wrapper.emitted("attend");
92
+ const currentSelection = emits[emits.length - 1][0];
93
+ expect(currentSelection).toHaveLength(0);
94
+ });
95
+
96
+ it("filters attendants based on the search input", async () => {
97
+ const input = wrapper.find("input");
98
+ await input.setValue("Jane");
99
+ await wrapper.vm.$nextTick();
100
+
101
+ // After filtering, only Jane Smith should be displayed.
102
+ const filteredItems = wrapper.findAll(".department-item");
103
+ expect(filteredItems.length).toBe(1);
104
+ expect(filteredItems[0].text()).toContain("Jane Smith");
105
+ });
106
+ });