<commit_before>// TODO: these tests currently run on both the client and server
// ideally we should have some distinction between them here

Authors = new Meteor.Collection('authors');
Books = new Meteor.Collection('books');

Tinytest.add("Factory - Build - Basic build works", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>'
  });

  test.equal(Factory.build('author').name, '<NAME>');
});

Tinytest.add("Factory - Build - Functions - Basic", function(test) {
  Factory.define('author', Authors, {
    name: function() { return '<NAME>'; }
  });

  test.equal(Factory.build('author').name, '<NAME>');
});

Tinytest.add("Factory - Build - Functions - Context", function(test) {
  Factory.define('author', Authors, {
    test: '<NAME>',
    name: function() { return this.test; }
  });

  test.equal(Factory.build('author').name, '<NAME>');
});

Tinytest.add("Factory - Build - Dotted properties - Basic", function(test) {
  Factory.define('author', Authors, {
    'profile.name': '<NAME>'
  });

  test.equal(Factory.build('author').profile.name, '<NAME>');
});

Tinytest.add("Factory - Build - Dotted properties - Context", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>',
    'profile.name': function() { return this.name; }
  });

  test.equal(Factory.build('author').profile.name, '<NAME>');
});

Tinytest.add("Factory - Build - Deep objects", function(test) {
  Factory.define('author', Authors, {
    profile: {
      name: '<NAME>'
    }
  });

  test.equal(Factory.build('author').profile.name, '<NAME>');
});

Tinytest.add("Factory - Build - Functions - Deep object - Basic", function(test) {
  Factory.define('author', Authors, {
    profile: {
      name: function() { return '<NAME>'; }
    }
  });

  test.equal(Factory.build('author').profile.name, '<NAME>');
});

Tinytest.add("Factory - Build - Functions - Deep object - Context", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>',
    profile: {
      name: function() { return this.name; }
    }
  });

  test.equal(Factory.build('author').profile.name, '<NAME>');
});

Tinytest.add("Factory - Build - Extend - Basic", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>'
  });

  Factory.define('authorOne', Books, Factory.extend('author'));

  test.equal(Factory.build('authorOne').name, '<NAME>');
});

Tinytest.add("Factory - Build - Extend - With attributes", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>'
  });

  Factory.define('authorOne', Books, Factory.extend('author', {
    test: 'testing!'
  }));

  test.equal(Factory.build('authorOne').name, '<NAME>');
  test.equal(Factory.build('authorOne').test, 'testing!');
});

Tinytest.add("Factory - Build - Extend - With attributes (check that we don't modify the parent)", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>'
  });

  Factory.define('authorOne', Books, Factory.extend('author', {
    test: 'testing!'
  }));

  var authorOne = Factory.build('authorOne');
  var author = Factory.build('author');

  test.equal(authorOne.name, '<NAME>');
  test.equal(authorOne.test, 'testing!');
  test.equal(author.test, undefined);
});

Tinytest.add("Factory - Create - Relationship", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>'
  });<commit_msg>added tests for define after hook and create<commit_after>// TODO: these tests currently run on both the client and server
// ideally we should have some distinction between them here

Authors = new Meteor.Collection('authors');
Books = new Meteor.Collection('books');

Tinytest.add("Factory - Build - Basic build works", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>'
  });

  test.equal(Factory.build('author').name, '<NAME>');
});

Tinytest.add("Factory - Define - After hook", function(test) {
  var result;
  
  Factory.define('author', Authors, {
    name: '<NAME>'
  }).after(function(doc) {
    result = doc;
  });

  var author = Factory.create('author');

  test.equal(result.name, '<NAME>');
});

Tinytest.add("Factory - Build - Functions - Basic", function(test) {
  Factory.define('author', Authors, {
    name: function() { return '<NAME>'; }
  });

  test.equal(Factory.build('author').name, '<NAME>');
});

Tinytest.add("Factory - Build - Functions - Context", function(test) {
  Factory.define('author', Authors, {
    test: '<NAME>',
    name: function() { return this.test; }
  });

  test.equal(Factory.build('author').name, '<NAME>');
});

Tinytest.add("Factory - Build - Dotted properties - Basic", function(test) {
  Factory.define('author', Authors, {
    'profile.name': '<NAME>'
  });

  test.equal(Factory.build('author').profile.name, '<NAME>');
});

Tinytest.add("Factory - Build - Dotted properties - Context", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>',
    'profile.name': function() { return this.name; }
  });

  test.equal(Factory.build('author').profile.name, '<NAME>');
});

Tinytest.add("Factory - Build - Deep objects", function(test) {
  Factory.define('author', Authors, {
    profile: {
      name: '<NAME>'
    }
  });

  test.equal(Factory.build('author').profile.name, '<NAME>');
});

Tinytest.add("Factory - Build - Functions - Deep object - Basic", function(test) {
  Factory.define('author', Authors, {
    profile: {
      name: function() { return '<NAME>'; }
    }
  });

  test.equal(Factory.build('author').profile.name, '<NAME>');
});

Tinytest.add("Factory - Build - Functions - Deep object - Context", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>',
    profile: {
      name: function() { return this.name; }
    }
  });

  test.equal(Factory.build('author').profile.name, '<NAME>');
});

Tinytest.add("Factory - Build - Extend - Basic", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>'
  });

  Factory.define('authorOne', Books, Factory.extend('author'));

  test.equal(Factory.build('authorOne').name, '<NAME>');
});

Tinytest.add("Factory - Build - Extend - With attributes", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>'
  });

  Factory.define('authorOne', Books, Factory.extend('author', {
    test: 'testing!'
  }));

  test.equal(Factory.build('authorOne').name, '<NAME>');
  test.equal(Factory.build('authorOne').test, 'testing!');
});

Tinytest.add("Factory - Build - Extend - With attributes (check that we don't modify the parent)", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>'
  });

  Factory.define('authorOne', Books, Factory.extend('author', {
    test: 'testing!'
  }));

  var authorOne = Factory.build('authorOne');
  var author = Factory.build('author');

  test.equal(authorOne.name, '<NAME>');
  test.equal(authorOne.test, 'testing!');
  test.equal(author.test, undefined);
});

Tinytest.add("Factory - Create - Basic", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>'
  });

  var author = Factory.create('author');

  test.equal(author.name, '<NAME>');
});

Tinytest.add("Factory - Create - Relationship", function(test) {
  Factory.define('author', Authors, {
    name: '<NAME>'
  });
{'fraction_non_alphanumeric': 0.20221914008321776, 'fraction_numerical': 0.0, 'mean_word_length': 4.035614525139665, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, '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': '7516953', 'n_tokens_mistral': 2286, 'n_tokens_neox': 2263, 'n_words': 471}