<commit_before>describe("sapphire.utils", function() {
  describe(".access", function() {
    it("should access the property if possible", function() {
      expect(sapphire.utils.access({foo: 3}, 'foo')).to.equal(3);
    });

    it("should use the default if the key does not exist", function() {
      expect(sapphire.utils.access({}, 'foo')).to.be.null;
      expect(sapphire.utils.access({}, 'foo', 3)).to.equal(3);
    });

    it("should use the default if the value is undefined", function() {
      expect(sapphire.utils.access({foo: undefined}, 'foo')).to.be.null;
      expect(sapphire.utils.access({foo: undefined}, 'foo', 3)).to.equal(3);
    });

    it("should use the default if the datum is not an object", function() {
      expect(sapphire.utils.access(2, 'foo')).to.be.null;
      expect(sapphire.utils.access(2, 'foo', 3)).to.equal(3);
    });
  });

  describe(".ensure", function() {
    it("should use the value if possible", function() {
      expect(sapphire.utils.ensure(2, 3)).to.equal(2);
    });

    it("should use the default if the value is null", function() {
      expect(sapphire.utils.ensure(null, 3)).to.equal(3);
    });

    it("should use the default if the value is undefined", function() {
      expect(sapphire.utils.ensure(undefined, 3)).to.equal(3);
    });
  });

  describe(".translate", function() {
    it("should return a translation string", function() {
      expect(sapphire.utils.translate(3.23, 23.23))
        .to.equal('translate(3.23, 23.23)');
    });
  });

  describe(".ensureEl", function() {
    it("should wrap the element in a d3 selection if it isn't already", function() {
      var el = sapphire.utils.ensureEl('body');
      expect(el.node()).to.equal(d3.select('body').node());
    });

    it("should return the selection if a selection was given", function() {
      var el = d3.select('body');
      expect(sapphire.utils.ensureEl(el)).to.equal(el);
    });
  });

  describe(".date", function() {
    it("should return a new date", function() {
      var d = new Date(2014, 2, 2);
      expect(+sapphire.utils.date(+d)).to.equal(+d);
      expect(sapphire.utils.date(+d)).to.be.an.instanceof(Date);
    });
  });

  describe(".box", function() {
    it("should contain its width", function() {
      var box = sapphire.utils.box()
        .width(200);

      expect(box()).to.have.property('width', 200);
    });

    it("should contain its height", function() {
      var margin = {
        top: 1,
        left: 2,
        right: 3,
        bottom: 4
      };

      var box = sapphire.utils.box()
        .margin(margin);

      expect(box()).to.have.property('margin', margin);
    });

    it("should contain its margin", function() {
      var box = sapphire.utils.box()
        .height(200);
<commit_msg>Fix typos in utils.box tests<commit_after>describe("sapphire.utils", function() {
  describe(".access", function() {
    it("should access the property if possible", function() {
      expect(sapphire.utils.access({foo: 3}, 'foo')).to.equal(3);
    });

    it("should use the default if the key does not exist", function() {
      expect(sapphire.utils.access({}, 'foo')).to.be.null;
      expect(sapphire.utils.access({}, 'foo', 3)).to.equal(3);
    });

    it("should use the default if the value is undefined", function() {
      expect(sapphire.utils.access({foo: undefined}, 'foo')).to.be.null;
      expect(sapphire.utils.access({foo: undefined}, 'foo', 3)).to.equal(3);
    });

    it("should use the default if the datum is not an object", function() {
      expect(sapphire.utils.access(2, 'foo')).to.be.null;
      expect(sapphire.utils.access(2, 'foo', 3)).to.equal(3);
    });
  });

  describe(".ensure", function() {
    it("should use the value if possible", function() {
      expect(sapphire.utils.ensure(2, 3)).to.equal(2);
    });

    it("should use the default if the value is null", function() {
      expect(sapphire.utils.ensure(null, 3)).to.equal(3);
    });

    it("should use the default if the value is undefined", function() {
      expect(sapphire.utils.ensure(undefined, 3)).to.equal(3);
    });
  });

  describe(".translate", function() {
    it("should return a translation string", function() {
      expect(sapphire.utils.translate(3.23, 23.23))
        .to.equal('translate(3.23, 23.23)');
    });
  });

  describe(".ensureEl", function() {
    it("should wrap the element in a d3 selection if it isn't already", function() {
      var el = sapphire.utils.ensureEl('body');
      expect(el.node()).to.equal(d3.select('body').node());
    });

    it("should return the selection if a selection was given", function() {
      var el = d3.select('body');
      expect(sapphire.utils.ensureEl(el)).to.equal(el);
    });
  });

  describe(".date", function() {
    it("should return a new date", function() {
      var d = new Date(2014, 2, 2);
      expect(+sapphire.utils.date(+d)).to.equal(+d);
      expect(sapphire.utils.date(+d)).to.be.an.instanceof(Date);
    });
  });

  describe(".box", function() {
    it("should contain its width", function() {
      var box = sapphire.utils.box()
        .width(200);

      expect(box()).to.have.property('width', 200);
    });

    it("should contain its margin", function() {
      var margin = {
        top: 1,
        left: 2,
        right: 3,
        bottom: 4
      };

      var box = sapphire.utils.box()
        .margin(margin);

      expect(box()).to.have.property('margin', margin);
    });

    it("should contain its height", function() {
      var box = sapphire.utils.box()
        .height(200);

{'fraction_non_alphanumeric': 0.18704134598174332, 'fraction_numerical': 0.018972614999105065, 'mean_word_length': 2.9407616361071933, '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': '7276521', 'n_tokens_mistral': 1864, 'n_tokens_neox': 1766, 'n_words': 410}