Skip to content

Commit

Permalink
Fetch pages in different lang
Browse files Browse the repository at this point in the history
  • Loading branch information
celineung authored and sbedeau committed Apr 19, 2021
1 parent 50c29a3 commit 681b9c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions services/get-routes-to-generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ async function getRoutesInPage(api, page) {
const { results, total_pages: totalPages } = await api.query('', {
pageSize: 100,
page,
lang: '*',
})
const uids = _.map(results, 'uid')
const routes = _.reject(uids, _.isEmpty)
Expand Down
24 changes: 20 additions & 4 deletions tests/services/get-routes-to-generate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ describe('#getRoutesToGenerate', () => {
const result = await getRoutesToGenerate(prismic)

// Then
expect(prismicApi.query).toBeCalledWith('', { pageSize: 100, page: 1 })
expect(prismicApi.query).toBeCalledWith('', {
lang: '*',
pageSize: 100,
page: 1,
})
expect(result).toEqual(expected)
})

Expand All @@ -35,7 +39,11 @@ describe('#getRoutesToGenerate', () => {
const result = await getRoutesToGenerate(prismic)

// Then
expect(prismicApi.query).toBeCalledWith('', { pageSize: 100, page: 1 })
expect(prismicApi.query).toBeCalledWith('', {
lang: '*',
pageSize: 100,
page: 1,
})
expect(result).toEqual(expected)
})

Expand Down Expand Up @@ -67,8 +75,16 @@ describe('#getRoutesToGenerate', () => {
const result = await getRoutesToGenerate(prismic)

// Then
expect(prismicApi.query).toBeCalledWith('', { pageSize: 100, page: 1 })
expect(prismicApi.query).toBeCalledWith('', { pageSize: 100, page: 2 })
expect(prismicApi.query).toBeCalledWith('', {
lang: '*',
pageSize: 100,
page: 1,
})
expect(prismicApi.query).toBeCalledWith('', {
lang: '*',
pageSize: 100,
page: 2,
})
expect(result).toEqual(expected)
})
})

0 comments on commit 681b9c0

Please sign in to comment.