diff --git a/extensions/amp-auto-lightbox/0.1/test/test-amp-auto-lightbox.js b/extensions/amp-auto-lightbox/0.1/test/test-amp-auto-lightbox.js index ef243e4ea933..7b79fdce85ce 100644 --- a/extensions/amp-auto-lightbox/0.1/test/test-amp-auto-lightbox.js +++ b/extensions/amp-auto-lightbox/0.1/test/test-amp-auto-lightbox.js @@ -1,3 +1,5 @@ +import {Assertion} from 'chai'; + import {CommonSignals_Enum} from '#core/constants/common-signals'; import {tryResolve} from '#core/data-structures/promise'; import {Signals} from '#core/data-structures/signals'; @@ -293,13 +295,10 @@ describes.realWin( const areaDeltaPerc = RENDER_AREA_RATIO * 100; const {vh, vw} = {vw: 1000, vh: 600}; - const expectMeetsSizingCriteria = ( - renderWidth, - renderHeight, - naturalWidth, - naturalHeight - ) => - expect( + Assertion.addProperty('meetSizingCriteria', function () { + const {naturalHeight, naturalWidth, renderHeight, renderWidth} = + this._obj; + this.assert( meetsSizingCriteria( renderWidth, renderHeight, @@ -307,8 +306,12 @@ describes.realWin( naturalHeight, vw, vh - ) + ), + 'expected #{this} to meet sizing criteria for #{exp}', + 'expected #{this} to not meet sizing criteria for #{exp}', + {vw, vh} ); + }); it(`accepts elements ${areaDeltaPerc}%+ of size than render area`, () => { const renderWidth = 1000; @@ -321,12 +324,8 @@ describes.realWin( const axisRange = [minDim + 1, minDim + 10, minDim + 100]; iterProduct(axisRange, axisRange, (naturalWidth, naturalHeight) => { - expectMeetsSizingCriteria( - renderWidth, - renderHeight, - naturalWidth, - naturalHeight - ).to.be.true; + expect({renderWidth, renderHeight, naturalWidth, naturalHeight}).to + .meetSizingCriteria; }); }); @@ -341,12 +340,8 @@ describes.realWin( const axisRange = [minDim, minDim - 10, minDim - 100]; iterProduct(axisRange, axisRange, (naturalWidth, naturalHeight) => { - expectMeetsSizingCriteria( - renderWidth, - renderHeight, - naturalWidth, - naturalHeight - ).to.be.false; + expect({renderWidth, renderHeight, naturalWidth, naturalHeight}).to + .not.meetSizingCriteria; }); }); @@ -361,12 +356,8 @@ describes.realWin( const axisRange = [minDim, minDim + 10, minDim + 100]; iterProduct(axisRange, axisRange, (renderWidth, renderHeight) => { - expectMeetsSizingCriteria( - renderWidth, - renderHeight, - naturalWidth, - naturalHeight - ).to.be.true; + expect({renderWidth, renderHeight, naturalWidth, naturalHeight}).to + .meetSizingCriteria; }); }); @@ -376,12 +367,12 @@ describes.realWin( const axisRange = [minDim - 1, minDim - 10, minDim - 100]; iterProduct(axisRange, axisRange, (renderWidth, renderHeight) => { - expectMeetsSizingCriteria( + expect({ renderWidth, renderHeight, - /* naturalWidth */ renderWidth, - /* naturalHeight */ renderHeight - ).to.be.false; + naturalWidth: renderWidth, + naturalHeight: renderHeight, + }).to.not.meetSizingCriteria; }); }); @@ -390,12 +381,12 @@ describes.realWin( const renderHeight = vh; [vh + 1, vh + 10, vh + 100].forEach((naturalHeight) => { - expectMeetsSizingCriteria( + expect({ renderWidth, renderHeight, - /* naturalWidth */ renderWidth, - naturalHeight - ).to.be.true; + naturalWidth: renderWidth, + naturalHeight, + }).to.meetSizingCriteria; }); }); @@ -404,12 +395,12 @@ describes.realWin( const renderHeight = vh; [vw + 1, vw + 10, vw + 100].forEach((naturalWidth) => { - expectMeetsSizingCriteria( + expect({ renderWidth, renderHeight, naturalWidth, - /* naturalHeight */ renderHeight - ).to.be.true; + naturalHeight: renderHeight, + }).to.meetSizingCriteria; }); }); @@ -419,12 +410,8 @@ describes.realWin( const axisRange = [renderWidth, renderWidth - 10, renderWidth - 100]; iterProduct(axisRange, axisRange, (naturalWidth, naturalHeight) => { - expectMeetsSizingCriteria( - renderWidth, - renderHeight, - naturalWidth, - naturalHeight - ).to.be.false; + expect({renderWidth, renderHeight, naturalWidth, naturalHeight}).to + .not.meetSizingCriteria; }); }); }); diff --git a/package-lock.json b/package-lock.json index 067c49f27a53..0d6c5fb91bc7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -99,7 +99,7 @@ "eslint": "8.57.0", "eslint-config-prettier": "9.1.0", "eslint-import-resolver-babel-module": "5.3.2", - "eslint-plugin-chai-expect": "3.0.0", + "eslint-plugin-chai-expect": "3.1.0", "eslint-plugin-eslint-plugin": "5.5.1", "eslint-plugin-import": "2.29.1", "eslint-plugin-jasmine": "4.1.3", @@ -10208,15 +10208,15 @@ } }, "node_modules/eslint-plugin-chai-expect": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-chai-expect/-/eslint-plugin-chai-expect-3.0.0.tgz", - "integrity": "sha512-NS0YBcToJl+BRKBSMCwRs/oHJIX67fG5Gvb4tGked+9Wnd1/PzKijd82B2QVKcSSOwRe+pp4RAJ2AULeck4eQw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-chai-expect/-/eslint-plugin-chai-expect-3.1.0.tgz", + "integrity": "sha512-a9F8b38hhJsR7fgDEfyMxppZXCnCW6OOHj7cQfygsm9guXqdSzfpwrHX5FT93gSExDqD71HQglF1lLkGBwhJ+g==", "dev": true, "engines": { - "node": "10.* || 12.* || >= 14.*" + "node": "10.* || 12.* || || 14.* || 16.* || >= 18.*" }, "peerDependencies": { - "eslint": ">=2.0.0 <= 8.x" + "eslint": ">=2.0.0 <= 9.x" } }, "node_modules/eslint-plugin-eslint-plugin": { @@ -30743,9 +30743,9 @@ } }, "eslint-plugin-chai-expect": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-chai-expect/-/eslint-plugin-chai-expect-3.0.0.tgz", - "integrity": "sha512-NS0YBcToJl+BRKBSMCwRs/oHJIX67fG5Gvb4tGked+9Wnd1/PzKijd82B2QVKcSSOwRe+pp4RAJ2AULeck4eQw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-chai-expect/-/eslint-plugin-chai-expect-3.1.0.tgz", + "integrity": "sha512-a9F8b38hhJsR7fgDEfyMxppZXCnCW6OOHj7cQfygsm9guXqdSzfpwrHX5FT93gSExDqD71HQglF1lLkGBwhJ+g==", "dev": true, "requires": {} }, diff --git a/package.json b/package.json index 1d75c4293be5..081d0f3be4d0 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "eslint": "8.57.0", "eslint-config-prettier": "9.1.0", "eslint-import-resolver-babel-module": "5.3.2", - "eslint-plugin-chai-expect": "3.0.0", + "eslint-plugin-chai-expect": "3.1.0", "eslint-plugin-eslint-plugin": "5.5.1", "eslint-plugin-import": "2.29.1", "eslint-plugin-jasmine": "4.1.3",