Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoscale in testing #228

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@embroider/broccoli-side-watch": "0.0.2-unstable.ba9fd29",
"@embroider/compat": "^3.4.8",
"@embroider/core": "^3.4.8",
"@embroider/macros": "^1.16.0",
"@embroider/macros": "^1.16.1",
"@embroider/router": "^2.1.6",
"@embroider/webpack": "^4.0.0",
"@glimmer/component": "^1.1.2",
Expand Down
4 changes: 0 additions & 4 deletions docs-app/tests/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
type SetupTestOptions,
} from 'ember-qunit';

import { resetViewport } from './reset-viewport';

// This file exists to provide wrappers around ember-qunit's
// test setup functions. This way, you can easily extend the setup that is
// needed per test type.
Expand All @@ -16,7 +14,6 @@ function setupApplicationTest(
options?: SetupTestOptions,
): void {
upstreamSetupApplicationTest(hooks, options);
resetViewport(hooks);

// Additional setup for application tests can be done here.
//
Expand Down Expand Up @@ -52,5 +49,4 @@ function setupTest(hooks: NestedHooks, options?: SetupTestOptions): void {
export { setupApplicationTest, setupRenderingTest, setupTest };

export * from './percy';
export * from './reset-viewport';
export * from './resize-container';
15 changes: 0 additions & 15 deletions docs-app/tests/helpers/reset-viewport.ts

This file was deleted.

1 change: 1 addition & 0 deletions ember-container-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
},
"dependencies": {
"@embroider/addon-shim": "^1.8.7",
"@embroider/macros": "^1.16.1",
"decorator-transforms": "^1.2.1",
"ember-element-helper": "^0.8.6",
"ember-modifier": "^3.2.7 || ^4.1.0",
Expand Down
10 changes: 6 additions & 4 deletions ember-container-query/src/modifiers/container-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { action } from '@ember/object';
import type Owner from '@ember/owner';
import { debounce as _debounce } from '@ember/runloop';
import { inject as service } from '@ember/service';
import { isTesting, macroCondition } from '@embroider/macros';
import type { ArgsFor, NamedArgs, PositionalArgs } from 'ember-modifier';
import Modifier from 'ember-modifier';

Expand Down Expand Up @@ -120,13 +121,14 @@ export default class ContainerQueryModifier<
}

private measureDimensions(element: Element): void {
const height = element.clientHeight;
const width = element.clientWidth;
const scale = macroCondition(isTesting()) ? 2 : 1;

const { height, width } = element.getBoundingClientRect();

this.dimensions = {
aspectRatio: width / height,
height,
width,
height: scale * height,
width: scale * width,
};
}

Expand Down
39 changes: 32 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.