Skip to content

Commit

Permalink
fix(eot-generator): remove format options that do not exist on ttf2eot
Browse files Browse the repository at this point in the history
  • Loading branch information
casaper committed Dec 22, 2020
1 parent 7867af0 commit b7b547b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
11 changes: 3 additions & 8 deletions src/generators/asset-types/__tests__/eot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ jest.mock('ttf2eot', () =>
);

const mockOptions = (eotOptions = { __mock: 'options__' } as any) =>
(({
formatOptions: { [FontAssetType.EOT]: eotOptions }
} as unknown) as FontGeneratorOptions);
(({} as unknown) as FontGeneratorOptions);

const ttf = ('::ttf::' as unknown) as Buffer;

Expand All @@ -24,15 +22,12 @@ describe('`EOT` font generator', () => {
const ttfArr = new Uint8Array(('::ttf::' as unknown) as any[]);

expect(ttf2eot).toHaveBeenCalledTimes(1);
expect(ttf2eot).toHaveBeenCalledWith(ttfArr, { __mock: 'options__' });
expect(ttf2eot).toHaveBeenCalledWith(ttfArr);
expect(result).toEqual(Buffer.from(`::eot(${ttfArr})::`));
});

test('passes correctly format options to `ttf2eot`', async () => {
const formatOptions = { foo: 'bar' };
await eotGen.generate(mockOptions(formatOptions), ttf);

await eotGen.generate(mockOptions({}), ttf);
expect(ttf2eot).toHaveBeenCalledTimes(1);
expect(ttf2eot.mock.calls[0][1]).toEqual(formatOptions);
});
});
4 changes: 2 additions & 2 deletions src/generators/asset-types/eot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { FontAssetType } from '../../types/misc';
const generator: FontGenerator<Buffer> = {
dependsOn: FontAssetType.TTF,

async generate({ formatOptions }, ttf) {
const font = ttf2eot(new Uint8Array(ttf), formatOptions[FontAssetType.EOT]);
async generate(_options, ttf) {
const font = ttf2eot(new Uint8Array(ttf));
return Buffer.from(font.buffer);
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/types/modules/ttf2eot.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module 'ttf2eot' {
function ttf2eot(ttf: Uint8Array, options: any): Buffer;
function ttf2eot(ttf: Uint8Array): Buffer;
export default ttf2eot;
}
2 changes: 0 additions & 2 deletions src/types/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export interface RunnerMandatoryOptions {
}

export interface FormatOptions {
eot?: any;
woff2?: any;
woff?: {
/**
* Woff Extended Metadata Block
Expand Down

0 comments on commit b7b547b

Please sign in to comment.