<commit_before>/*global suite:true, test:true, setup:true, teardown:true*/ // mocha

define(['jquery', 'q', 'chai', 'text!/test/1/form.json'],
       function($, Q, chai, json) {
  'use strict';

  var assert = chai.assert;

  suite('1', function() {
    var obj;

    setup(function() {
      obj = JSON.parse(json);
    });

    test('form.json is a JSON object', function() {
      assert.equal($.type(obj), 'object');
    });

    suite('Form', function() {

      test('wait for BlinkForms global', function(done) {
        var dfrd = Q.defer(),
            check = function() {
              if (window.BlinkForms) {
                dfrd.resolve();
              } else {
                setTimeout(check, 47);
              }
            };

        check();
        dfrd.promise.then(done);
      });

      test('BlinkForms global is an Object', function() {
        var Forms = window.BlinkForms;
        assert.equal($.type(Forms), 'object');
      });

      test('initialise with form.json', function() {
        var Forms = window.BlinkForms,
            form;
        Forms.initialize(obj);
        form = Forms.currentFormObject;
        assert.equal($.type(form), 'object');
        assert.equal(form.get('name'), 'form1');
        assert.equal(form.get('label'), 'Form 1');
      });

    });

    teardown(function() {
      delete window.BlinkForms.currentFormObject;
    });
  });
});
<commit_msg>use suiteSetup|Teardown instead of setup|teardown to avoid wiping out environment in between tests<commit_after>/*global suite:true, test:true, setup:true, teardown:true*/ // mocha

define(['jquery', 'q', 'chai', 'text!/test/1/form.json'],
       function($, Q, chai, json) {
  'use strict';

  var assert = chai.assert;

  suite('1', function() {
    var obj;

    /**
     * execute once before everything else in this suite
     */
    suiteSetup(function() {
      obj = JSON.parse(json);
    });

    test('form.json is a JSON object', function() {
      assert.equal($.type(obj), 'object');
    });

    suite('Form', function() {

      test('wait for BlinkForms global', function(done) {
        var dfrd = Q.defer(),
            check = function() {
              if (window.BlinkForms) {
                dfrd.resolve();
              } else {
                setTimeout(check, 47);
              }
            };

        check();
        dfrd.promise.then(done);
      });

      test('BlinkForms global is an Object', function() {
        var Forms = window.BlinkForms;
        assert.equal($.type(Forms), 'object');
      });

      test('initialise with form.json', function() {
        var Forms = window.BlinkForms,
            form;
        Forms.initialize(obj);
        form = Forms.currentFormObject;
        assert.equal($.type(form), 'object');
        assert.equal(form.get('name'), 'form1');
        assert.equal(form.get('label'), 'Form 1');
      });

    });

    /**
     * execute once after everything else in this suite
     */
    suiteTeardown(function() {
      delete window.BlinkForms.currentFormObject;
    });
  });
});

{'fraction_non_alphanumeric': 0.16189856957087126, 'fraction_numerical': 0.0039011703511053317, 'mean_word_length': 2.08008008008008, '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': '3046231', 'n_tokens_mistral': 949, 'n_tokens_neox': 907, 'n_words': 200}