|
| 1 | +// Integration test to verify package.json exports work correctly |
| 2 | +// This simulates how a user would import from the published package |
| 3 | + |
| 4 | +import { Tokenizer } from "@huggingface/tokenizers"; |
| 5 | +import type { Encoding } from "@huggingface/tokenizers"; |
| 6 | +import { Metaspace, Whitespace } from "@huggingface/tokenizers/pre-tokenizers"; |
| 7 | +import { BPE } from "@huggingface/tokenizers/models"; |
| 8 | +import { Lowercase, StripAccents } from "@huggingface/tokenizers/normalizers"; |
| 9 | +import { BPEDecoder } from "@huggingface/tokenizers/decoders"; |
| 10 | +import { TemplateProcessing } from "@huggingface/tokenizers/post-processors"; |
| 11 | + |
| 12 | +describe("Package exports integration", () => { |
| 13 | + it("should import main exports", () => { |
| 14 | + expect(Tokenizer).toBeDefined(); |
| 15 | + |
| 16 | + // Encoding is a type-only export |
| 17 | + const enc: Encoding = { |
| 18 | + ids: [1, 2, 3], |
| 19 | + tokens: ["a", "b", "c"], |
| 20 | + attention_mask: [1, 1, 1], |
| 21 | + }; |
| 22 | + expect(enc.ids).toHaveLength(3); |
| 23 | + }); |
| 24 | + |
| 25 | + it("should import pre-tokenizers", () => { |
| 26 | + expect(Metaspace).toBeDefined(); |
| 27 | + expect(Whitespace).toBeDefined(); |
| 28 | + }); |
| 29 | + |
| 30 | + it("should import models", () => { |
| 31 | + expect(BPE).toBeDefined(); |
| 32 | + }); |
| 33 | + |
| 34 | + it("should import normalizers", () => { |
| 35 | + expect(Lowercase).toBeDefined(); |
| 36 | + expect(StripAccents).toBeDefined(); |
| 37 | + }); |
| 38 | + |
| 39 | + it("should import decoders", () => { |
| 40 | + expect(BPEDecoder).toBeDefined(); |
| 41 | + }); |
| 42 | + |
| 43 | + it("should import post-processors", () => { |
| 44 | + expect(TemplateProcessing).toBeDefined(); |
| 45 | + }); |
| 46 | +}); |
0 commit comments