generated from unjs/template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78472fc
commit d50e2fe
Showing
1 changed file
with
29 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,33 @@ | ||
import { expect, it, describe } from "vitest"; | ||
import {} from "../src"; | ||
// eslint-disable-next-line import/no-named-as-default | ||
import mycolor from "../src"; | ||
|
||
describe("packageName", () => { | ||
it.todo("pass", () => { | ||
expect(true).toBe(true); | ||
describe("mycolor", () => { | ||
it("should get mycolor by default", async () => { | ||
const mycolor = await import("../src"); | ||
expect(mycolor).toBeDefined(); | ||
}); | ||
it("should get mycolor by named", async () => { | ||
const { mycolor } = await import("../src"); | ||
expect(mycolor).toBeDefined(); | ||
}); | ||
it("should get a new mycolor instance", () => { | ||
const color1 = mycolor(255, 165, 0, 1); | ||
const color2 = mycolor(color1); | ||
expect(color1).not.toBe(color2); | ||
}); | ||
it("input rgba params, should get a rgba array", () => { | ||
expect(mycolor(255, 165, 0, 1).rgba()).toEqual([255, 165, 0, 1]); | ||
}); | ||
it("input hex, should get a rgba array", () => { | ||
expect(mycolor("#ff3").rgba()).toEqual([255, 255, 51, 1]); | ||
expect(mycolor("#ff36").rgba()).toEqual([255, 255, 51, 0.4]); | ||
expect(mycolor("#ff3399").rgba()).toEqual([255, 51, 153, 1]); | ||
expect(mycolor("#ff339966").rgba()).toEqual([255, 51, 153, 0.4]); | ||
// without # | ||
expect(mycolor("ff3").rgba()).toEqual([255, 255, 51, 1]); | ||
expect(mycolor("ff36").rgba()).toEqual([255, 255, 51, 0.4]); | ||
expect(mycolor("ff3399").rgba()).toEqual([255, 51, 153, 1]); | ||
expect(mycolor("ff339966").rgba()).toEqual([255, 51, 153, 0.4]); | ||
}); | ||
}); |