Loading src/codegen/__snapshots__/class.test.ts.snap +154 −198 File changed.Preview size limit exceeded, changes collapsed. Show changes src/codegen/codec.ts +2 −2 Original line number Diff line number Diff line Loading @@ -295,8 +295,7 @@ export async function* generateDecoder( for (const subtypeUri of subtypes) { yield ` if (values["@type"].includes(${JSON.stringify(subtypeUri)})) { delete values["@type"]; return await ${types[subtypeUri].name}.fromJsonLd(values, options); return await ${types[subtypeUri].name}.fromJsonLd(json, options); } `; } Loading @@ -315,6 +314,7 @@ export async function* generateDecoder( `; } else { yield ` delete values["@type"]; const instance = await super.fromJsonLd(values, { ...options, // @ts-ignore: an internal option Loading src/vocab/vocab.test.ts +7 −2 Original line number Diff line number Diff line Loading @@ -144,7 +144,7 @@ test("Object.fromJsonLd()", async () => { new LanguageString("你好", "zh"), ]); const create = await Object.fromJsonLd({ const createJsonLd = { "@context": "https://www.w3.org/ns/activitystreams", "type": "Create", "name": "Test", Loading @@ -156,13 +156,18 @@ test("Object.fromJsonLd()", async () => { "type": "Note", "content": "Content", }, }, { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader }); }; const create = await Object.fromJsonLd( createJsonLd, { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader }, ); assertInstanceOf(create, Create); assertEquals(create.name, "Test"); assertEquals(create.contents, [ new LanguageString("Hello", "en"), new LanguageString("你好", "zh"), ]); assertEquals(await create.toJsonLd(), createJsonLd); const note = await create.getObject(); assertInstanceOf(note, Note); assertEquals(note.content, "Content"); Loading Loading
src/codegen/__snapshots__/class.test.ts.snap +154 −198 File changed.Preview size limit exceeded, changes collapsed. Show changes
src/codegen/codec.ts +2 −2 Original line number Diff line number Diff line Loading @@ -295,8 +295,7 @@ export async function* generateDecoder( for (const subtypeUri of subtypes) { yield ` if (values["@type"].includes(${JSON.stringify(subtypeUri)})) { delete values["@type"]; return await ${types[subtypeUri].name}.fromJsonLd(values, options); return await ${types[subtypeUri].name}.fromJsonLd(json, options); } `; } Loading @@ -315,6 +314,7 @@ export async function* generateDecoder( `; } else { yield ` delete values["@type"]; const instance = await super.fromJsonLd(values, { ...options, // @ts-ignore: an internal option Loading
src/vocab/vocab.test.ts +7 −2 Original line number Diff line number Diff line Loading @@ -144,7 +144,7 @@ test("Object.fromJsonLd()", async () => { new LanguageString("你好", "zh"), ]); const create = await Object.fromJsonLd({ const createJsonLd = { "@context": "https://www.w3.org/ns/activitystreams", "type": "Create", "name": "Test", Loading @@ -156,13 +156,18 @@ test("Object.fromJsonLd()", async () => { "type": "Note", "content": "Content", }, }, { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader }); }; const create = await Object.fromJsonLd( createJsonLd, { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader }, ); assertInstanceOf(create, Create); assertEquals(create.name, "Test"); assertEquals(create.contents, [ new LanguageString("Hello", "en"), new LanguageString("你好", "zh"), ]); assertEquals(await create.toJsonLd(), createJsonLd); const note = await create.getObject(); assertInstanceOf(note, Note); assertEquals(note.content, "Content"); Loading