Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Ember from 'ember';
import { moduleForComponent } from 'ember-qunit';
import { skip } from 'qunit';
import {
generateContent,
findItems,
findVisibleItems
} from '../helpers/helpers';
// import hbs from 'htmlbars-inline-precompile';
// TODO: Remove these declarations. They're just there to keep JSHint happy.
let compile, ListItemView, ReusableListItemView;
moduleForComponent('ember-collection', 'View recycling', {integration: true});
skip("recycling complex views long list", function(assert){
var content = generateContent(100),
height = 50,
rowHeight = 50,
itemViewClass = ListItemView.extend({
innerViewClass: Ember.View.extend({
didInsertElement: function(){
innerViewInsertionCount++;
},
willDestroyElement: function(){
innerViewDestroyCount++;
}
}),
template: compile("{{name}} {{#view view.innerViewClass}}{{/view}}")
});
var listViewInsertionCount, listViewDestroyCount,
export default function testInDebug(label, callback) {
if (DEBUG) {
test(`[DEBUG-ONLY] ${label}`, callback);
} else {
skip(`[DEBUG-ONLY] ${label}`, callback);
}
}
import startApp from '../../helpers/start-app';
import Pretender from 'pretender';
var App;
var server;
module('Acceptance: FriendsNew', {
beforeEach: function() {
App = startApp();
},
afterEach: function() {
Ember.run(App, 'destroy');
}
});
skip('Creating a new friends', function(assert) {
visit('/friends/new');
click('a[href=/friends/new]');
andThen(function() {
assert.equal(currentPath(), 'friends.new');
});
fillIn('input[placeholder=First Name]', 'Johnny');
fillIn('input[placeholder=Last Name]', 'Foo');
fillIn('input[placeholder=email]', 'j@cash.com');
fillIn('input[placeholder=twitter]', 'jcash');
click('input[value=Save]');
andThen(function() {
assert.equal(find('.error-message').text(), 'Friend was not saved', 'shows error');
});
assert.async(1);
assert.deepEqual(1);
export default function todo(description, callback) {
if (DEBUG) {
test(`[TODO] ${description}`, async function todoTest(assert) {
let todos = [];
hijackAssert(assert, todos);
await callback.call(this, assert);
assertTestStatus(assert, todos);
});
} else {
skip(`[TODO] ${description}`, callback);
}
}
listItemViewInsertionCount = 0;
listItemViewDestroyCount = 0;
innerViewInsertionCount = 0;
innerViewDestroyCount = 0;
view.scrollTo(0);
assert.equal(findItems(this).length, 2, "The correct number of rows were rendered (post-scroll to 0)");
assert.equal(listItemViewInsertionCount, 0, "expected number of listItemView's didInsertElement (post-scroll to 0)");
assert.equal(listItemViewDestroyCount, 0, "expected number of listItemView's willDestroyElement (post-scroll to 0)");
assert.equal(innerViewInsertionCount, 0, "expected number of innerView's didInsertElement (post-scroll to 0)");
assert.equal(innerViewDestroyCount, 0, "expected number of innerView's willDestroyElement (post-scroll to 0)");
});
skip("recycling complex views short list, with ReusableListItemView", function(assert){
var content = generateContent(2),
height = 50,
rowHeight = 50,
itemViewClass = ReusableListItemView.extend({
innerViewClass: Ember.View.extend({
didInsertElement: function(){
innerViewInsertionCount++;
},
willDestroyElement: function(){
innerViewDestroyCount++;
}
}),
didInsertElement: function(){
this._super();
listItemViewInsertionCount++;
},
listItemViewInsertionCount = 0;
listItemViewDestroyCount = 0;
innerViewInsertionCount = 0;
innerViewDestroyCount = 0;
view.scrollTo(0);
assert.equal(findItems(this).length, 2, "The correct number of rows were rendered (post-scroll to 0)");
assert.equal(listItemViewInsertionCount, 0, "expected number of listItemView's didInsertElement (post-scroll to 0)");
assert.equal(listItemViewDestroyCount, 0, "expected number of listItemView's willDestroyElement (post-scroll to 0)");
assert.equal(innerViewInsertionCount, 0, "expected number of innerView's didInsertElement (post-scroll to 0)");
assert.equal(innerViewDestroyCount, 0, "expected number of innerView's willDestroyElement (post-scroll to 0)");
});
skip("recycling complex views with ReusableListItemView, handling empty slots at the end of the grid", function(assert){
var content = generateContent(20),
height = 150,
rowHeight = 50,
width = 100,
elementWidth = 50,
itemViewClass = ReusableListItemView.extend({
innerViewClass: Ember.View.extend({
didInsertElement: function(){
innerViewInsertionCount++;
},
willDestroyElement: function(){
innerViewDestroyCount++;
}
}),
didInsertElement: function(){
this._super();
function ignoreIt(testElement) {
skip(`${testElement.title}`, function(/*assert*/) {});
}
innerViewInsertionCount = 0;
innerViewDestroyCount = 0;
view.scrollTo(0);
assert.equal(findItems(this).length, 2, "The correct number of rows were rendered (post-scroll to 0)");
assert.equal(innerViewInsertionCount, 0, "expected number of innerView's didInsertElement (post-scroll to 0)");
assert.equal(innerViewDestroyCount, 0, "expected number of innerView's willDestroyElement (post-scroll to 0)");
assert.equal(listViewInsertionCount, 1, "expected number of listView's didInsertElement (post-scroll to 0)");
assert.equal(listViewDestroyCount, 0, "expected number of listView's willDestroyElement (post-scroll to 0)");
});
skip("recycling complex views long list, with ReusableListItemView", function(assert){
var content = generateContent(50),
height = 50,
rowHeight = 50,
itemViewClass = Ember.ReusableListItemView.extend({
innerViewClass: Ember.View.extend({
didInsertElement: function(){
innerViewInsertionCount++;
},
willDestroyElement: function(){
innerViewDestroyCount++;
}
}),
didInsertElement: function(){
this._super();
listItemViewInsertionCount++;
},
run(function() {
view.scrollTo(0);
});
assert.equal(findItems(this).length, 2, "The correct number of rows were rendered");
assert.equal(innerViewInsertionCount, 1, "expected number of innerView's didInsertElement");
assert.equal(innerViewDestroyCount, 1, "expected number of innerView's willDestroyElement");
assert.equal(listViewInsertionCount, 1, "expected number of listView's didInsertElement");
assert.equal(listViewDestroyCount, 0, "expected number of listView's willDestroyElement");
});
skip("recycling complex views short list", function(assert){
var content = generateContent(2),
height = 50,
rowHeight = 50,
itemViewClass = ListItemView.extend({
innerViewClass: Ember.View.extend({
didInsertElement: function(){
innerViewInsertionCount++;
},
willDestroyElement: function(){
innerViewDestroyCount++;
}
}),
template: compile("{{name}} {{#view view.innerViewClass}}{{/view}}")
});
var listViewInsertionCount, listViewDestroyCount,