<commit_before># spritesmith-engine-test

Common test suite and specification for all Spritesmith engines

These files were written for usage with [doubleshot][doubleshot].

[doubleshot]: https://github.com/twolfson/doubleshot

## Specification
There are two constructors that will need to be made

- `engine` which takes care of asynchronous construction of new items
- `canvas` which accepts image instances and outputs a final image

### engine
Each `engine` must have and implement the following methods:

```js
engine.createImages(images, cb);
/**
 * Utility to create images in your engine format
 * @param {String[]} filepaths Array of filepaths to images to be parsed into images
 * @param {Function} cb Function to callback with image objects
 * @callback {null|Object} err Callback with an error if there was one, otherwise null
 * @callback {Object[]} imgs Callback with an array of images
 * @callback {Number} imgs[*].height Height (pixels) of the input image
 * @callback {Number} imgs[*].width Width (pxiels) of the input image
 */
```

```js
engine.createCanvas(width, height, cb);
/**
 * Asynchronous constructor for canvas
 * @param {Number} width Width (pixels) for canvas. Exported width should match this.
 * @param {Number} height Height (pixels) for canvas. Exported height should match this.
 * @param {Function} cb Function to callback with constructed canvas
 * @callback {null|Object} err Callback with an error if there was one, otherwise null
 * @callback {Object} canvas Canvas instance for your engine
 */
```

### canvas
Each `canvas` must have and implement the following methods:

```js
canvas.addImage(img, x, y);
/**
 * Add an image at the specified location (upper-left corner of image matches x,y)
 * You will not need to worry about overlapping images.
 * It is a bit inconsistent for this to not be asynchronous but any async can be done in export.
 * @param {Object} img Image instance created via `engine.createImages`
 * @param {Number} x Horizontal coordinate to position left edge of image
 * @param {Number} y Vertical coordinate to position top edge of image
 */
```

```js
canvas['export'](options, cb);
/**
 * Export canvas to an image with dimensions from `engine.createCanvas` and images at positions from `canvas.addImage`
 * @param {Object} options Modifiers to indicate how to export (e.g. {format: 'png'} would produce a `png` over a `jpeg`)
 * @param {Function} cb
 * @callback {null|Object} err Callback with an error if there was one, otherwise null
 * @callback {String} result Binary encoded string of output image
 */
```

## Using the module
Install the module via npm

```shell
npm install spritesmith-engine-test
```

Create files that require and extend test `content` and `outline`

```js
// test_outline.js
module.exports = {
  // Run all spritesmith-engine-tests using mysmith
  'mysmith': require('spritesmith-engine-test').outline
};

// test_content.js
var commonTest = require('spritesmith-engine-test').content;
module.exports = extend({}, commonTest, {
  // Provide a hook for my smith in doubleshot
  'mysmith': function () {
    // Save mysmith as the test smith
    this.smith = mysmith;<commit_msg>Thinning out README for GitHub lengths<commit_after># spritesmith-engine-test

Common test suite and specification for all Spritesmith engines

These files were written for usage with [doubleshot][doubleshot].

[doubleshot]: https://github.com/twolfson/doubleshot

## Specification
There are two constructors that will need to be made

- `engine` which takes care of asynchronous construction of new items
- `canvas` which accepts image instances and outputs a final image

### engine
Each `engine` must have and implement the following methods:

```js
engine.createImages(images, cb);
/**
 * Utility to create images in your engine format
 * @param {String[]} filepaths Array of filepaths to images to be parsed into images
 * @param {Function} cb Function to callback with image objects
 * @callback {null|Object} err Callback with an error if there was one, otherwise null
 * @callback {Object[]} imgs Callback with an array of images
 * @callback {Number} imgs[*].height Height (pixels) of the input image
 * @callback {Number} imgs[*].width Width (pxiels) of the input image
 */
```

```js
engine.createCanvas(width, height, cb);
/**
 * Asynchronous constructor for canvas
 * @param {Number} width Width (pixels) for canvas. Exported width should match this.
 * @param {Number} height Height (pixels) for canvas. Exported height should match this.
 * @param {Function} cb Function to callback with constructed canvas
 * @callback {null|Object} err Callback with an error if there was one, otherwise null
 * @callback {Object} canvas Canvas instance for your engine
 */
```

### canvas
Each `canvas` must have and implement the following methods:

```js
canvas.addImage(img, x, y);
/**
 * Add an image at the specified location (upper-left corner of image matches x,y)
 * You will not need to worry about overlapping images.
 * It is a bit inconsistent for this to not be asynchronous but any async can be done in export.
 * @param {Object} img Image instance created via `engine.createImages`
 * @param {Number} x Horizontal coordinate to position left edge of image
 * @param {Number} y Vertical coordinate to position top edge of image
 */
```

```js
canvas['export'](options, cb);
/**
 * Export an image with dimensions from `engine.createCanvas` and imgs/positions from `canvas.addImage`
 * @param {Object} options Modifiers to indicate how to export (e.g. {format: 'png'} to produce a `png`)
 * @param {Function} cb
 * @callback {null|Object} err Callback with an error if there was one, otherwise null
 * @callback {String} result Binary encoded string of output image
 */
```

## Using the module
Install the module via npm

```shell
npm install spritesmith-engine-test
```

Create files that require and extend test `content` and `outline`

```js
// test_outline.js
module.exports = {
  // Run all spritesmith-engine-tests using mysmith
  'mysmith': require('spritesmith-engine-test').outline
};

// test_content.js
var commonTest = require('spritesmith-engine-test').content;
module.exports = extend({}, commonTest, {
  // Provide a hook for my smith in doubleshot
  'mysmith': function () {
    // Save mysmith as the test smith
    this.smith = mysmith;
{'fraction_non_alphanumeric': 0.09976359338061466, 'fraction_numerical': 0.0, 'mean_word_length': 4.499133448873484, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1805541', 'n_tokens_mistral': 1808, 'n_tokens_neox': 1705, 'n_words': 799}