Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cezar-guimaraes committed Feb 10, 2022
1 parent ddb64e6 commit d900804
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/gatsby-plugin-nginx/test/nginx-generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ describe('convert Gatsby paths into nginx RegExp', () => {
it('handles wildcard (*)', () => {
expect(convertToRegExp('/*')).toEqual('^/(.*)$')
expect(convertToRegExp('/*/')).toEqual('^/(.*)$')
expect(convertToRegExp('/pt/*')).toEqual('^/pt/(.*)$')
expect(convertToRegExp('/*/*')).toEqual('^/(.*)(?:/(.*))?$')
expect(convertToRegExp('/pt/*')).toEqual('^/pt(?:/(.*))?$')
})
})

Expand Down Expand Up @@ -109,7 +110,7 @@ describe('generateRewrites', () => {
},
{
children: [{ cmd: ['rewrite', '.+', '/pt/__client-side-search__'] }],
cmd: ['location', '~*', '"^/pt/(.*)$"'],
cmd: ['location', '~*', '"^/pt(?:/(.*))?$"'],
},
{
children: [{ cmd: ['rewrite', '.+', '/foo-path'] }],
Expand Down Expand Up @@ -147,7 +148,7 @@ describe('generateRewrites', () => {
{ cmd: ['proxy_cookie_domain', 'other-domain.com', '$host'] },
{ cmd: ['proxy_cookie_path', '/api/auth', '/'] },
],
cmd: ['location', '~*', '"^/api/auth/(.*)$"'],
cmd: ['location', '~*', '"^/api/auth(?:/(.*))?$"'],
},
]

Expand All @@ -173,7 +174,7 @@ describe('generateRedirects', () => {
it('correctly translates into NginxDirectives', () => {
const expected = [
{
cmd: ['location', '~*', '"^/api/(.*)$"'],
cmd: ['location', '~*', '"^/api(?:/(.*))?$"'],
children: [
{
cmd: [
Expand All @@ -185,7 +186,7 @@ describe('generateRedirects', () => {
],
},
{
cmd: ['location', '~*', '"^/graphql/(.*)$"'],
cmd: ['location', '~*', '"^/graphql(?:/(.*))?$"'],
children: [
{
cmd: [
Expand Down Expand Up @@ -320,6 +321,11 @@ describe('generateNginxConfiguration', () => {
add_header c \\"d\\";
add_header e \\"f\\";
}
location ~ ^(?<no_slash>.+)/$ {
rewrite .+ $no_slash;
add_header c \\"d\\";
add_header e \\"f\\";
}
location = /foo {
add_header a \\"b\\";
try_files /foo/index.html =404;
Expand Down

0 comments on commit d900804

Please sign in to comment.