Skip to content

Commit cfbac88

Browse files
committed
chore(sound): ignore platforms without web audio support
1 parent 487d7bd commit cfbac88

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/app/model/sound.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ describe('Sound', () => {
4141
expect(zzfxMock).not.toHaveBeenCalled();
4242
});
4343

44-
it('should propagate errors from zzfx', () => {
44+
it('should propagate not errors from zzfx', () => {
4545
zzfxMock.mockImplementation(() => {
4646
throw new Error('Test error');
4747
});
4848

49-
expect(() => sound.play(SOUNDS.SELECT)).toThrow('Test error');
49+
expect(() => sound.play(SOUNDS.SELECT)).not.toThrow('Test error');
5050
});
5151
});
5252
});

src/app/model/sound.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export class Sound {
2020
if (!this.enabled) {
2121
return;
2222
}
23-
zzfx(...sound);
23+
try {
24+
zzfx(...sound);
25+
} catch {
26+
// nope, we ignore platforms which do not support web audio
27+
}
2428
}
2529
}

0 commit comments

Comments
 (0)