Skip to content

Commit

Permalink
Refresh development dependencies and use prettier 3 for formatting (#202
Browse files Browse the repository at this point in the history
)

Also adds a 'Sample guide for updating image test data' in test/processImage.js.

---------

Co-authored-by: priyank <[email protected]>
Co-authored-by: Andreas Lind <[email protected]>
  • Loading branch information
3 people authored Jan 30, 2024
1 parent c89abae commit 4d63702
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 35 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"singleQuote": true
"singleQuote": true,
"trailingComma": "es5"
}
52 changes: 26 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"lib"
],
"dependencies": {
"accepts": "^1.3.3",
"accepts": "^1.3.8",
"animated-gif-detector": "^1.2.0",
"exif-reader": "^1.0.2",
"exif-reader": "^1.0.3",
"gm-papandreou": "^1.23.0-patch1",
"hijackresponse": "^5.0.0",
"httperrors": "^2.0.1",
"httperrors": "^2.3.0",
"impro": "~0.14.1",
"inkscape": "^3.0.0",
"jpegtran": "^2.0.0",
Expand All @@ -26,33 +26,33 @@
"sharp": "^0.32.0"
},
"devDependencies": {
"browser-sync": "^2.18.6",
"compression": "^1.6.1",
"eslint": "^8.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-mocha": "^10.0.1",
"eslint-plugin-n": "^15.1.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^6.0.0",
"browser-sync": "^3.0.2",
"compression": "^1.7.4",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-mocha": "^10.2.0",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-standard": "^5.0.0",
"express": "^4.16.3",
"express": "^4.18.2",
"gifsicle": "^5.3.0",
"magicpen": "^6.0.2",
"magicpen-prism": "^5.0.0",
"magicpen": "^6.2.4",
"magicpen-prism": "^5.0.1",
"memoizesync": "^1.1.1",
"mocha": "^9.0.1",
"nyc": "^15.0.0",
"offline-github-changelog": "^1.7.0",
"prettier": "~2.5.0",
"sinon": "^12.0.1",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"offline-github-changelog": "^3.0.1",
"prettier": "~3.2.1",
"sinon": "^17.0.1",
"svgfilter": "^4.0.0",
"unexpected": "^12.0.0",
"unexpected-express": "^13.0.1",
"unexpected-http": "^8.0.1",
"unexpected-image": "^4.0.0",
"unexpected-sinon": "^11.0.0"
"unexpected": "^12.0.5",
"unexpected-express": "^13.1.2",
"unexpected-http": "^9.0.0",
"unexpected-image": "^4.1.0",
"unexpected-sinon": "^11.1.0"
},
"scripts": {
"docker:build": "docker build -t express-processimage-dev .",
Expand Down
56 changes: 48 additions & 8 deletions test/processImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,48 @@ const load = memoizeSync((fileName) =>
fs.readFileSync(pathModule.resolve(__dirname, '..', 'testdata', fileName))
);

/*
Sample guide for updating image test data:
* Suppose, the original test case looks like this:
it('should do an entropy-based crop', () =>
expect(
'GET /turtle.jpg?resize=100,200&crop=entropy',
'to yield response',
{
body: expect
.it('to equal', load('turtleCroppedEntropy100x200.jpg'))
.and('to have metadata satisfying', {
size: {
width: 100,
height: 200
}
})
}
));
* Rename the concerned file to the new name (turtleCroppedEntropy100x200.jpg -> turtleCroppedEntropy100x200.old.jpg)
* Now, temporarily update the test case in a way to make it pass, like:
it('should do an entropy-based crop', () =>
expect(
'GET /turtle.jpg?resize=100,200&crop=entropy',
'to yield response',
{
statusCode: 200
}
).then((context) => {
const outputPath = pathModule.resolve(root, 'turtleCroppedEntropy100x200.jpg');
const body = context.httpResponse.body;
fs.writeFileSync(outputPath, body);
}));
* Run the test case. This will create a new file with the new name (turtleCroppedEntropy100x200.jpg)
* Now, compare the new file with the old file using appropriate tool, if required
* If the new file is:
* Correct, then:
* revert the test case to the original state
* delete the old file (turtleCroppedEntropy100x200.old.jpg)
* Incorrect, then:
* revert the test case to the original state and investigate
*/

describe('express-processimage', () => {
let config;
let impro;
Expand Down Expand Up @@ -49,14 +91,12 @@ describe('express-processimage', () => {

impro = middleware._impro;

return expect(
express().use(middleware).use(express.static(root)),
'to yield exchange',
{
request: subject,
response: value,
}
);
const app = express().use(middleware).use(express.static(root));

return expect(app, 'to yield exchange', {
request: subject,
response: value,
});
}
)
.addAssertion(
Expand Down

0 comments on commit 4d63702

Please sign in to comment.