Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use eslint and dockerized mocha for testing.
- Loading branch information
Showing
15 changed files
with
1,612 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: 'standard' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
.DS_Store | ||
node_modules | ||
test/out*.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM alpine:3.9 | ||
|
||
RUN apk --no-cache add \ | ||
nodejs \ | ||
npm \ | ||
ffmpeg \ | ||
&& npm install -g \ | ||
npm@latest \ | ||
mocha@5.2.0 \ | ||
# Clean up obsolete files: | ||
&& rm -rf \ | ||
/tmp/* \ | ||
/root/.npm | ||
|
||
# Avoid permission issues with host mounts by assigning a user/group with | ||
# uid/gid 1000 (usually the ID of the first user account on GNU/Linux): | ||
RUN adduser -D -u 1000 mocha | ||
|
||
USER mocha | ||
|
||
WORKDIR /opt | ||
|
||
ENTRYPOINT ["mocha"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '3.7' | ||
services: | ||
test: | ||
build: . | ||
init: true | ||
command: index.test.js | ||
read_only: true | ||
volumes: | ||
- .:/opt:ro | ||
- ./output:/opt/output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
'use strict' | ||
|
||
/* global describe, it */ | ||
|
||
const assert = require('assert') | ||
const imgDiff = require('.') | ||
|
||
const referenceImage = 'samples/lenna.png' | ||
const comparisonImage = 'samples/lenna-edit.png' | ||
|
||
describe('image diff', function () { | ||
this.slow(300) | ||
|
||
it('no output image', async function () { | ||
this.slow(150) | ||
const result = await imgDiff(referenceImage, comparisonImage) | ||
assert.strictEqual(typeof result.R, 'number') | ||
assert.strictEqual(typeof result.G, 'number') | ||
assert.strictEqual(typeof result.B, 'number') | ||
assert.strictEqual(typeof result.All, 'number') | ||
}) | ||
|
||
it('default', async function () { | ||
const result = await imgDiff( | ||
referenceImage, | ||
comparisonImage, | ||
'output/default.png' | ||
) | ||
assert.strictEqual(typeof result.R, 'number') | ||
assert.strictEqual(typeof result.G, 'number') | ||
assert.strictEqual(typeof result.B, 'number') | ||
assert.strictEqual(typeof result.All, 'number') | ||
}) | ||
|
||
it('color yellow', async function () { | ||
const result = await imgDiff( | ||
referenceImage, | ||
comparisonImage, | ||
'output/color-yellow.png', | ||
{ color: 'yellow' } | ||
) | ||
assert.strictEqual(typeof result.R, 'number') | ||
assert.strictEqual(typeof result.G, 'number') | ||
assert.strictEqual(typeof result.B, 'number') | ||
assert.strictEqual(typeof result.All, 'number') | ||
}) | ||
|
||
it('color cyan', async function () { | ||
const result = await imgDiff( | ||
referenceImage, | ||
comparisonImage, | ||
'output/color-cyan.png', | ||
{ color: 'cyan' } | ||
) | ||
assert.strictEqual(typeof result.R, 'number') | ||
assert.strictEqual(typeof result.G, 'number') | ||
assert.strictEqual(typeof result.B, 'number') | ||
assert.strictEqual(typeof result.All, 'number') | ||
}) | ||
|
||
it('color red', async function () { | ||
const result = await imgDiff( | ||
referenceImage, | ||
comparisonImage, | ||
'output/color-red.png', | ||
{ color: 'red' } | ||
) | ||
assert.strictEqual(typeof result.R, 'number') | ||
assert.strictEqual(typeof result.G, 'number') | ||
assert.strictEqual(typeof result.B, 'number') | ||
assert.strictEqual(typeof result.All, 'number') | ||
}) | ||
|
||
it('color green', async function () { | ||
const result = await imgDiff( | ||
referenceImage, | ||
comparisonImage, | ||
'output/color-green.png', | ||
{ color: 'green' } | ||
) | ||
assert.strictEqual(typeof result.R, 'number') | ||
assert.strictEqual(typeof result.G, 'number') | ||
assert.strictEqual(typeof result.B, 'number') | ||
assert.strictEqual(typeof result.All, 'number') | ||
}) | ||
|
||
it('color blue', async function () { | ||
const result = await imgDiff( | ||
referenceImage, | ||
comparisonImage, | ||
'output/color-blue.png', | ||
{ color: 'blue' } | ||
) | ||
assert.strictEqual(typeof result.R, 'number') | ||
assert.strictEqual(typeof result.G, 'number') | ||
assert.strictEqual(typeof result.B, 'number') | ||
assert.strictEqual(typeof result.All, 'number') | ||
}) | ||
|
||
it('color empty', async function () { | ||
const result = await imgDiff( | ||
referenceImage, | ||
comparisonImage, | ||
'output/color-empty.png', | ||
{ color: '' } | ||
) | ||
assert.strictEqual(typeof result.R, 'number') | ||
assert.strictEqual(typeof result.G, 'number') | ||
assert.strictEqual(typeof result.B, 'number') | ||
assert.strictEqual(typeof result.All, 'number') | ||
}) | ||
|
||
it('similarity 1', async function () { | ||
const result = await imgDiff( | ||
referenceImage, | ||
comparisonImage, | ||
'output/similarity-1.png', | ||
{ similarity: 1 } | ||
) | ||
assert.strictEqual(typeof result.R, 'number') | ||
assert.strictEqual(typeof result.G, 'number') | ||
assert.strictEqual(typeof result.B, 'number') | ||
assert.strictEqual(typeof result.All, 'number') | ||
}) | ||
|
||
it('blend 0', async function () { | ||
const result = await imgDiff( | ||
referenceImage, | ||
comparisonImage, | ||
'output/blend-0.png', | ||
{ blend: 0 } | ||
) | ||
assert.strictEqual(typeof result.R, 'number') | ||
assert.strictEqual(typeof result.G, 'number') | ||
assert.strictEqual(typeof result.B, 'number') | ||
assert.strictEqual(typeof result.All, 'number') | ||
}) | ||
|
||
it('opacity 0', async function () { | ||
const result = await imgDiff( | ||
referenceImage, | ||
comparisonImage, | ||
'output/opacity-0.png', | ||
{ opacity: 0 } | ||
) | ||
assert.strictEqual(typeof result.R, 'number') | ||
assert.strictEqual(typeof result.G, 'number') | ||
assert.strictEqual(typeof result.B, 'number') | ||
assert.strictEqual(typeof result.All, 'number') | ||
}) | ||
|
||
it('opacity 1', async function () { | ||
const result = await imgDiff( | ||
referenceImage, | ||
comparisonImage, | ||
'output/opacity-1.png', | ||
{ opacity: 1 } | ||
) | ||
assert.strictEqual(typeof result.R, 'number') | ||
assert.strictEqual(typeof result.G, 'number') | ||
assert.strictEqual(typeof result.B, 'number') | ||
assert.strictEqual(typeof result.All, 'number') | ||
}) | ||
|
||
it('ssim false', async function () { | ||
const result = await imgDiff( | ||
referenceImage, | ||
comparisonImage, | ||
'output/ssim-false.png', | ||
{ ssim: false } | ||
) | ||
assert.strictEqual(result.constructor, Object) | ||
assert.strictEqual(Object.entries(result).length, 0) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.png |
Oops, something went wrong.