Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Aug 15, 2023
1 parent d6b5302 commit 936e07a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions test/integration/tw_font_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ const VirtualMachine = require('../../src/virtual-machine');

const emptyProjectFixture = path.join(__dirname, '..', 'fixtures', 'tw-empty-project.sb3');

// Tests use a vanilla scratch-storage, so we need to patch these in ourselves.
const TTFDataFormat = 'ttf';
const FontAssetType = {
contentType: 'application/x-font-ttf',
name: 'Font',
runtimeFormat: TTFDataFormat,
immutable: true
};

test('isValidFamily', t => {
const {fontManager} = new Runtime();
t.ok(fontManager.isValidFamily('Roboto'));
Expand Down Expand Up @@ -184,8 +193,8 @@ test('custom fonts', t => {
changed = false;
setCustomFontsCalls.length = 0;
const asset = rt.storage.createAsset(
rt.storage.AssetType.Font,
rt.storage.DataFormat.TTF,
FontAssetType,
TTFDataFormat,
new Uint8Array([4, 5, 6]),
null,
true
Expand Down Expand Up @@ -296,8 +305,8 @@ test('fonts are serialized by VM', t => {

fontManager.addSystemFont('DejaVu Sans', 'sans-serif');
const fontAsset = storage.createAsset(
storage.AssetType.Font,
storage.DataFormat.TTF,
FontAssetType,
TTFDataFormat,
new Uint8Array([10, 11, 12]),
null,
true
Expand Down Expand Up @@ -356,8 +365,8 @@ test('serialization and deserialization roundtrip - project', t => {
// Add our custom fonts here
fontManager.addSystemFont('Ubuntu Mono', 'monospace');
const fontAsset = storage.createAsset(
storage.AssetType.Font,
storage.DataFormat.TTF,
FontAssetType,
TTFDataFormat,
new Uint8Array([20, 21, 22]),
null,
true
Expand Down

0 comments on commit 936e07a

Please sign in to comment.