<commit_before>import sinon from 'sinon';
import { graphql } from 'graphql';
import schema from '../../schema';

describe('PartnerShow type', () => {
  const PartnerShow = schema.__get__('PartnerShow');

  beforeEach(() => {
    const gravity = sinon.stub();
    const total = sinon.stub();

    gravity.returns(Promise.resolve({
      id: 'new-museum-1-2015-triennial-surround-audience',
      start_at: '2015-02-25T12:00:00+00:00',
      end_at: '2015-05-24T12:00:00+00:00',
      press_release: '**foo** *bar*',
      displayable: true,
    }));

    total
      .onCall(0).returns(Promise.resolve(42))
      .onCall(1).returns(Promise.resolve(2));

    PartnerShow.__Rewire__('gravity', gravity);
    PartnerShow.__Rewire__('total', total);
  });

  afterEach(() => {
    PartnerShow.__ResetDependency__('gravity');
    PartnerShow.__ResetDependency__('total');
  });

  it('includes a formattable start and end date', () => {
    const query = `
      {
        partner_show(id: "new-museum-1-2015-triennial-surround-audience") {
          id
          start_at(format: "dddd, MMMM Do YYYY, h:mm:ss a")
          end_at(format: "YYYY")
        }
      }
    `;

    return graphql(schema, query)
      .then(({ data }) => {
        PartnerShow.__get__('gravity').args[0][0]
          .should.equal('show/new-museum-1-2015-triennial-surround-audience');

        data.should.eql({
          partner_show: {
            id: 'new-museum-1-2015-triennial-surround-audience',
            start_at: 'Wednesday, February 25th 2015, 12:00:00 pm',
            end_at: '2015',
          },
        });
      });
  });

  it('includes a formatted exhibition period', () => {
     const query = `
      {
        partner_show(id: "new-museum-1-2015-triennial-surround-audience") {
          exhibition_period
        }
      }
    `;

    return graphql(schema, query)
      .then(({ data }) => {
        data.should.eql({
          partner_show: {
            exhibition_period: 'February 25th - May 24th, 2015'
          },
        });
      });
  });

  it('includes the html version of markdown', () => {
    const query = `
      {
        partner_show(id: "new-museum-1-2015-triennial-surround-audience") {
          press_release(format: markdown)
        }
      }
    `;

    return graphql(schema, query)
      .then(({ data }) => {
        PartnerShow.__get__('gravity').args[0][0]
          .should.equal('show/new-museum-1-2015-triennial-surround-audience');

        data.should.eql({
          partner_show: {
            press_release: '<p><strong>foo</strong> <em>bar</em></p>\n',
          },
        });
      });
  });

  it('includes the total number of artworks', () => {
    const query = `
      {
        partner_show(id: "new-museum-1-2015-triennial-surround-audience") {
          artworks_count
        }
      }
    `;

    return graphql(schema, query)
      .then(({ data }) => {
        data.should.eql({
          partner_show: {
            artworks_count: 42,
          },
        });
      });
  });

  it('includes the number of artworks by a specific artist', () => {
    const query = `
      {
        partner_show(id: "new-museum-1-2015-triennial-surround-audience") {
          artworks_count(artist_id: "juliana-huxtable")
        }
      }
    `;

    return graphql(schema, query)
      .then(({ data }) => {
        data.should.eql({
          partner_show: {
            artworks_count: 2,
          },
        });
      });
  });
});<commit_msg>Passing specs<commit_after>import sinon from 'sinon';
import { graphql } from 'graphql';
import schema from '../../schema';

describe('PartnerShow type', () => {
  const PartnerShow = schema.__get__('PartnerShow');
  let total = null;

  beforeEach(() => {
    const gravity = sinon.stub();

    total = sinon.stub();

    gravity.returns(Promise.resolve({
      id: 'new-museum-1-2015-triennial-surround-audience',
      start_at: '2015-02-25T12:00:00+00:00',
      end_at: '2015-05-24T12:00:00+00:00',
      press_release: '**foo** *bar*',
      displayable: true,
      partner: {
        id: 'new-museum',
      },
    }));

    PartnerShow.__Rewire__('gravity', gravity);
    PartnerShow.__Rewire__('total', total);
  });

  afterEach(() => {
    PartnerShow.__ResetDependency__('gravity');
    PartnerShow.__ResetDependency__('total');
  });

  it('includes a formattable start and end date', () => {
    const query = `
      {
        partner_show(id: "new-museum-1-2015-triennial-surround-audience") {
          id
          start_at(format: "dddd, MMMM Do YYYY, h:mm:ss a")
          end_at(format: "YYYY")
        }
      }
    `;

    return graphql(schema, query)
      .then(({ data }) => {
        PartnerShow.__get__('gravity').args[0][0]
          .should.equal('show/new-museum-1-2015-triennial-surround-audience');

        data.should.eql({
          partner_show: {
            id: 'new-museum-1-2015-triennial-surround-audience',
            start_at: 'Wednesday, February 25th 2015, 12:00:00 pm',
            end_at: '2015',
          },
        });
      });
  });

  it('includes a formatted exhibition period', () => {
    const query = `
      {
        partner_show(id: "new-museum-1-2015-triennial-surround-audience") {
          exhibition_period
        }
      }
    `;

    return graphql(schema, query)
      .then(({ data }) => {
        data.should.eql({
          partner_show: {
            exhibition_period: 'February 25th - May 24th, 2015',
          },
        });
      });
  });

  it('includes the html version of markdown', () => {
    const query = `
      {
        partner_show(id: "new-museum-1-2015-triennial-surround-audience") {
          press_release(format: markdown)
        }
      }
    `;

    return graphql(schema, query)
      .then(({ data }) => {
        PartnerShow.__get__('gravity').args[0][0]
          .should.equal('show/new-museum-1-2015-triennial-surround-audience');

        data.should.eql({
          partner_show: {
            press_release: '<p><strong>foo</strong> <em>bar</em></p>\n',
          },
        });
      });
  });

  it('includes the total number of artworks', () => {
    total
      .onCall(0)
      .returns(Promise.resolve(42));

    const query = `
      {
        partner_show(id: "new-museum-1-2015-triennial-surround-audience") {
          artworks_count
        }
      }
    `;

    return graphql(schema, query)
      .then(({ data }) => {
        data.should.eql({
          partner_show: {
            artworks_count: 42,
          },
        });
      });
  });

  it('includes the number of artworks by a specific artist', () => {
    total
      .onCall(0)
      .returns(Promise.resolve(2));

    const query = `
      {
        partner_show(id: "new-museum-1-2015-triennial-surround-audience") {
          artworks_count(artist_id: "juliana-huxtable")
        }
      }
    `;

    return graphql(schema, query)
      .then(({ data }) => {
        data.should.eql({
          partner_show: {
            artworks_count: 2,
          },
        });
      });
  });
});
{'fraction_non_alphanumeric': 0.16319886765746638, 'fraction_numerical': 0.033121019108280254, 'mean_word_length': 2.0004246284501064, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7630974', 'n_tokens_mistral': 2495, 'n_tokens_neox': 2334, 'n_words': 365}