|
| 1 | +import { mergeNamingConvention } from "../naming-convention"; |
| 2 | + |
| 3 | +describe(mergeNamingConvention, () => { |
| 4 | + test("neither options existing", () => { |
| 5 | + const result = mergeNamingConvention(undefined, undefined); |
| 6 | + |
| 7 | + expect(result).toEqual([]); |
| 8 | + }); |
| 9 | + |
| 10 | + test("original variable name existing", () => { |
| 11 | + const result = mergeNamingConvention( |
| 12 | + [ |
| 13 | + { |
| 14 | + selector: "variable", |
| 15 | + format: ["camelCase", "UPPER_CASE"], |
| 16 | + leadingUnderscore: "forbid", |
| 17 | + trailingUnderscore: "forbid", |
| 18 | + }, |
| 19 | + ], |
| 20 | + undefined, |
| 21 | + ); |
| 22 | + |
| 23 | + expect(result).toEqual([ |
| 24 | + { |
| 25 | + selector: "variable", |
| 26 | + format: ["camelCase", "UPPER_CASE"], |
| 27 | + leadingUnderscore: "forbid", |
| 28 | + trailingUnderscore: "forbid", |
| 29 | + }, |
| 30 | + ]); |
| 31 | + }); |
| 32 | + |
| 33 | + test("original interface name existing", () => { |
| 34 | + const result = mergeNamingConvention(undefined, [ |
| 35 | + { |
| 36 | + selector: "interface", |
| 37 | + format: ["PascalCase"], |
| 38 | + custom: { |
| 39 | + regex: "^I[A-Z]", |
| 40 | + match: false, |
| 41 | + }, |
| 42 | + }, |
| 43 | + ]); |
| 44 | + |
| 45 | + expect(result).toEqual([ |
| 46 | + { |
| 47 | + selector: "interface", |
| 48 | + format: ["PascalCase"], |
| 49 | + custom: { |
| 50 | + regex: "^I[A-Z]", |
| 51 | + match: false, |
| 52 | + }, |
| 53 | + }, |
| 54 | + ]); |
| 55 | + }); |
| 56 | + |
| 57 | + test("both interface and variable name existing", () => { |
| 58 | + const result = mergeNamingConvention( |
| 59 | + [ |
| 60 | + { |
| 61 | + selector: "variable", |
| 62 | + format: ["camelCase", "UPPER_CASE"], |
| 63 | + leadingUnderscore: "forbid", |
| 64 | + trailingUnderscore: "forbid", |
| 65 | + }, |
| 66 | + ], |
| 67 | + [ |
| 68 | + { |
| 69 | + selector: "interface", |
| 70 | + format: ["PascalCase"], |
| 71 | + custom: { |
| 72 | + regex: "^I[A-Z]", |
| 73 | + match: false, |
| 74 | + }, |
| 75 | + }, |
| 76 | + ], |
| 77 | + ); |
| 78 | + |
| 79 | + expect(result).toEqual([ |
| 80 | + { |
| 81 | + selector: "variable", |
| 82 | + format: ["camelCase", "UPPER_CASE"], |
| 83 | + leadingUnderscore: "forbid", |
| 84 | + trailingUnderscore: "forbid", |
| 85 | + }, |
| 86 | + { |
| 87 | + selector: "interface", |
| 88 | + format: ["PascalCase"], |
| 89 | + custom: { |
| 90 | + regex: "^I[A-Z]", |
| 91 | + match: false, |
| 92 | + }, |
| 93 | + }, |
| 94 | + ]); |
| 95 | + }); |
| 96 | +}); |
0 commit comments