<commit_before>// vim: tabstop=2:softtabstop=2:shiftwidth=2 

var frisby   = require('frisby');
var datatest = require('./data');
var util     = require('util');
var url      = require('url');

module.exports = {
  runTalkTests : runTalkTests
}

function runTalkTests(userAccessToken, talks_uri) {
  testCreateTalkFailsIfNotLoggedIn(talks_uri);
  testCreateTalkFailsWithIncorrectData(userAccessToken, talks_uri);
}

function testCreateTalkFailsIfNotLoggedIn(talks_uri)
{
  frisby.create('Create talk fails if not logged in')
    .post(
      talks_uri,
      {},
      {json: true}
    )
    .afterJSON(function(result) {
      expect(result[0]).toContain("You must be logged in");
    })
    .expectStatus(400) // fails as no user token
    .toss();
}

function testCreateTalkFailsWithIncorrectData(access_token, talks_uri) {
  frisby.create('Create talk fails with missing name')
      .post(
      talks_uri,
      {},
      {json : true, headers : {'Authorization' : 'oauth ' + access_token}}
  )
      .expectStatus(400)
      .afterJSON(function (result) {
        expect(result[0]).toContain("The \'talk_title\' field is required");
      })
      .toss();

    frisby.create('Create talk fails with missing description')
        .post(
        talks_uri,
        {'talk_title' : 'talk_title'},
        {json : true, headers : {'Authorization' : 'oauth ' + access_token}}
    )
        .expectStatus(400)
        .afterJSON(function (result) {
            expect(result[0]).toContain("The \'talk_description\' field is required");
        })
        .toss();

    frisby.create('Create talk fails with missing date and time')
        .post(
        talks_uri,
        {
            'talk_title' : 'talk_title',
            'talk_description' : 'talk-description',
        },
        {json : true, headers : {'Authorization' : 'oauth ' + access_token}}
    )
        .expectStatus(400)
        .afterJSON(function (result) {
            expect(result[0]).toContain("The \'start_date\' field is required");
        })
        .toss();

    frisby.create('Create talk fails with missing type')
        .post(
        baseURL + "/v2.1/events/" + eventId + "/talks",
        {<commit_msg>Use talks_uri in 'Create talk fails with missing type' test<commit_after>// vim: tabstop=2:softtabstop=2:shiftwidth=2 

var frisby   = require('frisby');
var datatest = require('./data');
var util     = require('util');
var url      = require('url');

module.exports = {
  runTalkTests : runTalkTests
}

function runTalkTests(userAccessToken, talks_uri) {
  testCreateTalkFailsIfNotLoggedIn(talks_uri);
  testCreateTalkFailsWithIncorrectData(userAccessToken, talks_uri);
}

function testCreateTalkFailsIfNotLoggedIn(talks_uri)
{
  frisby.create('Create talk fails if not logged in')
    .post(
      talks_uri,
      {},
      {json: true}
    )
    .afterJSON(function(result) {
      expect(result[0]).toContain("You must be logged in");
    })
    .expectStatus(400) // fails as no user token
    .toss();
}

function testCreateTalkFailsWithIncorrectData(access_token, talks_uri) {
  frisby.create('Create talk fails with missing name')
      .post(
      talks_uri,
      {},
      {json : true, headers : {'Authorization' : 'oauth ' + access_token}}
  )
      .expectStatus(400)
      .afterJSON(function (result) {
        expect(result[0]).toContain("The \'talk_title\' field is required");
      })
      .toss();

    frisby.create('Create talk fails with missing description')
        .post(
        talks_uri,
        {'talk_title' : 'talk_title'},
        {json : true, headers : {'Authorization' : 'oauth ' + access_token}}
    )
        .expectStatus(400)
        .afterJSON(function (result) {
            expect(result[0]).toContain("The \'talk_description\' field is required");
        })
        .toss();

    frisby.create('Create talk fails with missing date and time')
        .post(
        talks_uri,
        {
            'talk_title' : 'talk_title',
            'talk_description' : 'talk-description',
        },
        {json : true, headers : {'Authorization' : 'oauth ' + access_token}}
    )
        .expectStatus(400)
        .afterJSON(function (result) {
            expect(result[0]).toContain("The \'start_date\' field is required");
        })
        .toss();

    frisby.create('Create talk fails with missing type')
        .post(
        talks_uri,
        {
{'fraction_non_alphanumeric': 0.13488266119845066, 'fraction_numerical': 0.00911369332421964, 'mean_word_length': 2.655287260616153, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1187618', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1367, 'n_words': 288}