Beispiel #1
0
  it("is_publically_visible returns false when profile is not published", () => {
    const profile = {
      id: "context",
      published: false,
      private: false,
    }

    rootValue.profileLoader = sinon.stub().returns(Promise.resolve(profile))

    return runQuery(query, rootValue).then(data => {
      expect(data).toEqual({
        fair: {
          id: "the-armory-show-2017",
          name: "The Armory Show 2017",
          organizer: {
            profile_id: "the-armory-show",
            profile: {
              is_publically_visible: false,
            },
          },
          mobile_image: {
            image_url: "circle-image.jpg",
          },
        },
      })
    })
  })
 it("resolves a node", () => {
   const query = `
     {
       node(__id: "${globalId}") {
         __typename
         ... on HomePageArtworkModule {
           key
           params {
             related_artist_id
             followed_artist_id
           }
         }
       }
     }
   `
   return runQuery(query).then(data => {
     expect(data).toEqual({
       node: {
         __typename: "HomePageArtworkModule",
         key: "related_artists",
         params: {
           related_artist_id: "charles-broskoski",
           followed_artist_id: "pablo-picasso",
         },
       },
     })
   })
 })
Beispiel #3
0
    it("detects square", () => {
      assign(image, { original_width: 2000, original_height: 2000 })

      return runQuery(query, rootValue).then(data => {
        expect(data.artwork.image.orientation).toBe("square")
      })
    })
Beispiel #4
0
    it("fetches an artist by ID", () => {
      const query = `
        {
          artist(id: "foo-bar") {
            id
            carousel {
              images {
                href
                resized(width: 300) {
                  url
                  width
                  height
                }
              }
            }
          }
        }
      `

      return runQuery(query, rootValue).then(data => {
        expect(data.artist.carousel).toEqual({
          images: [
            {
              href: "/artwork/foo-bar-artwork-1",
              resized: {
                height: 199,
                width: 300,
                url: "https://gemini.cloudfront.test/?resize_to=fit&width=300&height=199&quality=95&src=https%3A%2F%2Fxxx.cloudfront.net%2Fxxx%2Flarge.jpg", // eslint-disable-line
              },
            },
          ],
        })
      })
    })
Beispiel #5
0
    it("is square by default (when there is no image geometry)", () => {
      assign(image, { original_width: null, original_height: null })

      return runQuery(query, rootValue).then(data => {
        expect(data.artwork.image.orientation).toBe("square")
      })
    })
Beispiel #6
0
    it("detects portrait", () => {
      assign(image, { original_width: 1000, original_height: 1500 })

      return runQuery(query, rootValue).then(data => {
        expect(data.artwork.image.orientation).toBe("portrait")
      })
    })
Beispiel #7
0
 it("returns the blurb if present", () => {
   artist.blurb = "catty blurb"
   const query = `
     {
       artist(id: "foo-bar") {
         biography_blurb {
           text
           credit
           partner_id
         }
       }
     }
   `
   return runQuery(query, rootValue).then(data => {
     expect(data).toEqual({
       artist: {
         biography_blurb: {
           text: "catty blurb",
           credit: null,
           partner_id: null,
         },
       },
     })
   })
 })
Beispiel #8
0
 it("excludes shows from private partners for exhibition highlights", () => {
   const query = `
     {
       artist(id: "foo-bar") {
         exhibition_highlights {
           id
         }
       }
     }
   `
   return runQuery(query, rootValue).then(data => {
     expect(data).toEqual({
       artist: {
         exhibition_highlights: [
           {
             id: "ok",
           },
           {
             id: "galaxy-partner",
           },
         ],
       },
     })
   })
 })
Beispiel #9
0
  it("queries match/artist for the term 'ok'", () => {
    const query = `
      {
        match_artist(term: "ok") {
          id
          name
          birthday
        }
      }
    `
    const matchArtistsLoader = () =>
      Promise.resolve([
        {
          id: "han-myung-ok",
          name: "Han Myung-Ok",
          birthday: "1958",
          artworks_count: 12,
        },
      ])

    return runQuery(query, { matchArtistsLoader }).then(data => {
      expect(data).toEqual({
        match_artist: [
          { birthday: "1958", id: "han-myung-ok", name: "Han Myung-Ok" },
        ],
      })
    })
  })
Beispiel #10
0
 it("returns the artsy blurb if there is no featured partner bio", () => {
   rootValue.partnerArtistsForArtistLoader = sinon
     .stub()
     .returns(Promise.resolve([]))
   artist.blurb = "artsy blurb"
   const query = `
     {
       artist(id: "foo-bar") {
         biography_blurb(partner_bio: true) {
           text
           credit
           partner_id
         }
       }
     }
   `
   return runQuery(query, rootValue).then(data => {
     expect(data).toEqual({
       artist: {
         biography_blurb: {
           text: "artsy blurb",
           credit: null,
           partner_id: null,
         },
       },
     })
   })
 })
 it("resolves a node", () => {
   const query = `
     {
       node(__id: "${globalId}") {
         __typename
         ... on HomePageArtworkModule {
           key
           params {
             id
           }
         }
       }
     }
   `
   return runQuery(query).then(data => {
     expect(data).toEqual({
       node: {
         __typename: "HomePageArtworkModule",
         key: "generic_gene",
         params: {
           id: "abstract-art",
         },
       },
     })
   })
 })
 it("implements the NodeInterface", () => {
   const query = `
     {
       gene(id: "500-1000-ce") {
         name
         filtered_artworks(for_sale: true, aggregations:[TOTAL], medium: "*"){
           __id
         }
       }
     }
   `
   const filterOptions = {
     aggregations: ["total"],
     for_sale: true,
     gene_id: "500-1000-ce",
   }
   const expectedId = toGlobalId(
     "FilterArtworks",
     JSON.stringify(filterOptions)
   )
   return runQuery(query, rootValue).then(
     ({ gene: { filtered_artworks: { __id } } }) => {
       expect(__id).toEqual(expectedId)
     }
   )
 })
Beispiel #13
0
 it("is hangable if the artwork is 2d and has reasonable dimensions", () => {
   artwork.width = 100
   artwork.height = 100
   return runQuery(query, rootValue).then(data => {
     expect(data.artwork.is_hangable).toBe(true)
   })
 })
 it("can return the bid increments, including Gravity's asking price, but then snapped to preset increments", () => {
   gravity
     .onCall(1)
     .returns(
       Promise.resolve({
         increment_strategy: "default",
       })
     )
     .onCall(2)
     .returns(
       Promise.resolve([
         {
           key: "default",
           increments: [
             {
               from: 0,
               to: 399999,
               amount: 5000,
             },
             {
               from: 400000,
               to: 1000000,
               amount: 10000,
             },
           ],
         },
       ])
     )
   const query = `
     {
       sale_artwork(id: "54c7ed2a7261692bfa910200") {
         bid_increments
       }
     }
   `
   return runQuery(query).then(data => {
     expect(data.sale_artwork.bid_increments.slice(0, 20)).toEqual([
       351000,
       355000,
       360000,
       365000,
       370000,
       375000,
       380000,
       385000,
       390000,
       395000,
       400000,
       410000,
       420000,
       430000,
       440000,
       450000,
       460000,
       470000,
       480000,
       490000,
     ])
   })
 })
Beispiel #15
0
 it("is not hangable if the category is not applicable to wall display", () => {
   artwork.category = "sculpture"
   artwork.width = 100
   artwork.height = 100
   return runQuery(query, rootValue).then(data => {
     expect(data.artwork.is_hangable).toBe(false)
   })
 })
Beispiel #16
0
 it("is not hangable if the work is 3d", () => {
   artwork.width = 100
   artwork.height = 100
   artwork.depth = 100
   return runQuery(query, rootValue).then(data => {
     expect(data.artwork.is_hangable).toBe(false)
   })
 })
Beispiel #17
0
 it("is not hangable if the dimensions are unreasonably large", () => {
   artwork.width = "10000"
   artwork.height = "10000"
   artwork.metric = "cm"
   return runQuery(query, rootValue).then(data => {
     expect(data.artwork.is_hangable).toBe(false)
   })
 })
Beispiel #18
0
 it("fetches an artist by ID", () => {
   return runQuery(`{ artist(id: "foo-bar") { id, name } }`, rootValue).then(
     data => {
       expect(data.artist.id).toBe("foo-bar")
       expect(data.artist.name).toBe("Foo Bar")
     }
   )
 })
  it("can return bid increments that are above the size of a GraphQLInt", () => {
    gravity.returns(
      Promise.resolve({
        minimum_next_bid_cents: 2400000000,
      })
    )
    SaleArtwork.__Rewire__("gravity", gravity)

    gravity
      .onCall(1)
      .returns(Promise.resolve({ increment_strategy: "default" }))
      .onCall(2)
      .returns(
        Promise.resolve([
          {
            key: "default",
            increments: [
              {
                from: 0,
                to: 3000000000,
                amount: 1000,
              },
            ],
          },
        ])
      )
    const query = `
      {
        sale_artwork(id: "54c7ed2a7261692bfa910200") {
          bid_increments
        }
      }
    `
    return runQuery(query).then(data => {
      expect(data.sale_artwork.bid_increments.slice(0, 20)).toEqual([
        2400000000,
        2400001000,
        2400002000,
        2400003000,
        2400004000,
        2400005000,
        2400006000,
        2400007000,
        2400008000,
        2400009000,
        2400010000,
        2400011000,
        2400012000,
        2400013000,
        2400014000,
        2400015000,
        2400016000,
        2400017000,
        2400018000,
        2400019000,
      ])
    })
  })
Beispiel #20
0
 it("does not error, but returns null for associated sale", () => {
   return runQuery(query).then(data => {
     expect(data).toEqual({
       sale: {
         _id: "123",
         associated_sale: null,
       },
     })
   })
 })
Beispiel #21
0
 it("is_publically_visible returns true when profile is published", () => {
   return runQuery(query).then(data => {
     expect(data).toEqual({
       profile: {
         id: "the-armory-show",
         is_publically_visible: true,
       },
     })
   })
 })
 const execute = async (
   query,
   gravityResponse = saleArtwork,
   rootValue = {}
 ) => {
   return await runQuery(query, {
     saleArtworkRootLoader: () => Promise.resolve(gravityResponse),
     ...rootValue,
   })
 }
Beispiel #23
0
 it("is Untitled title when its title is empty", () => {
   artwork.title = ""
   return runQuery(query, rootValue).then(data => {
     expect(data).toEqual({
       artwork: {
         title: "Untitled",
       },
     })
   })
 })
Beispiel #24
0
 it("is_publically_visible returns false when profile is private", () => {
   return runQuery(query).then(data => {
     expect(data).toEqual({
       profile: {
         id: "the-armory-show",
         is_publically_visible: false,
       },
     })
   })
 })
 it("formats money correctly", () => {
   const query = `
     {
       sale_artwork(id: "54c7ed2a7261692bfa910200") {
         high_estimate {
           cents
           amount(format: "%v EUROS!")
           display
         }
         low_estimate {
           cents
           amount
           display
         }
         highest_bid {
           cents
           amount
           display
         }
         current_bid {
           cents
           amount
           display
         }
       }
     }
   `
   return runQuery(query).then(data => {
     expect(SaleArtwork.__get__("gravity").args[0][0]).toBe("sale_artwork/54c7ed2a7261692bfa910200")
     expect(data).toEqual({
       sale_artwork: {
         high_estimate: {
           cents: 300000,
           amount: "3,000 EUROS!",
           display: "€3,000",
         },
         low_estimate: {
           cents: 200000,
           amount: "€2,000",
           display: "€2,000",
         },
         highest_bid: {
           cents: 325000,
           amount: "€3,250",
           display: "€3,250",
         },
         current_bid: {
           cents: 325000,
           amount: "€3,250",
           display: "€3,250",
         },
       },
     })
   })
 })
Beispiel #26
0
 it("returns false if artwork price is not a range.", () => {
   artwork.price = "$1000"
   return runQuery(query, rootValue).then(data => {
     expect(data).toEqual({
       artwork: {
         id: "richard-prince-untitled-portrait",
         is_price_range: false,
       },
     })
   })
 })
Beispiel #27
0
 it("returns nothing for a not for sale work", () => {
   artwork.availability = "not for sale"
   return runQuery(query, rootValue).then(data => {
     expect(data).toEqual({
       artwork: {
         id: "richard-prince-untitled-portrait",
         contact_message: null,
       },
     })
   })
 })
Beispiel #28
0
 it("is false if the artwork is not in any sales that are auctions", () => {
   rootValue.salesLoader = sinon.stub().returns(Promise.resolve([]))
   return runQuery(query, rootValue).then(data => {
     expect(data).toEqual({
       artwork: {
         id: "richard-prince-untitled-portrait",
         is_biddable: false,
       },
     })
   })
 })
Beispiel #29
0
 it("returns false if artwork price is a range with multiple editions.", () => {
   artwork.price = "$200 - $300"
   artwork.edition_sets = [{}]
   return runQuery(query, rootValue).then(data => {
     expect(data).toEqual({
       artwork: {
         id: "richard-prince-untitled-portrait",
         is_price_range: false,
       },
     })
   })
 })
Beispiel #30
0
 it("is false if the artwork is acquireable but not in any open sales", () => {
   artwork.acquireable = false
   rootValue.salesLoader = sinon.stub().returns(Promise.resolve([]))
   return runQuery(query, rootValue).then(data => {
     expect(data).toEqual({
       artwork: {
         id: "richard-prince-untitled-portrait",
         is_buy_nowable: false,
       },
     })
   })
 })