Skip to content

Commit

Permalink
fix: πŸ› allow empty str author,generator,keywords in manifest (#71)
Browse files Browse the repository at this point in the history
* fix: πŸ› allow empty str author,generator,keywords in manifest

βœ… Closes: #70

* chore: πŸ€– update changelog

* chore: πŸ€– fix typo
  • Loading branch information
theashraf committed Apr 25, 2024
1 parent a641781 commit 340d9aa
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 10 deletions.
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

0 comments on commit 340d9aa

Please sign in to comment.