|
| 1 | +"use strict"; |
| 2 | + |
| 3 | +const expect = require("chai").expect; |
| 4 | +const camelCase = require("../camel-case"); |
| 5 | +const unCamelCase = require("../un-camel-case"); |
| 6 | + |
| 7 | +const data = { |
| 8 | + xwebkitAnimation: "-xwebkit-animation", |
| 9 | + webkitAnimation: "-webkit-animation", |
| 10 | + epubAnimation: "-epub-animation", |
| 11 | + mozAnimation: "-moz-animation", |
| 12 | + msAnimation: "-ms-animation", |
| 13 | + oAnimation: "-o-animation", |
| 14 | + xAnimation: "-x-animation", |
| 15 | + webkitApp: "-webkit-app", |
| 16 | + borderTopLeftRadius: "border-top-left-radius", |
| 17 | + backgroundImage: "background-image", |
| 18 | + "::selection": "::selection", |
| 19 | + "::mozSelection": "::-moz-selection", |
| 20 | + "::mozSelection,::selection": "::-moz-selection,::selection", |
| 21 | + "--margin-top": "--margin-top", |
| 22 | + "margin--top": "margin--top", |
| 23 | + "height: webkitCalc(2vh-20px);": "height: -webkit-calc(2vh-20px);", |
| 24 | + "calc(2vh-20px)": "calc(2vh-20px)", |
| 25 | + "calc(2vh--20px)": "calc(2vh--20px)", |
| 26 | +}; |
| 27 | + |
| 28 | +const testCases = Object.keys(data).map(prop => { |
| 29 | + return { |
| 30 | + camel: prop, |
| 31 | + unCamel: data[prop], |
| 32 | + }; |
| 33 | +}); |
| 34 | + |
| 35 | +const symbols = Array.from("@*:;\n,(){} "); |
| 36 | + |
| 37 | +describe("camelCase", () => { |
| 38 | + testCases.forEach(testCase => { |
| 39 | + it(`${testCase.unCamel} => ${testCase.camel}`, () => { |
| 40 | + expect(camelCase(testCase.unCamel)).to.equal(testCase.camel); |
| 41 | + }); |
| 42 | + }); |
| 43 | + describe("symbols", () => { |
| 44 | + symbols.forEach(symbol => { |
| 45 | + it(JSON.stringify(symbol), () => { |
| 46 | + expect(camelCase(testCases.map(testCase => testCase.unCamel).join(symbol))).to.equal(testCases.map(testCase => testCase.camel).join(symbol)); |
| 47 | + }); |
| 48 | + }); |
| 49 | + }); |
| 50 | +}); |
| 51 | + |
| 52 | +describe("unCamelCase", () => { |
| 53 | + it("onChange => on-change", () => { |
| 54 | + expect(unCamelCase("onChange")).to.equal("on-change"); |
| 55 | + }); |
| 56 | + it("OnChange => -on-change", () => { |
| 57 | + expect(unCamelCase("OnChange")).to.equal("-on-change"); |
| 58 | + }); |
| 59 | + testCases.forEach(testCase => { |
| 60 | + it(`${testCase.camel} => ${testCase.unCamel}`, () => { |
| 61 | + expect(unCamelCase(testCase.camel)).to.equal(testCase.unCamel); |
| 62 | + }); |
| 63 | + }); |
| 64 | + describe("symbols", () => { |
| 65 | + symbols.forEach(symbol => { |
| 66 | + it(JSON.stringify(symbol), () => { |
| 67 | + expect(unCamelCase(testCases.map(testCase => testCase.camel).join(symbol))).to.equal(testCases.map(testCase => testCase.unCamel).join(symbol)); |
| 68 | + }); |
| 69 | + }); |
| 70 | + }); |
| 71 | +}); |
0 commit comments