Skip to content

Commit

Permalink
Merge pull request #222 from datocms/add-test-locale-filtering
Browse files Browse the repository at this point in the history
Add test for locales filter
  • Loading branch information
souljuse authored Jun 12, 2023
2 parents d99e2b2 + 52ef77f commit af17da0
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/__snapshots__/graphql.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,41 @@ https://www.datocms-assets.com/34723/1620629638-plant.jpeg?crop=focalpoint&dpr=1
}
`;

exports[`filter by locale 1`] = `
Object {
"data": Object {
"enResults": Object {
"nodes": Array [
Object {
"locales": Array [
"en",
],
"title": "English title",
},
Object {
"locales": Array [
"en",
"it",
],
"title": "English title",
},
],
},
"itResults": Object {
"nodes": Array [
Object {
"locales": Array [
"en",
"it",
],
"title": null,
},
],
},
},
}
`;

exports[`focalPoints 1`] = `
Object {
"data": Object {
Expand Down
29 changes: 29 additions & 0 deletions test/graphql.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,35 @@ test('items', async () => {
expect(result).toMatchSnapshot();
});

test('filter by locale', async () => {
const query = /* GraphQL */ `
{
itResults: allDatoCmsOptionalLocalesModel(
locale: "it"
filter: { locales: { in: ["it"] } }
) {
nodes {
locales
title
}
}
enResults: allDatoCmsOptionalLocalesModel(
locale: "en"
filter: { locales: { in: ["en"] } }
) {
nodes {
locales
title
}
}
}
`;

const result = await executeQuery(query);

expect(result).toMatchSnapshot();
});

test('_allXXXLocales with fallback', async () => {
const query = /* GraphQL */ `
{
Expand Down

0 comments on commit af17da0

Please sign in to comment.