Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function getRfc232TestContext() {
// Support older versions of `ember-qunit` that don't have
// `@ember/test-helpers` (and therefore cannot possibly be running an
// rfc232/rfc268 test).
if (require.has('@ember/test-helpers')) {
let { getContext } = require('@ember/test-helpers');
return getContext();
}
}
export function getTools() {
return getContext().owner.lookup('service:cardstack-tools');
}
return getSpaceForCard(type, id).then(space => {
let context = getContext();
let card = space.get('primaryCard');
let params = space.get('params');
context.set('card', card);
context.set('format', format);
context.set('params', Object.assign({}, params, options.params || {}));
if (options.width) {
context.set('widthStyle', htmlSafe(`width: ${options.width}`));
return render(hbs`
<div style="{{widthStyle}}">
{{cardstack-content content=card format=format params=params }}
</div>`);
} else {
return render(hbs`{{cardstack-content content=card format=format params=params }}`);
}
});
export function getSpaceForCard(type, id) {
return getContext()
.owner.lookup('service:store')
.findRecord('space', `/${pluralize(type)}/${id}`);
}
getContext() {
if (this.context) {
return this.context;
}
return (this.context = getContext() || {});
}
return module.setup().then(() => {
var context = getContext();
Object.keys(context).forEach(key => {
this[key] = context[key];
});
});
});
return module.setup().then(() => {
var context = getContext();
Object.keys(context).forEach(key => {
this[key] = context[key];
});
});
});
export function assertPositioning(assert, selector = '.tooltip') {
assert.dom(selector).exists({ count: 1 }, 'Element exists.');
let rootEl = getContext().element;
let tooltip = rootEl.querySelector(selector);
let trigger = rootEl.querySelector('#target');
let margin = -parseInt(window.getComputedStyle(tooltip).marginTop, 10) + parseInt(window.getComputedStyle(tooltip).marginBottom, 10);
let tooltipPos = Math.round(offset(tooltip).top + tooltip.offsetHeight + margin);
let triggerPos = Math.round(offset(trigger).top);
assert.ok(Math.abs(triggerPos - tooltipPos) <= 1, `Expected position: ${triggerPos}, actual: ${tooltipPos}`);
}
run(() => {
getContext().application.destroy();
});
export function triggerCopyError(selector) {
const { owner } = getContext();
_fireComponentAction(owner, selector, 'error');
}