|
| 1 | +import { goTry } from "go-go-try"; |
| 2 | +import { expect, test } from "vitest"; |
| 3 | +import { checkLicense } from "./check-license"; |
| 4 | + |
| 5 | +test("undefined", () => { |
| 6 | + const [err] = goTry(() => checkLicense()); |
| 7 | + expect(err).toBeDefined(); |
| 8 | +}); |
| 9 | + |
| 10 | +test("empty", () => { |
| 11 | + const [err] = goTry(() => checkLicense("")); |
| 12 | + expect(err).toBeDefined(); |
| 13 | +}); |
| 14 | + |
| 15 | +test("unlicensed", () => { |
| 16 | + const [err1] = goTry(() => checkLicense("UNLICENSED")); |
| 17 | + const [err2] = goTry(() => checkLicense("unlicensed")); |
| 18 | + expect(err1).toBeDefined(); |
| 19 | + expect(err2).toBeDefined(); |
| 20 | +}); |
| 21 | + |
| 22 | +test("see license in ...", () => { |
| 23 | + const [err1] = goTry(() => checkLicense("SEE LICENSE IN ...")); |
| 24 | + const [err2] = goTry(() => checkLicense("see license in ...")); |
| 25 | + const [err3] = goTry(() => checkLicense("See license in ...")); |
| 26 | + expect(err1).toBeDefined(); |
| 27 | + expect(err2).toBeDefined(); |
| 28 | + expect(err3).toBeDefined(); |
| 29 | +}); |
| 30 | + |
| 31 | +test("valid licenses", () => { |
| 32 | + const [err1] = goTry(() => checkLicense("MIT")); |
| 33 | + const [err2] = goTry(() => checkLicense("Apache-2.0")); |
| 34 | + const [err3] = goTry(() => checkLicense("MIT AND Apache-2.0")); |
| 35 | + const [err4] = goTry(() => checkLicense("(ISC OR GPL-4.0)")); |
| 36 | + expect(err1).toBeUndefined(); |
| 37 | + expect(err2).toBeUndefined(); |
| 38 | + expect(err3).toBeUndefined(); |
| 39 | + expect(err4).toBeUndefined(); |
| 40 | +}); |
0 commit comments