computed: {
console: () => console,
window: () => window,
},
import { mount, shallowMount } from '@vue/test-utils'
<select>
<option v-for="(item , index) in categories" v-bind:key="index" :selected= "item.id == 30" >
{{item.title}}
</option>
</select>
import { mapGetters, mapState, mapActions } from 'vuex';
props: {
cell: {
type: Object,
required: true,
},
}
<form @submit.prevent="onFormSubmit">
unique = [... new Set (array)]
getEventListeners(window)
Runner.instance_.gameOver = () => {}
{{if (eq index (sub this.lems.length 1)) "rounded-b-full"}}
this.clock = sinon.useFakeTimers({ shouldAdvanceTime: true });
hooks.afterEach(function() {
this.clock.restore();
});
[^\x00-\x7F] # find special chars
ember-intl
price_banner: The {product} costs {price, number, ::currency/USD}
import Model from '@ember-data/model';
import { inject as service } from '@ember/service';
export default {
initialize() {
Model.reopen({
cacheResponse: service(),
notifyBelongsToChanged() {
if (this.get('cacheResponse').isRetry) {
console.error('Infinite retry bug for failed relationship fetches detected. The following requests stopped!');
} else {
return this._super(...arguments);
}
},
});
}
};
"component-library": "file:../component-library",
return Ember.Test._helpers.pauseTest.method();
import tHelper from 'ember-i18n/helper';
import { getOwner, setOwner } from '@ember/application';
let owner = getOwner(this);
let authenticator = owner.lookup(authenticatorName);
setOwner(authenticator, owner);
return authenticator;
@action
async authenticate(e) {
await promise
}
import { guidFor } from '@ember/object/internals';
// Use assign instead of merge to solve deprecation
- import { merge } from '@ember/polyfills';
- let parameters = merge(properties, {
+ import { assign } from '@ember/polyfills';
+ let parameters = assign(properties, {
isTesting: computed(() => testing)
- clipsSorting: ['position']
+ clipsSorting: Object.freeze(['position'])
find('*').textContent
return this.get('currentSchool.content').hasMany('submissionMethods').reload();
app.import('node_modules/linkify-it/index.js', {
using: [
{ transformation: 'cjs', as: 'linkify-it' }
]
});
const { timeout: defaultTimeout } = config.flashMessageDefaults
# app/utils/update-session-token-in-local-storage.js
import { Promise } from 'rsvp';
export default function updateSessionTokenInLocalStorage(session, token) {
return new Promise(resolve => {
session.set('data.authenticated.smhw_token', token);
const newSessionData = session.get('data');
session.get('store').persist(newSessionData).then(() => resolve());
});
}
case 'findRecord':
return this.urlForFindRecord(id, modelName, snapshot);
case 'findAll':
return this.urlForFindAll(modelName, snapshot);
case 'query':
return this.urlForQuery(query, modelName);
case 'queryRecord':
return this.urlForQueryRecord(query, modelName);
case 'findMany':
return this.urlForFindMany(id, modelName, snapshot);
case 'findHasMany':
return this.urlForFindHasMany(id, modelName, snapshot);
case 'findBelongsTo':
return this.urlForFindBelongsTo(id, modelName, snapshot);
case 'createRecord':
return this.urlForCreateRecord(modelName, snapshot);
case 'updateRecord':
return this.urlForUpdateRecord(id, modelName, snapshot);
case 'deleteRecord':
return this.urlForDeleteRecord(id, modelName, snapshot);
ps -A | grep ember
kill -USR1
yarn upgrade-interactive --latest
export NODE_PATH="$(npm config get prefix)/lib/node_modules"
+new Date it's just the same as (new Date()).getTime()
model() {
return { taskName: [] };
},
taskName: task(function*() {
return yield this.store.findAll('model');
}).cancelOn('deactivate').restartable(),
Array.prototype.slice.call(scope.getElementsByTagName(tag)).filter(el => el.textContent.trim() === text);
sinon.stub(ENV, 'APP').value({ infiniteScrollPageSize: pageSize });
assert.po(showPage.navLinks.links.findOneBy('text', 'Questions')).hasActiveStyling();
1 < 2 < 3;
true
3 > 2 > 1;
false
typeof [];
"object"
typeof null;
"object"
[] instanceof Object;
true
null instanceof Object;
false
NaN === NaN;
false
new URLSearchParams(new URL(window.location).search).get(param);
willDestroyElement() {
this.set('isAnimated', false);
let clone = this.get('element').parentNode.cloneNode(true);
let popup = clone.querySelector('.popup-wrapper');
popup.classList.remove('popup-wrapper--on-opening');
popup.classList.add('popup-wrapper--on-closing');
document.querySelector('body').append(clone);
later(() => { clone.remove() }, this.get('animationTime'));
},
if (!overlay.animate) { return; }
_unfilter(array, callback) {
return array.filter(function () {
return !callback.apply(this, arguments);
});
}
this.get('request').put(
`/url`,
{ body: JSON.stringify(data) }
).then(response => {
if (response.ok) {
return response.json().then(json => {
resolve(this.get('store').pushPayload(json));
});
} else if (response.code === 422) {
return response.json().then(json => reject(json));
} else {
reject();
}
});
# ember focus magic
becomeFocused: function() {
this.$('.create-new-submission-method-input').focus();
}.on('didInsertElement'),
assert.dom('.navbar-blue li a[href*="/school/homeworks/calendar"]').hasText('Calendar');
assert.ok(/invalid format/i.test(find('#pin-only-form').text()), 'An error message appears');
server.db.employees.where({ employee_type: 'teacher' }).length
Object.entries(errors).length
random template (Handlebars.compile(.html())-> components
url = new URL('http://example:8080/path')
url.hostname // "example"
url.host // "example:8080"
white-space: pre-wrap
$p: &;
.only-one-element {
@at-root #{$p} {
left: 25%;
}
}
// .centered
display: flex; justify-content: center; align-items: center; on the parent element
.centered {
left: 50%;
margin: 0;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
yarn add [package]@[version]
function test(){
alert( this instanceof test );
}
test(); // сработает как alert( false );
new test(); // сработает как alert( true );
// all available methods
Object.getOwnPropertyNames()
moment.unix(retry[0]).format('YYYY-MM-DD HH:mm')
function resolveAfter2Seconds() {
return new Promise(resolve => {
setTimeout(() => {
resolve('resolved');
}, 2000);
});
}
async function asyncCall() {
console.log('calling');
var result = await resolveAfter2Seconds();
console.log(result);
// expected output: 'resolved'
}
asyncCall();
pauseTest();
async function unicorn() {
try {
let rainbow = await getRainbow();
return rainbow.data.colors;
} catch(e) {
return {
message: e.data.message,
somaText: ‘Текст о не легкой жизни единорогов’
}
}
}
async function unicorn() {
let [rainbow, food] = await Promise.all([getRainbow(), getFood()]);
return {rainbow, food}
}
class FakeIssuedOnModel {
constructor(issuedOn) {
this.issuedOn = issuedOn;
}
get(name) {
return this[name];
}
}
# times
[...Array(aspectsSize).keys()].forEach(function(size) {
// size
});
import ObjectProxy from '@ember/object/proxy';
[class*="button--active"]
cypress
npm install --unsafe-perm=true --allow-root
ember generate component-class rental