-
Notifications
You must be signed in to change notification settings - Fork 54
/
types.test.ts
34 lines (31 loc) · 1.34 KB
/
types.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import * as NftMetadata from '../../src/NftMetadata';
import { InvalidStringError } from '@cardano-sdk/core';
describe('NftMetadata/types', () => {
describe('Uri', () => {
it('accepts a string starting with protocol://', () => {
expect(() => NftMetadata.Uri('http://some.url')).not.toThrow();
expect(() => NftMetadata.Uri('ipfs://abc123')).not.toThrow();
});
it('throws for string without protocol:// prefix', () => {
expect(() => NftMetadata.Uri('abc123')).toThrowError(InvalidStringError);
});
});
describe('ImageMediaType', () => {
it('accepts a string starting with image/', () => {
expect(() => NftMetadata.ImageMediaType('image/svg+xml')).not.toThrow();
});
it('throws for non-image media type', () => {
expect(() => NftMetadata.ImageMediaType('video/webm')).toThrowError(InvalidStringError);
});
});
describe('MediaType', () => {
it('accepts any media type in format "type/subtype"', () => {
expect(() => NftMetadata.MediaType('image/svg+xml')).not.toThrow();
expect(() => NftMetadata.MediaType('video/mp4')).not.toThrow();
expect(() => NftMetadata.MediaType('audio/x-wav')).not.toThrow();
});
it('throws for incorrectly formatted media type', () => {
expect(() => NftMetadata.MediaType('videomp4')).toThrowError(InvalidStringError);
});
});
});