<commit_before>/*global require */
var api = require('../js/edit_api');
var test_data = require('./fixtures/article/1.json');
var should = require('should');
var utils = require('./utils');
var sinon = require('sinon');

describe("edit component api", function() {
  describe("post", function() {
    before(function(done){
      var slug = 'testslug';
      var server = utils.mock_component('test', {"slug" : slug}, false,
        ['byline', 'master_image']
      );
    });
    it("makes post requests at mirrors", function(done) {
      var component = new api.Component();
      component.create().then(function() {
        should(true).be.ok;
        done();
      }, function() {
        true.should.not.be.ok;
        done();
      });
    });
    after(function(done) {
      server.restore();
    });
  });

  describe("patch", function() {
    it("makes put requests at mirrors", function(done) {
      var slug = 'testslug';
      var server = utils.mock_component(slug, test_data);

      var component = new api.Component(slug);
      component.metadata = test_data.metadata;
      component.attributes = test_data.attributes;
      component.update().then(function() {
        server.restore();
        done();
      });
    });
  });

  describe("setAttribute", function() {
    it("changes component attributes", function(done) {
      var slug = 'testslug';
      var component = new api.Component(slug);
      var attr_name = 'test';<commit_msg>added done<commit_after>/*global require */
var api = require('../js/edit_api');
var test_data = require('./fixtures/article/1.json');
var should = require('should');
var utils = require('./utils');
var sinon = require('sinon');

describe("edit component api", function() {
  describe("post", function() {
    var server = slug = undefined;
    before(function(done){
      slug = 'testslug';
      server = utils.mock_component('test', {"slug" : slug}, false,
        ['byline', 'master_image']
      );
      done();
    });
    it("makes post requests at mirrors", function(done) {
      var component = new api.Component();
      component.create().then(function() {
        should(true).be.ok;
        done();
      }, function() {
        true.should.not.be.ok;
        done();
      });
    });
    after(function(done) {
      server.restore();
      done();
    });
  });

  describe("patch", function() {
    it("makes put requests at mirrors", function(done) {
      var slug = 'testslug';
      var server = utils.mock_component(slug, test_data);

      var component = new api.Component(slug);
      component.metadata = test_data.metadata;
      component.attributes = test_data.attributes;
      component.update().then(function() {
        server.restore();
        done();
      });
    });
  });

  describe("setAttribute", function() {
    it("changes component attributes", function(done) {
      var slug = 'testslug';
      var component = new api.Component(slug);
      var attr_name = 'test';
{'fraction_non_alphanumeric': 0.16677852348993288, 'fraction_numerical': 0.0006711409395973154, 'mean_word_length': 2.792620865139949, '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': '1826462', 'n_tokens_mistral': 864, 'n_tokens_neox': 861, 'n_words': 194}