Skip to content

Commit

Permalink
test: stub out all the functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
aalemayhu committed Sep 14, 2023
1 parent f2c342d commit eda93a1
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
40 changes: 37 additions & 3 deletions src/csv-to-apkg.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,45 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { describe, it, expect } from 'vitest';
import { describe, it, expect, fail } from 'vitest';

import convertCSVToAPKG from './csv-to-apkg';
import convertCSVToAPKG, { CSVReader } from './csv-to-apkg';

const CSV_EXAMPLE = `
Word,Meaning,Tags
お願いします,Please,one
ありがとう,Thank you (impolite),two
ありがとうございます。,Thank you (polite),three
`;

describe("Convert CSV to APKG", () => {
it("converts CSV to APKG format", () => {
it.skip("converts CSV to APKG format", () => {
expect(convertCSVToAPKG()).toContain("magic")
});

it.skip("reads the CSV content correctly", () => {
const reader = new CSVReader(CSV_EXAMPLE);
expect(reader.getHeaders()).toBe(['Word', 'Meaning', 'Tags']);
expect(reader.getRows()).toBe(
[
['お願いします', 'Please', 'one'],
['ありがとう', 'Thank you (impolite)', 'two'],
['ありがとうございます。', 'Thank you (polite)', 'three']
]
)
});

it.skip("Transform to decks / notes", () => {
const reader = new CSVReader(CSV_EXAMPLE);
const mapper = new DataMapper(reader.parseSync())
expect(mapper.getDecks()).toBe(['Default'])
});

it.skip("uses filename as deck name", () => {
console.info("to be implemented");
})

it.skip("uses custom filename as deck name", () => {
console.info("to be implemented");
})

})

17 changes: 17 additions & 0 deletions src/csv-to-apkg.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
export default function convertCSVToAPKG(): string | null {
throw new Error("To be implemented")
}


export type CSVColumnHeader = string
export type CSVRow = string

export class CSVReader {

constructor(readonly content: string) {}

getHeaders(): CSVColumnHeader {
throw new Error("not implemented")
}

getRows(): CSVRow {
throw new Error("not implemented")
}
}

0 comments on commit eda93a1

Please sign in to comment.