Skip to content

Commit

Permalink
⬆️ Ember-Cli 3.0...3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nadnoslen committed Apr 6, 2022
1 parent e884bdf commit f1e472e
Show file tree
Hide file tree
Showing 9 changed files with 857 additions and 273 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
**/*{.,-}min.js
/blueprints/*/files/**/*.js
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
"ember-cli-build.js",
"index.js",
"testem.js",
"blueprints/*/index.js",
"config/**/*.js",
"tests/dummy/config/**/*.js",
],
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 8.17.0
nodejs 10.24.1
8 changes: 4 additions & 4 deletions MODULE_REPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

**Global**: `Ember.Logger`

**Location**: `addon/services/showdown-converter.js` at line 16
**Location**: `addon/services/showdown-converter.js` at line 21

```js
// set showdown global settings from the environment
if (Ember.isEmpty(config.APP.showdown)) {
if (isEmpty(config.APP.showdown)) {
Ember.Logger.info('The `ember-cli-marked-down` addon will use ShowdownJS defaults to create the Converters.');
Ember.Logger.info('If you want to customize ShowdownJS behaviour, please see the ember-cli-marked-down README: https://github.com/cybertoothca/ember-cli-marked-down#showdownjs-configuration-optional');
return;
Expand All @@ -17,10 +17,10 @@
**Global**: `Ember.Logger`
**Location**: `addon/services/showdown-converter.js` at line 17
**Location**: `addon/services/showdown-converter.js` at line 22
```js
if (Ember.isEmpty(config.APP.showdown)) {
if (isEmpty(config.APP.showdown)) {
Ember.Logger.info('The `ember-cli-marked-down` addon will use ShowdownJS defaults to create the Converters.');
Ember.Logger.info('If you want to customize ShowdownJS behaviour, please see the ember-cli-marked-down README: https://github.com/cybertoothca/ember-cli-marked-down#showdownjs-configuration-optional');
return;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ cd ember-cli-marked-down

- `ember test` – Runs the test suite on the current Ember version
- `ember test --server` – Runs the test suite in "watch mode"
- `yarn test` – Runs `ember try:each` to test your addon against multiple Ember versions
- `ember try:each` – Runs the test suite against multiple Ember versions

### Running the dummy application

Expand Down
15 changes: 8 additions & 7 deletions addon/helpers/marked-down.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { helper as buildHelper } from '@ember/component/helper';
import { htmlSafe } from '@ember/template';
import EmberObject from '@ember/object';
import { isEmpty, isBlank } from '@ember/utils';
import showdown from 'showdown';
import showdown from "showdown";

import { helper as buildHelper } from "@ember/component/helper";
import EmberObject from "@ember/object";
import { htmlSafe } from "@ember/template";
import { isBlank, isEmpty } from "@ember/utils";

export function markedDown(src, hash) {
if (isEmpty(src) || isBlank(src[0])) {
return '';
return "";
}
const converter = new showdown.Converter(EmberObject.create(hash));
const converter = new showdown.Converter(EmberObject.create(hash || {}));
return htmlSafe(converter.makeHtml(src[0].toString()));
}

Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
},
"scripts": {
"build": "ember build",
"lint:js": "eslint ./*.js addon addon-test-support app config lib server test-support tests",
"lint:js": "eslint ./*.js addon addon-test-support app blueprints config lib server test-support tests",
"start": "ember serve",
"test": "ember try:each"
"test": "ember test",
"test:all": "ember try:each"
},
"dependencies": {
"ember-auto-import": "^1.5.3",
Expand All @@ -51,7 +52,7 @@
"bootswatch": "^3.3.7",
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-cli": "~3.0.4",
"ember-cli": "~3.1.4",
"ember-cli-dependency-checker": "^2.0.0",
"ember-cli-deploy": "^1.0.2",
"ember-cli-deploy-build": "^1.1.1",
Expand All @@ -65,13 +66,13 @@
"ember-cli-shims": "^1.2.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-uglify": "^2.0.0",
"ember-cli-update": "^0.40",
"ember-cli-update": "0.54",
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-resolver": "^4.0.0",
"ember-source": "~3.0.0",
"ember-source": "~3.1.0",
"ember-source-channel-url": "^1.0.1",
"ember-try": "^0.2.23",
"ember-welcome-page": "^3.0.0",
Expand Down
86 changes: 49 additions & 37 deletions tests/unit/helpers/marked-down-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { markedDown } from 'dummy/helpers/marked-down';
import { module, test } from 'qunit';
import { markedDown } from "dummy/helpers/marked-down";
import { module, test } from "qunit";

module('Unit | Helper | marked down');
module("Unit | Helper | marked down");

test('when filtering xss attack', function (assert) {
test("when filtering xss attack", function (assert) {
const markdown = `Paragraph before...
<script type='text/javascript'>Ember.Logger.info('Attempted XSS');</script>
Expand All @@ -12,65 +12,77 @@ test('when filtering xss attack', function (assert) {
`;

// TODO: this test's markedDown output is incomplete and I cannot figure out why?!
assert.equal(markedDown(markdown).toHTML(),
'<p>P</p>', 'The script is not executed and has been stripped from the markup.');
assert.equal(
markedDown(markdown).toHTML(),
"<p>P</p>",
"The script is not executed and has been stripped from the markup."
);
});

test('when param has one element that is null', function (assert) {
assert.equal(markedDown([undefined]), '');
test("when param has one element that is null", function (assert) {
assert.equal(markedDown([undefined]), "");
});

test('when param has one element that is null', function (assert) {
assert.equal(markedDown([null]), '');
test("when param has one element that is null", function (assert) {
assert.equal(markedDown([null]), "");
});

test('when param is not present', function (assert) {
assert.equal(markedDown(), '');
test("when param is not present", function (assert) {
assert.equal(markedDown(), "");
});

test('when param is undefined', function (assert) {
assert.equal(markedDown(undefined), '');
test("when param is undefined", function (assert) {
assert.equal(markedDown(undefined), "");
});

test('when param is null', function (assert) {
assert.equal(markedDown(null), '');
test("when param is null", function (assert) {
assert.equal(markedDown(null), "");
});

test('when empty array param', function (assert) {
assert.equal(markedDown([]), '');
test("when empty array param", function (assert) {
assert.equal(markedDown([]), "");
});

test('when src is just some text', function (assert) {
assert.equal(markedDown(['123']).toHTML(), '<p>123</p>');
test("when src is just some text", function (assert) {
assert.equal(markedDown(["123"]).toHTML(), "<p>123</p>");
});

test('when hash is null', function (assert) {
assert.equal(markedDown(['123'], null).toHTML(), '<p>123</p>');
test("when hash is null", function (assert) {
assert.equal(markedDown(["123"], null).toHTML(), "<p>123</p>");
});

test('when src is a number', function (assert) {
assert.equal(markedDown([456]), '<p>456</p>');
test("when src is a number", function (assert) {
assert.equal(markedDown([456]), "<p>456</p>");
});

test('when src is a boolean', function (assert) {
assert.equal(markedDown([true]), '<p>true</p>');
test("when src is a boolean", function (assert) {
assert.equal(markedDown([true]), "<p>true</p>");
});

test('when src is empty string', function (assert) {
assert.equal(markedDown(['']), '');
test("when src is empty string", function (assert) {
assert.equal(markedDown([""]), "");
});

test('when src is markdown', function (assert) {
assert.equal(markedDown(['## Heading 2']).toHTML(), '<h2 id="heading2">Heading 2</h2>');
test("when src is markdown", function (assert) {
assert.equal(
markedDown(["## Heading 2"]).toHTML(),
'<h2 id="heading2">Heading 2</h2>'
);
});

test('when passing markdown option to helper', function (assert) {
assert.equal(markedDown(['## Heading 2'], {noHeaderId: true}).toHTML(), '<h2>Heading 2</h2>');
test("when passing markdown option to helper", function (assert) {
assert.equal(
markedDown(["## Heading 2"], { noHeaderId: true }).toHTML(),
"<h2>Heading 2</h2>"
);
});

test('when passing an invalid markdown option to helper', function (assert) {
assert.equal(markedDown(['## Heading 2'], {noHeaderId: false, malarkey: true}).toHTML(),
'<h2 id="heading2">Heading 2</h2>');
test("when passing an invalid markdown option to helper", function (assert) {
assert.equal(
markedDown(["## Heading 2"], {
noHeaderId: false,
malarkey: true,
}).toHTML(),
'<h2 id="heading2">Heading 2</h2>'
);
});


Loading

0 comments on commit f1e472e

Please sign in to comment.