Commit dbbf81d2 authored by Michael Underwood's avatar Michael Underwood
Browse files

Add simple initial tests

parent 5a49af73
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@ pnpm-debug.log*

# Editor directories and files
.idea
.vscode
.vscode/*
!.vscode/extensions.json
*.suo
*.ntvs*
*.njsproj
+6 −0
Original line number Diff line number Diff line
{
  "recommendations": [
    "zixuanchen.vitest-explorer",
    "vue.volar"
  ]
}
 No newline at end of file

jest.config.js

deleted100644 → 0
+0 −24
Original line number Diff line number Diff line
module.exports = {
  verbose: true,
  bail: true,
  collectCoverage: true,
  coverageDirectory: "coverage",
  restoreMocks: true,
  moduleFileExtensions: ["js", "jsx", "json", "vue"],
  setupFiles: ["<rootDir>/tests/setup.js"],
  transform: {
    "^.+\\.vue$": "vue-jest",
    ".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$":
      "jest-transform-stub",
    "^.+\\.jsx?$": "babel-jest",
  },
  moduleNameMapper: {
    "^@/tests/(.*)$": "<rootDir>/tests/$1",
    "^@/(.*)$": "<rootDir>/src/$1",
  },
  snapshotSerializers: ["jest-serializer-vue"],
  testMatch: [
    "**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)",
  ],
  testURL: "http://localhost/",
};

jsconfig.json

0 → 100644
+9 −0
Original line number Diff line number Diff line
{
  "compilerOptions": {
    "baseUrl": ".",
    "target": "es6",
    "paths": {
      "@src/*": ["./src/*"]
    }
  }
}
+22 −0
Original line number Diff line number Diff line
import { describe, it, expect } from "vitest";
import { capitalizeFirstLetter } from "@src/utils";

describe("capitalizeFirstLetter", () => {
  it("returns empty string given empty string", () => {
    const result = capitalizeFirstLetter("");

    expect(result).to.be.empty;
  });

  it("capitalizes the first letter of a string starting with a letter, and changes nothing else", () => {
    const result = capitalizeFirstLetter("this IS a String!");

    expect(result).to.equal("This IS a String!");
  });

  it("returns a string unchanged when not starting with a letter", () => {
    const result = capitalizeFirstLetter("42 is the answer");

    expect(result).to.equal("42 is the answer");
  });
});
Loading