Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
simonihmig committed Jan 9, 2021
1 parent 944a89d commit dc17a75
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
6 changes: 2 additions & 4 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ module.exports = function (defaults) {
// Add options here
'ember-cli-lazysizes': {
lazyClass: 'lazy',
plugins: [
'bgset'
]
}
plugins: ['bgset'],
},
});

/*
Expand Down
20 changes: 14 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,23 @@ module.exports = {
trees.push(tree);
}

let lazyNodeTree = this.treeGenerator(path.dirname(require.resolve('lazysizes')));
let lazyNodeTree = this.treeGenerator(
path.dirname(require.resolve('lazysizes'))
);
if (this.plugins.length > 0) {
let include = this.plugins.map((plugin) => `plugins/${plugin}/ls.${plugin}.js`);
let include = this.plugins.map(
(plugin) => `plugins/${plugin}/ls.${plugin}.js`
);
trees.push(transform(find(lazyNodeTree, { include })));
}
trees.push(transform(map(find(lazyNodeTree, 'lazysizes.js'), (content) => {
return `window.lazySizesConfig = ${JSON.stringify(this.addonOptions)};
trees.push(
transform(
map(find(lazyNodeTree, 'lazysizes.js'), (content) => {
return `window.lazySizesConfig = ${JSON.stringify(this.addonOptions)};
${content}`;
})));
})
)
);
return mergeTrees(trees, { overwrite: true });
}
},
};
14 changes: 7 additions & 7 deletions tests/acceptance/lazysizes-test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { test } from 'qunit';
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance';
import { module, test } from 'qunit';
import { visit } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';

moduleForAcceptance('Acceptance | lazysizes');
module('Acceptance | lazysizes', function (hooks) {
setupApplicationTest(hooks);

test('it creates the `lazySizes` global and overwrittes the `lazyClass`', function(assert) {
visit('/');
test('visiting /lazysizes', async function (assert) {
await visit('/');

andThen(function() {
assert.ok(window.lazySizes);
assert.equal(window.lazySizesConfig.lazyClass, 'lazy');
});
});

0 comments on commit dc17a75

Please sign in to comment.