|
1 |
| -import { testBlock } from "bingo-stratum-testers"; |
2 |
| -import { describe, expect, test, vi } from "vitest"; |
| 1 | +import { testBlock, testIntake } from "bingo-stratum-testers"; |
| 2 | +import { describe, expect, it, test, vi } from "vitest"; |
3 | 3 |
|
4 | 4 | import { blockVitest } from "./blockVitest.js";
|
5 | 5 | import { optionsBase } from "./options.fakes.js";
|
@@ -759,4 +759,111 @@ describe("blockVitest", () => {
|
759 | 759 | }
|
760 | 760 | `);
|
761 | 761 | });
|
| 762 | + |
| 763 | + describe("intake", () => { |
| 764 | + it("returns undefined when vitest.config.ts does not exist", () => { |
| 765 | + const actual = testIntake(blockVitest, { |
| 766 | + files: { |
| 767 | + src: {}, |
| 768 | + }, |
| 769 | + }); |
| 770 | + |
| 771 | + expect(actual).toEqual(undefined); |
| 772 | + }); |
| 773 | + |
| 774 | + it("returns undefined when vitest.config.ts does not contain the expected defineConfig", () => { |
| 775 | + const actual = testIntake(blockVitest, { |
| 776 | + files: { |
| 777 | + "vitest.config.ts": [`invalid`], |
| 778 | + }, |
| 779 | + }); |
| 780 | + |
| 781 | + expect(actual).toEqual(undefined); |
| 782 | + }); |
| 783 | + |
| 784 | + it("returns undefined when vitest.config.ts passes a non-object to defineConfig", () => { |
| 785 | + const actual = testIntake(blockVitest, { |
| 786 | + files: { |
| 787 | + "vitest.config.ts": [`defineConfig("invalid")`], |
| 788 | + }, |
| 789 | + }); |
| 790 | + |
| 791 | + expect(actual).toEqual(undefined); |
| 792 | + }); |
| 793 | + |
| 794 | + it("returns undefined when vitest.config.ts does not pass a test to defineConfig", () => { |
| 795 | + const actual = testIntake(blockVitest, { |
| 796 | + files: { |
| 797 | + "vitest.config.ts": [`defineConfig({ other: true })`], |
| 798 | + }, |
| 799 | + }); |
| 800 | + |
| 801 | + expect(actual).toEqual(undefined); |
| 802 | + }); |
| 803 | + |
| 804 | + it("returns undefined when vitest.config.ts passes unknown test data to defineConfig", () => { |
| 805 | + const actual = testIntake(blockVitest, { |
| 806 | + files: { |
| 807 | + "vitest.config.ts": [`defineConfig({ test: true })`], |
| 808 | + }, |
| 809 | + }); |
| 810 | + |
| 811 | + expect(actual).toEqual(undefined); |
| 812 | + }); |
| 813 | + |
| 814 | + it("returns undefined when vitest.config.ts passes invalid test syntax to defineConfig", () => { |
| 815 | + const actual = testIntake(blockVitest, { |
| 816 | + files: { |
| 817 | + "vitest.config.ts": [`defineConfig({ test: { ! } })`], |
| 818 | + }, |
| 819 | + }); |
| 820 | + |
| 821 | + expect(actual).toEqual(undefined); |
| 822 | + }); |
| 823 | + |
| 824 | + it("returns undefined when vitest.config.ts passes invalid test data to defineConfig", () => { |
| 825 | + const actual = testIntake(blockVitest, { |
| 826 | + files: { |
| 827 | + "vitest.config.ts": [ |
| 828 | + `defineConfig({ test: { coverage: 'invalid' } })`, |
| 829 | + ], |
| 830 | + }, |
| 831 | + }); |
| 832 | + |
| 833 | + expect(actual).toEqual(undefined); |
| 834 | + }); |
| 835 | + |
| 836 | + it("returns coverage and exclude when they exist in vitest.config.ts", () => { |
| 837 | + const actual = testIntake(blockVitest, { |
| 838 | + files: { |
| 839 | + "vitest.config.ts": [ |
| 840 | + `import { defineConfig } from "vitest/config"; |
| 841 | +
|
| 842 | +export default defineConfig({ |
| 843 | + test: { |
| 844 | + clearMocks: true, |
| 845 | + coverage: { |
| 846 | + all: true, |
| 847 | + exclude: ["src/index.ts"], |
| 848 | + include: ["src", "other"], |
| 849 | + reporter: ["html", "lcov"], |
| 850 | + }, |
| 851 | + exclude: ["lib", "node_modules"], |
| 852 | + setupFiles: ["console-fail-test/setup"], |
| 853 | + }, |
| 854 | +}); |
| 855 | +`, |
| 856 | + ], |
| 857 | + }, |
| 858 | + }); |
| 859 | + |
| 860 | + expect(actual).toEqual({ |
| 861 | + coverage: { |
| 862 | + exclude: ["src/index.ts"], |
| 863 | + include: ["src", "other"], |
| 864 | + }, |
| 865 | + exclude: ["lib", "node_modules"], |
| 866 | + }); |
| 867 | + }); |
| 868 | + }); |
762 | 869 | });
|
0 commit comments