Skip to content

Commit

Permalink
Add tests for mediaType
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcaza committed Aug 31, 2024
1 parent 2eadd7d commit 8456097
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/__specs__/main.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect } from "bun:test";
import { mkConfig } from "../config.ts";
import { asBlob, generateCsv } from "../generator.ts";
import { ConfigOptions } from "../types.ts";
import { ConfigOptions, MediaType } from "../types.ts";
import { asString } from "../helpers.ts";

const mockData = [
Expand Down Expand Up @@ -344,6 +344,27 @@ describe("ExportToCsv", () => {
expect(firstLine).toBe("Test Csv 2\r");
});

it("should allow for custom file extensions", () => {
const csvOpts: ConfigOptions = {
mediaType: MediaType.csv,
};
const csvConf = mkConfig(csvOpts);

const txtOpts: ConfigOptions = {
mediaType: MediaType.plain,
};
const txtConf = mkConfig(txtOpts);

const tsvOpts: ConfigOptions = {
mediaType: MediaType.tsv,
};
const tsvConf = mkConfig(tsvOpts);

expect(csvConf.mediaType).toBe(MediaType.csv);
expect(txtConf.mediaType).toBe(MediaType.plain);
expect(tsvConf.mediaType).toBe(MediaType.tsv);
});

describe("asBlob", () => {
it("should construct a valid blob based on options", async () => {
const options: ConfigOptions = {
Expand Down

0 comments on commit 8456097

Please sign in to comment.