Skip to content

Commit

Permalink
Merge pull request #57 from Dhaulagiri/br-modules
Browse files Browse the repository at this point in the history
use new modules syntax
  • Loading branch information
jasonmit authored Aug 29, 2017
2 parents 1b0fc77 + 4c03d9e commit e4ba9d3
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 30 deletions.
13 changes: 7 additions & 6 deletions addon/components/markdown-to-html.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import Ember from 'ember';
import { htmlSafe } from '@ember/string';
import Component from '@ember/component';
import { get, computed } from '@ember/object';
import { merge, assign } from '@ember/polyfills';
import { getOwner } from '@ember/application';
import showdown from 'showdown';
import layout from '../templates/components/markdown-to-html';

const { computed, get, merge, getOwner } = Ember;
const CONFIG_LOOKUP = 'config:environment';

let assign = Ember.assign;

if (!assign) {
assign = function assignPolyfill(...objects) {
return objects.reduce(merge);
};
}

const ShowdownComponent = Ember.Component.extend({
const ShowdownComponent = Component.extend({
layout,
markdown: '',
_globalOptions: null,
Expand Down Expand Up @@ -45,7 +46,7 @@ const ShowdownComponent = Ember.Component.extend({
}
}

return Ember.String.htmlSafe(converter.makeHtml(get(this, 'markdown')));
return htmlSafe(converter.makeHtml(get(this, 'markdown')));
}).readOnly(),

converter: computed('extensions', function() {
Expand Down
6 changes: 2 additions & 4 deletions tests/dummy/app/app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import Ember from 'ember';
import Application from '@ember/application';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';

let App;

Ember.MODEL_FACTORY_INJECTIONS = true;

App = Ember.Application.extend({
App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ember from 'ember';
import EmberRouter from '@ember/routing/router';
import config from './config/environment';

const Router = Ember.Router.extend({
const Router = EmberRouter.extend({
location: config.locationType,
rootURL: config.rootURL
});
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/destroy-app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ember from 'ember';
import { run } from '@ember/runloop';

export default function destroyApp(application) {
Ember.run(application, 'destroy');
run(application, 'destroy');
}
4 changes: 1 addition & 3 deletions tests/helpers/module-for-acceptance.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Promise } from 'rsvp';
import { module } from 'qunit';
import Ember from 'ember';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';

const { RSVP: { Promise } } = Ember;

export default function(name, options = {}) {
module(name, {
beforeEach() {
Expand Down
9 changes: 5 additions & 4 deletions tests/helpers/start-app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Ember from 'ember';
import { run } from '@ember/runloop';
import { merge } from '@ember/polyfills';
import Application from '../../app';
import config from '../../config/environment';

export default function startApp(attrs) {
let attributes = Ember.merge({}, config.APP);
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
let attributes = merge({}, config.APP);
attributes = merge(attributes, attrs); // use defaults, but you can override;

return Ember.run(() => {
return run(() => {
let application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/components/markdown-to-html-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Ember from 'ember';
import { run } from '@ember/runloop';
import showdown from 'showdown';
import { moduleForComponent, test } from 'ember-qunit';

Expand All @@ -18,7 +18,7 @@ test('it produces markdown', function(assert) {
let component = this.subject();
this.render();

Ember.run(function() {
run(function() {
component.set('markdown', '##Hello, [world](#)');
});

Expand All @@ -34,7 +34,7 @@ test('it inserts <br> tag', function(assert) {
let component = this.subject();
this.render();

Ember.run(function() {
run(function() {
component.set('markdown', 'foo \nbar');
});

Expand All @@ -50,7 +50,7 @@ test('supports setting showdown options', function(assert) {
let component = this.subject();
this.render();

Ember.run(function() {
run(function() {
component.set('markdown', '# title\nI ~~dislike~~ enjoy visiting http://www.google.com');
component.set('simplifiedAutoLink', true);
component.set('headerLevelStart', 3);
Expand All @@ -74,7 +74,7 @@ test('supports setting showdown options merged with global options', function(as
let component = this.subject();
this.render();

Ember.run(function() {
run(function() {
component.set('markdown', '# title\nI ~~dislike~~ enjoy visiting http://www.google.com');
component.set('headerLevelStart', 3);
component.set('strikethrough', true);
Expand All @@ -101,7 +101,7 @@ test('it supports loading showdown extensions', function(assert) {
let component = this.subject({ extensions: ['demo'] });
this.render();

Ember.run(function() {
run(function() {
component.set("markdown", "this is an ember showdown!");
});

Expand All @@ -118,7 +118,7 @@ test('does not reset default showdown options with undefined', function(assert)
let component = this.subject();
this.render();

Ember.run(function() {
run(function() {
component.set('markdown', '~~dislike~~');
});

Expand Down Expand Up @@ -156,7 +156,7 @@ test('it supports loading showdown extensions', function(assert) {
let component = this.subject({ extensions: 'demo excited' });
this.render();

Ember.run(function() {
run(function() {
component.set("markdown", "this is a showdown");
});

Expand All @@ -171,7 +171,7 @@ test('it does not munge code fences', function(assert) {
let component = this.subject();
this.render();

Ember.run(function() {
run(function() {
component.set("ghCodeBlocks", true);
component.set("markdown", "```html\n<strong>hello</strong>\n<em>world</em>\n```");
});
Expand Down

0 comments on commit e4ba9d3

Please sign in to comment.