diff --git a/test/unit/__snapshots__/metadata.test.ts.snap b/test/unit/__snapshots__/metadata.test.ts.snap new file mode 100644 index 0000000..ff5282b --- /dev/null +++ b/test/unit/__snapshots__/metadata.test.ts.snap @@ -0,0 +1,17 @@ +// Vitest Snapshot v1 + +exports[`Metadata Object > get commentID() 1`] = `undefined`; + +exports[`Metadata Object > get commentID() 2`] = `undefined`; + +exports[`Metadata Object > get commentID() 3`] = `"123456789"`; + +exports[`Metadata Object > get commentID() 4`] = `"123456789"`; + +exports[`Metadata Object > get tag() 1`] = `undefined`; + +exports[`Metadata Object > get tag() 2`] = `"v1"`; + +exports[`Metadata Object > get tag() 3`] = `undefined`; + +exports[`Metadata Object > get tag() 4`] = `"v1"`; diff --git a/test/unit/fixtures/metadata.fixture.ts b/test/unit/fixtures/metadata.fixture.ts index 9cac60a..8201b1e 100644 --- a/test/unit/fixtures/metadata.fixture.ts +++ b/test/unit/fixtures/metadata.fixture.ts @@ -6,7 +6,12 @@ export interface IMetadataTestContext { } export const metadataContextFixture: IMetadataTestContext = { - metadata: [new Metadata({ tag: undefined, commentID: undefined })], + metadata: [ + new Metadata({ tag: undefined, commentID: undefined }), + new Metadata({ tag: 'v1', commentID: undefined }), + new Metadata({ tag: undefined, commentID: '123456789' }), + new Metadata({ tag: 'v1', commentID: '123456789' }), + ], invalid: [ // @ts-expect-error: Let's ignore a type error, it's required for testing @@ -21,5 +26,9 @@ export const metadataContextFixture: IMetadataTestContext = { new Metadata({}), // @ts-expect-error: Let's ignore a type error, it's required for testing new Metadata([]), + // @ts-expect-error: Let's ignore a type error, it's required for testing + new Metadata({ tag: null, commentID: null }), + // @ts-expect-error: Let's ignore a type error, it's required for testing + new Metadata({ tag: undefined, commentID: 123456789 }), ], }; diff --git a/test/unit/metadata.test.ts b/test/unit/metadata.test.ts index b4cc854..372bd56 100644 --- a/test/unit/metadata.test.ts +++ b/test/unit/metadata.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, beforeEach } from 'vitest'; +import { describe, it, expect, beforeEach, test } from 'vitest'; import { metadataContextFixture, @@ -11,7 +11,31 @@ describe('Metadata Object', () => { context.invalid = metadataContextFixture.invalid; }); - it('can be instantiated', context => { - context.metadata.map(item => expect(item).toBeDefined()); - }); + it('can be instantiated', context => + context.metadata.map(metadataItem => expect(metadataItem).toBeDefined())); + + it.todo( + 'is invalid' /*, async context => { + context.invalid.map(async item => + expect(Metadata.validate(item)).resolves.toMatchSnapshot() + ); + }*/ + ); + + test('get tag()', context => + context.metadata.map(metadataItem => + expect(metadataItem.tag).toMatchSnapshot() + )); + + test.todo('set tag()'); + + test('get commentID()', context => + context.metadata.map(metadataItem => + expect(metadataItem.commentID).toMatchSnapshot() + )); + + test.todo('set commentID()'); + + test.todo('getMetadata()'); + test.todo('setMetadata()'); });