Skip to content

Commit

Permalink
fix!: drop implicit context (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw authored Jan 13, 2025
1 parent 501c9e2 commit 7fc779d
Show file tree
Hide file tree
Showing 133 changed files with 941 additions and 1,142 deletions.
File renamed without changes.
12 changes: 6 additions & 6 deletions packages/schema-org/src/nodes/AggregateOffer/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { injectSchemaOrg, useSetup } from '../../../test'

describe('defineAggregateOffer', () => {
it('can be registered simple', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineAggregateOffer({
lowPrice: 100,
highPrice: 200,
}),
])

const tag = await injectSchemaOrg()
const tag = await injectSchemaOrg(head)

expect(tag).toMatchInlineSnapshot(`
[
Expand All @@ -29,8 +29,8 @@ describe('defineAggregateOffer', () => {
})

it('can be registered offers', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineAggregateOffer({
lowPrice: 100,
highPrice: 200,
Expand All @@ -47,7 +47,7 @@ describe('defineAggregateOffer', () => {
}),
])

const tag = await injectSchemaOrg()
const tag = await injectSchemaOrg(head)

expect(tag).toMatchInlineSnapshot(`
[
Expand Down
64 changes: 32 additions & 32 deletions packages/schema-org/src/nodes/Article/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const defaultArticleInput = {

describe('defineArticle', () => {
it('can be registered', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineArticle(defaultArticleInput),
])

const client = await injectSchemaOrg()
const client = await injectSchemaOrg(head)

expect(client).toMatchInlineSnapshot(`
[
Expand Down Expand Up @@ -50,14 +50,14 @@ describe('defineArticle', () => {
})

it('inherits attributes from useRoute()', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineArticle(),
])

const client = await injectSchemaOrg()
const client = await injectSchemaOrg(head)

const article = await findNode<Article>('#article')
const article = await findNode<Article>(head, '#article')
expect(article?.headline).toEqual('Article headline')
expect(article?.description).toEqual('my article description')
expect(article?.image).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -102,8 +102,8 @@ describe('defineArticle', () => {
})

it('can define article with custom fields', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineArticle<{ somethingNew: 'test' }>({
headline: 'test',
datePublished: mockDate,
Expand All @@ -112,7 +112,7 @@ describe('defineArticle', () => {
}),
])

const client = await injectSchemaOrg()
const client = await injectSchemaOrg(head)
expect(client).toMatchInlineSnapshot(`
[
{
Expand All @@ -130,25 +130,25 @@ describe('defineArticle', () => {
})

it('passes Date objects into iso string', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineArticle({
...defaultArticleInput,
datePublished: new Date(Date.UTC(2021, 10, 1, 0, 0, 0)),
dateModified: new Date(Date.UTC(2022, 1, 1, 0, 0, 0)),
}),
])

const client = await injectSchemaOrg()
const client = await injectSchemaOrg(head)
const article = client[0]
expect(article?.datePublished).toEqual('2021-11-01T00:00:00.000Z')
expect(article?.dateModified).toEqual('2022-02-01T00:00:00.000Z')
})
})

it('allows overriding the type', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineArticle({
'@type': 'TechArticle',
...defaultArticleInput,
Expand All @@ -157,21 +157,21 @@ describe('defineArticle', () => {
}),
])

const client = await injectSchemaOrg()
const client = await injectSchemaOrg(head)
const article = client[0]

expect(article?.['@type']).toEqual(['Article', 'TechArticle'])
})
})

it('adds read action to web page', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineWebPage(),
defineArticle(defaultArticleInput),
])

const client = await injectSchemaOrg()
const client = await injectSchemaOrg(head)
const webpage = client[0]

expect(webpage?.potentialAction).toMatchInlineSnapshot(`
Expand All @@ -188,8 +188,8 @@ describe('defineArticle', () => {
})

it('clones date to web page', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineWebPage(),
defineArticle({
'@id': '#my-article',
Expand All @@ -199,7 +199,7 @@ describe('defineArticle', () => {
}),
])

const client = await injectSchemaOrg()
const client = await injectSchemaOrg(head)
const webpage = client[0]
const article = client[1]

Expand All @@ -209,8 +209,8 @@ describe('defineArticle', () => {
})

it('handles custom author', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineOrganization({
name: 'Identity',
logo: 'test.png',
Expand All @@ -227,7 +227,7 @@ describe('defineArticle', () => {
}),
])

const client = await injectSchemaOrg()
const client = await injectSchemaOrg(head)

expect(client[2]).toMatchInlineSnapshot(`
{
Expand Down Expand Up @@ -274,8 +274,8 @@ describe('defineArticle', () => {
})

it('handles custom authors', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineOrganization({
name: 'Identity',
logo: '/test.png',
Expand All @@ -296,7 +296,7 @@ describe('defineArticle', () => {
}),
])

const client = await injectSchemaOrg()
const client = await injectSchemaOrg(head)

expect(client).toMatchInlineSnapshot(`
[
Expand Down Expand Up @@ -397,16 +397,16 @@ describe('defineArticle', () => {
})

it('can match yoast schema', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineOrganization({
name: 'Kootingal Pecan Company',
logo: 'test',
}),
defineWebPage(),
])

useSchemaOrg([
useSchemaOrg(head, [
defineArticle({
wordCount: 381,
datePublished: '2022-04-06T08:00:51+00:00',
Expand All @@ -430,7 +430,7 @@ describe('defineArticle', () => {
}),
])

const client = await injectSchemaOrg()
const client = await injectSchemaOrg(head)

expect(client[2]).toMatchInlineSnapshot(`
{
Expand Down
6 changes: 3 additions & 3 deletions packages/schema-org/src/nodes/Book/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { injectSchemaOrg, useSetup } from '../../../test'

describe('defineBook', () => {
it('can be registered', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineBook({
url: 'http://example.com/work/the_catcher_in_the_rye',
name: 'The Catcher in the Rye',
Expand All @@ -31,7 +31,7 @@ describe('defineBook', () => {
}),
])

const graphNodes = await injectSchemaOrg()
const graphNodes = await injectSchemaOrg(head)

expect(graphNodes).toMatchInlineSnapshot(`
[
Expand Down
12 changes: 6 additions & 6 deletions packages/schema-org/src/nodes/Breadcrumb/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { injectSchemaOrg, useSetup } from '../../../test'

describe('defineBreadcrumb', async () => {
it('can be registered', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineBreadcrumb({
itemListElement: [
{ name: 'Home', item: '/' },
Expand All @@ -15,7 +15,7 @@ describe('defineBreadcrumb', async () => {
}),
])

const breadcrumbs = await injectSchemaOrg()
const breadcrumbs = await injectSchemaOrg(head)

expect(breadcrumbs).toMatchInlineSnapshot(`
[
Expand Down Expand Up @@ -48,8 +48,8 @@ describe('defineBreadcrumb', async () => {
})

it('can handle duplicate', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineBreadcrumb({
itemListElement: [
{ name: 'Home', item: '/', position: 1 },
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('defineBreadcrumb', async () => {
}),
])

const client = await injectSchemaOrg()
const client = await injectSchemaOrg(head)

expect(client).toMatchInlineSnapshot(`
[
Expand Down
6 changes: 3 additions & 3 deletions packages/schema-org/src/nodes/Comment/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { injectSchemaOrg, useSetup } from '../../../test'

describe('defineComment', () => {
it('can be registered', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineComment({
text: 'This is a comment',
author: {
Expand All @@ -14,7 +14,7 @@ describe('defineComment', () => {
}),
])

const graphNodes = await injectSchemaOrg()
const graphNodes = await injectSchemaOrg(head)
expect(graphNodes).toMatchInlineSnapshot(`
[
{
Expand Down
6 changes: 3 additions & 3 deletions packages/schema-org/src/nodes/Course/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { injectSchemaOrg, useSetup } from '../../../test'

describe('defineCourse', () => {
it('can be registered', async () => {
await useSetup(async () => {
useSchemaOrg([
await useSetup(async (head) => {
useSchemaOrg(head, [
defineCourse({
name: 'Introduction to Computer Science and Programming',
description: 'Introductory CS course laying out the basics.',
Expand All @@ -16,7 +16,7 @@ describe('defineCourse', () => {
}),
])

const graphNodes = await injectSchemaOrg()
const graphNodes = await injectSchemaOrg(head)

expect(graphNodes).toMatchInlineSnapshot(`
[
Expand Down
Loading

0 comments on commit 7fc779d

Please sign in to comment.