Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 allow empty str author,generator,keywords in manifest #71

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tall-flowers-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@dotlottie/dotlottie-js": patch
---

fix: 🐛 allow empty str author,generator,keywords in manifest
20 changes: 10 additions & 10 deletions packages/dotlottie-js/src/common/dotlottie-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,31 +167,31 @@ export class DotLottieCommon {
}

public setAuthor(author: string | undefined): DotLottieCommon {
this._author = author ?? 'LottieFiles';
this._author = typeof author === 'string' ? author : 'LottieFiles';

return this;
}

public setDescription(description: string | undefined): DotLottieCommon {
this._description = description ?? '';
this._description = typeof description === 'string' ? description : '';

return this;
}

public setGenerator(generator: string | undefined): DotLottieCommon {
this._generator = generator ?? `${pkg.name}@${pkg.version}`;
this._generator = typeof generator === 'string' ? generator : `${pkg.name}@${pkg.version}`;

return this;
}

public setKeywords(keywords: string | undefined): DotLottieCommon {
this._keywords = keywords ?? 'dotLottie';
this._keywords = typeof keywords === 'string' ? keywords : 'dotLottie';

return this;
}

public setVersion(version: string | undefined): DotLottieCommon {
this._version = version ?? '1.0';
this._version = typeof version === 'string' ? version : '1.0';

return this;
}
Expand Down Expand Up @@ -699,23 +699,23 @@ export class DotLottieCommon {
}

protected _requireValidAuthor(author: string | undefined): asserts author is string {
if (!author) throw createError('Invalid author');
if (typeof author !== 'string') throw createError('Invalid author');
}

protected _requireValidDescription(description: string | undefined): asserts description is string {
if (!description) throw createError('Invalid description');
if (typeof description !== 'string') throw createError('Invalid description');
}

protected _requireValidGenerator(generator: string | undefined): asserts generator is string {
if (!generator) throw createError('Invalid generator');
if (typeof generator !== 'string') throw createError('Invalid generator');
}

protected _requireValidKeywords(keywords: string | undefined): asserts keywords is string {
if (!keywords) throw createError('Invalid keywords');
if (typeof keywords !== 'string') throw createError('Invalid keywords');
}

protected _requireValidVersion(version: string | undefined): asserts version is string {
if (!version) throw createError('Invalid version');
if (typeof version !== 'string') throw createError('Invalid version');
}

protected _requireValidCustomData(
Expand Down
40 changes: 40 additions & 0 deletions packages/dotlottie-js/src/tests/dotlottie-js-browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ describe('DotLottie', () => {

expect(dotlottie.version).toBe(version);
});

it('accepts empty string', () => {
const dotlottie = new DotLottie();

dotlottie.setVersion('');

expect(dotlottie.version).toBe('');
});
});

describe('setAuthor', () => {
Expand All @@ -71,6 +79,14 @@ describe('DotLottie', () => {

expect(dotlottie.author).toBe('Design Barn');
});

it('accepts empty string', () => {
const dotlottie = new DotLottie();

dotlottie.setAuthor('');

expect(dotlottie.author).toBe('');
});
});

describe('setRevision', () => {
Expand Down Expand Up @@ -109,6 +125,14 @@ describe('DotLottie', () => {

expect(dotlottie.description).toBe('A description');
});

it('accepts empty string', () => {
const dotlottie = new DotLottie();

dotlottie.setDescription('');

expect(dotlottie.description).toBe('');
});
});

describe('setGenerator', () => {
Expand All @@ -135,6 +159,14 @@ describe('DotLottie', () => {

expect(dotLottie.generator).toBe(`${pkg.name}@${pkg.version}`);
});

it('accepts empty string', () => {
const dotlottie = new DotLottie();

dotlottie.setGenerator('');

expect(dotlottie.generator).toBe('');
});
});

describe('setRevision', () => {
Expand Down Expand Up @@ -175,6 +207,14 @@ describe('DotLottie', () => {

expect(dotlottie.keywords).toBe(keywords);
});

it('accepts empty string', () => {
const dotlottie = new DotLottie();

dotlottie.setKeywords('');

expect(dotlottie.keywords).toBe('');
});
});

describe('addAnimation', () => {
Expand Down
40 changes: 40 additions & 0 deletions packages/dotlottie-js/src/tests/dotlottie-js-node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ describe('DotLottie', () => {

expect(dotlottie.version).toBe(version);
});

it('accepts empty string', () => {
const dotlottie = new DotLottie();

dotlottie.setVersion('');

expect(dotlottie.version).toBe('');
});
});

describe('setAuthor', () => {
Expand All @@ -71,6 +79,14 @@ describe('DotLottie', () => {

expect(dotlottie.author).toBe('Design Barn');
});

it('accepts empty string', () => {
const dotlottie = new DotLottie();

dotlottie.setAuthor('');

expect(dotlottie.author).toBe('');
});
});

describe('setRevision', () => {
Expand Down Expand Up @@ -109,6 +125,14 @@ describe('DotLottie', () => {

expect(dotlottie.description).toBe('A description');
});

it('accepts empty string', () => {
const dotlottie = new DotLottie();

dotlottie.setDescription('');

expect(dotlottie.description).toBe('');
});
});

describe('setGenerator', () => {
Expand All @@ -135,6 +159,14 @@ describe('DotLottie', () => {

expect(dotLottie.generator).toBe(`${pkg.name}/node@${pkg.version}`);
});

it('accepts empty string', () => {
const dotlottie = new DotLottie();

dotlottie.setGenerator('');

expect(dotlottie.generator).toBe('');
});
});

describe('setRevision', () => {
Expand Down Expand Up @@ -175,6 +207,14 @@ describe('DotLottie', () => {

expect(dotlottie.keywords).toBe(keywords);
});

it('accepts empty string', () => {
const dotlottie = new DotLottie();

dotlottie.setKeywords('');

expect(dotlottie.keywords).toBe('');
});
});

describe('addAnimation', () => {
Expand Down
Loading