<commit_before>var expect = require("chai").expect;
var models = require('../../../models');
var utils = require('../../utils');

var testUser;


var validQuizDescriptorJSON = utils.validDescriptorJSON;


describe('QuizDescriptor', function() {

  beforeEach(function(done) {
    models.sequelize.sync({ force: true }).then(function() {
      models.User.create({ 
        account_type: "google",
        id: "some_id",
        token: "some token",
        email: "<EMAIL>",
        name: "<NAME>",
        role: "author"
      }).then(function(user) {
        testUser = user;
        done();
      });
    });
  });

  it('shouldcreate a quiz descriptor', function(done){
    models.QuizDescriptor.create({descriptor: validQuizDescriptorJSON}).then(function(qd) {
      done();
    });
  });

  it('should use the testUser to create a quiz descriptor', function(done){
    testUser.createQuizDescriptor({descriptor: validQuizDescriptorJSON}).then(function(qd) {
      done();
    });
  });

  it('should create one quiz descriptor for user, and retrieve all expecting 1', function(done){
    testUser.createQuizDescriptor({descriptor: validQuizDescriptorJSON}).then(function(qd) {
      testUser.getQuizDescriptors().then(function(results) {
        expect(results.length).to.equal(1);
        done();
      });
    });
  });

  it('should create two quiz descriptor for user, and retrieve all expecting 2', function(done){
    testUser.createQuizDescriptor({descriptor: validQuizDescriptorJSON}).then(function(qd1) {
      testUser.createQuizDescriptor({descriptor: validQuizDescriptorJSON}).then(function(qd2) {
        testUser.getQuizDescriptors().then(function(results) {
          expect(results.length).to.equal(2);
          done();
        });
      });
    });
  });

});







<commit_msg>Renamed descriptor variable to not get confused with quiz descriptor.<commit_after>var expect = require("chai").expect;
var models = require('../../../models');
var utils = require('../../utils');

var testUser;


var validDescriptor = utils.validDescriptorJSON;


describe('QuizDescriptor', function() {

  beforeEach(function(done) {
    models.sequelize.sync({ force: true }).then(function() {
      models.User.create({ 
        account_type: "google",
        id: "some_id",
        token: "<PASSWORD>",
        email: "<EMAIL>",
        name: "<NAME>",
        role: "author"
      }).then(function(user) {
        testUser = user;
        done();
      });
    });
  });

  it('shouldcreate a quiz descriptor', function(done){
    models.QuizDescriptor.create({descriptor: validDescriptor}).then(function(qd) {
      done();
    });
  });

  it('should use the testUser to create a quiz descriptor', function(done){
    testUser.createQuizDescriptor({descriptor: validDescriptor}).then(function(qd) {
      done();
    });
  });

  it('should create one quiz descriptor for user, and retrieve all expecting 1', function(done){
    testUser.createQuizDescriptor({descriptor: validDescriptor}).then(function(qd) {
      testUser.getQuizDescriptors().then(function(results) {
        expect(results.length).to.equal(1);
        done();
      });
    });
  });

  it('should create two quiz descriptor for user, and retrieve all expecting 2', function(done){
    testUser.createQuizDescriptor({descriptor: validDescriptor}).then(function(qd1) {
      testUser.createQuizDescriptor({descriptor: validDescriptor}).then(function(qd2) {
        testUser.getQuizDescriptors().then(function(results) {
          expect(results.length).to.equal(2);
          done();
        });
      });
    });
  });

});








{'fraction_non_alphanumeric': 0.15688987271721086, 'fraction_numerical': 0.003320420586607637, 'mean_word_length': 3.2330210772833725, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '4660691', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1021, 'n_words': 204}