1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const vitest_1 = require("vitest");
|
4 | const argsToTemplate_1 = require("./argsToTemplate");
|
5 | (0, vitest_1.describe)('argsToTemplate', () => {
|
6 | (0, vitest_1.it)('should correctly convert args to template string and exclude undefined values', () => {
|
7 | const args = {
|
8 | prop1: 'value1',
|
9 | prop2: undefined,
|
10 | prop3: 'value3',
|
11 | };
|
12 | const options = {};
|
13 | const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
|
14 | (0, vitest_1.expect)(result).toBe('[prop1]="prop1" [prop3]="prop3"');
|
15 | });
|
16 | (0, vitest_1.it)('should include properties from include option', () => {
|
17 | const args = {
|
18 | prop1: 'value1',
|
19 | prop2: 'value2',
|
20 | prop3: 'value3',
|
21 | };
|
22 | const options = {
|
23 | include: ['prop1', 'prop3'],
|
24 | };
|
25 | const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
|
26 | (0, vitest_1.expect)(result).toBe('[prop1]="prop1" [prop3]="prop3"');
|
27 | });
|
28 | (0, vitest_1.it)('should include non-undefined properties from include option', () => {
|
29 | const args = {
|
30 | prop1: 'value1',
|
31 | prop2: 'value2',
|
32 | prop3: undefined,
|
33 | };
|
34 | const options = {
|
35 | include: ['prop1', 'prop3'],
|
36 | };
|
37 | const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
|
38 | (0, vitest_1.expect)(result).toBe('[prop1]="prop1"');
|
39 | });
|
40 | (0, vitest_1.it)('should exclude properties from exclude option', () => {
|
41 | const args = {
|
42 | prop1: 'value1',
|
43 | prop2: 'value2',
|
44 | prop3: 'value3',
|
45 | };
|
46 | const options = {
|
47 | exclude: ['prop2'],
|
48 | };
|
49 | const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
|
50 | (0, vitest_1.expect)(result).toBe('[prop1]="prop1" [prop3]="prop3"');
|
51 | });
|
52 | (0, vitest_1.it)('should exclude properties from exclude option and undefined properties', () => {
|
53 | const args = {
|
54 | prop1: 'value1',
|
55 | prop2: 'value2',
|
56 | prop3: undefined,
|
57 | };
|
58 | const options = {
|
59 | exclude: ['prop2'],
|
60 | };
|
61 | const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
|
62 | (0, vitest_1.expect)(result).toBe('[prop1]="prop1"');
|
63 | });
|
64 | (0, vitest_1.it)('should prioritize include over exclude when both options are given', () => {
|
65 | const args = {
|
66 | prop1: 'value1',
|
67 | prop2: 'value2',
|
68 | prop3: 'value3',
|
69 | };
|
70 | const options = {
|
71 | include: ['prop1', 'prop2'],
|
72 | exclude: ['prop2', 'prop3'],
|
73 | };
|
74 | const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
|
75 | (0, vitest_1.expect)(result).toBe('[prop1]="prop1" [prop2]="prop2"');
|
76 | });
|
77 | (0, vitest_1.it)('should work when neither include nor exclude options are given', () => {
|
78 | const args = {
|
79 | prop1: 'value1',
|
80 | prop2: 'value2',
|
81 | };
|
82 | const options = {};
|
83 | const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
|
84 | (0, vitest_1.expect)(result).toBe('[prop1]="prop1" [prop2]="prop2"');
|
85 | });
|
86 | (0, vitest_1.it)('should bind events correctly when value is a function', () => {
|
87 | const args = { event1: () => { }, event2: () => { } };
|
88 | const result = (0, argsToTemplate_1.argsToTemplate)(args, {});
|
89 | (0, vitest_1.expect)(result).toEqual('(event1)="event1($event)" (event2)="event2($event)"');
|
90 | });
|
91 | (0, vitest_1.it)('should mix properties and events correctly', () => {
|
92 | const args = { input: 'Value1', event1: () => { } };
|
93 | const result = (0, argsToTemplate_1.argsToTemplate)(args, {});
|
94 | (0, vitest_1.expect)(result).toEqual('[input]="input" (event1)="event1($event)"');
|
95 | });
|
96 | });
|