|
| 1 | +// Licensed to the Software Freedom Conservancy (SFC) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The SFC licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +import { convertToSnake } from "../src/utils"; |
| 19 | + |
| 20 | +describe("convert test names to snake_case", () => { |
| 21 | + it("should convert spaces to _", () => { |
| 22 | + expect(convertToSnake(" ")).toBe("_"); |
| 23 | + }); |
| 24 | + it("should convert arithmetic signs to _", () => { |
| 25 | + expect(convertToSnake("+")).toBe("_"); |
| 26 | + expect(convertToSnake("-")).toBe("_"); |
| 27 | + expect(convertToSnake("/")).toBe("_"); |
| 28 | + expect(convertToSnake("*")).toBe("_"); |
| 29 | + expect(convertToSnake("%")).toBe("_"); |
| 30 | + }); |
| 31 | + it("should convert boolean signs to _", () => { |
| 32 | + expect(convertToSnake("!")).toBe("_"); |
| 33 | + expect(convertToSnake("=")).toBe("_"); |
| 34 | + expect(convertToSnake("&")).toBe("_"); |
| 35 | + expect(convertToSnake("|")).toBe("_"); |
| 36 | + expect(convertToSnake(">")).toBe("_"); |
| 37 | + expect(convertToSnake("<")).toBe("_"); |
| 38 | + expect(convertToSnake("?")).toBe("_"); |
| 39 | + }); |
| 40 | + it("should convert other illegal entities to _", () => { |
| 41 | + expect(convertToSnake("\\")).toBe("_"); |
| 42 | + expect(convertToSnake("@")).toBe("_"); |
| 43 | + expect(convertToSnake("#")).toBe("_"); |
| 44 | + expect(convertToSnake("^")).toBe("_"); |
| 45 | + expect(convertToSnake(";")).toBe("_"); |
| 46 | + expect(convertToSnake(":")).toBe("_"); |
| 47 | + expect(convertToSnake(".")).toBe("_"); |
| 48 | + expect(convertToSnake(",")).toBe("_"); |
| 49 | + }); |
| 50 | + it("should convert all braces signs to _", () => { |
| 51 | + expect(convertToSnake("(")).toBe("_"); |
| 52 | + expect(convertToSnake(")")).toBe("_"); |
| 53 | + expect(convertToSnake("[")).toBe("_"); |
| 54 | + expect(convertToSnake("]")).toBe("_"); |
| 55 | + expect(convertToSnake("{")).toBe("_"); |
| 56 | + expect(convertToSnake("}")).toBe("_"); |
| 57 | + }); |
| 58 | + it("should convert all string literals", () => { |
| 59 | + expect(convertToSnake("'")).toBe("_"); |
| 60 | + expect(convertToSnake("\"")).toBe("_"); |
| 61 | + expect(convertToSnake("`")).toBe("_"); |
| 62 | + }); |
| 63 | +}); |
0 commit comments