Exemple #1
0
  it(`allows assetPrefix to be a URL with nested paths`, () => {
    const config = {
      assetPrefix: `https://cdn.example.com/some/nested/path`,
    }

    expect(gatsbyConfigSchema.validate(config)).resolves.toEqual(config)
  })
Exemple #2
0
  it(`allows assetPrefix to be full URL`, () => {
    const config = {
      assetPrefix: `https://cdn.example.com`,
    }

    expect(gatsbyConfigSchema.validate(config)).resolves.toEqual(config)
  })
Exemple #3
0
  it(`allows relative paths for url fields`, () => {
    const config = {
      pathPrefix: `/blog`,
      assetPrefix: `https://cdn.example.com`,
    }

    expect(gatsbyConfigSchema.validate(config)).resolves.toEqual(config)
  })
Exemple #4
0
  it(`does not allow pathPrefix to be full URL`, () => {
    const config = {
      pathPrefix: `https://google.com`,
    }

    expect(
      gatsbyConfigSchema.validate(config)
    ).rejects.toThrowErrorMatchingSnapshot()
  })
Exemple #5
0
  it(`throws when relative path used for both assetPrefix and pathPrefix`, () => {
    const config = {
      assetPrefix: `/assets`,
      pathPrefix: `/blog`,
    }

    expect(
      gatsbyConfigSchema.validate(config)
    ).rejects.toThrowErrorMatchingSnapshot()
  })
Exemple #6
0
  it(`strips trailing slashes from url fields`, () => {
    const config = {
      pathPrefix: `/blog///`,
      assetPrefix: `https://cdn.example.com/`,
    }

    expect(gatsbyConfigSchema.validate(config)).resolves.toEqual({
      pathPrefix: `/blog`,
      assetPrefix: `https://cdn.example.com`,
    })
  })