diff --git a/Brocfile.js b/Brocfile.js deleted file mode 100644 index 8c25bfe..0000000 --- a/Brocfile.js +++ /dev/null @@ -1,20 +0,0 @@ -/* global require, module */ - -var EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); - -var app = new EmberAddon(); - -// Use `app.import` to add additional libraries to the generated -// output files. -// -// If you need to use different assets in different -// environments, specify an object as the first parameter. That -// object's keys should be the environment name and the values -// should be the asset to use in that environment. -// -// If the library that you are including contains AMD or ES6 -// modules that you would like to import into your application -// please specify an object with the list of modules as keys -// along with the exports of each module as its value. - -module.exports = app.toTree(); diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 74e4d78..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014-2015 John Otander - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/addon/helpers/md-remarkable.js b/addon/helpers/md-remarkable.js deleted file mode 100644 index 26daaba..0000000 --- a/addon/helpers/md-remarkable.js +++ /dev/null @@ -1,10 +0,0 @@ -import Ember from 'ember'; -import Remarkable from 'remarkable'; - -export function mdRemarkable(arg) { - var markdownInput = arg[0]; - var md = new Remarkable(); - return new Ember.Handlebars.SafeString(md.render(markdownInput)); -} - -export default Ember.Helper.helper(mdRemarkable); diff --git a/app/components/md-text.js b/app/components/md-text.js index 7bd3e10..0960ea9 100644 --- a/app/components/md-text.js +++ b/app/components/md-text.js @@ -1,3 +1 @@ -import mdText from 'ember-remarkable/components/md-text'; - -export default mdText; +export { default } from 'ember-remarkable/components/md-text'; \ No newline at end of file diff --git a/app/helpers/md.js b/app/helpers/md.js deleted file mode 100644 index 049c1ec..0000000 --- a/app/helpers/md.js +++ /dev/null @@ -1,3 +0,0 @@ -import md from 'ember-remarkable/helpers/md-remarkable'; - -export default md; diff --git a/blueprints/ember-remarkable/index.js b/blueprints/ember-remarkable/index.js index 6f324b0..56e2aa7 100644 --- a/blueprints/ember-remarkable/index.js +++ b/blueprints/ember-remarkable/index.js @@ -1,11 +1,7 @@ 'use strict'; module.exports = { - normalizeEntityName: function() { - // this prevents an error when the entityName is - // not specified (since that doesn't actually matter - // to us - }, + normalizeEntityName: function() {}, afterInstall: function() { return this.addBowerPackagesToProject([{ name: 'remarkable' }, { name: 'highlightjs' }]); diff --git a/tests/integration/components/md-text-test.js b/tests/integration/components/md-text-test.js new file mode 100644 index 0000000..3f08564 --- /dev/null +++ b/tests/integration/components/md-text-test.js @@ -0,0 +1,31 @@ +import { moduleForComponent, test } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; + +moduleForComponent('md-text', 'Integration | Component | md text', { + integration: true +}); + +test('it renders', function(assert) { + this.render(hbs`{{md-text text="# An awesome h1!"}}`); + assert.equal(this.$().text().trim(), 'An awesome h1!'); +}); + +test('it parses markdown', function(assert) { + this.render(hbs`{{md-text text="# An awesome h1!"}}`); + assert.equal(this.$('h1').text().trim(), 'An awesome h1!'); +}); + +test('it correctly creates a link from a url', function(assert) { + this.render(hbs`{{md-text text='# Markdown is fun www.google.com' linkify=true}}`); + assert.equal(this.$().find('a').length, 1); +}); + +test('it does not render html when the html option is set to false', function(assert) { + this.render(hbs`{{md-text text="Cool"}}`); + assert.equal(this.$().find('abbr').length, 0); +}); + +test('it renders html when the html option is set to true', function(assert) { + this.render(hbs`{{md-text text="Cool" html=true}}`); + assert.equal(this.$().find('abbr').length, 1); +}); diff --git a/tests/unit/components/md-text-test.js b/tests/unit/components/md-text-test.js deleted file mode 100644 index 7fbe7a8..0000000 --- a/tests/unit/components/md-text-test.js +++ /dev/null @@ -1,79 +0,0 @@ -import Ember from 'ember'; - -import { - moduleForComponent, - test -} from 'ember-qunit'; - -moduleForComponent('md-text', 'MdTextComponent', { - // specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'] -}); - -test('it renders', function() { - // creates the component instance - var component = this.subject(); - equal(component._state, 'preRender'); - - // appends the component to the page - this.append(); - equal(component._state, 'inDOM'); -}); - -test('it displays text', function() { - var component = this.subject(); - component.set('text', '# Markdown is fun'); - - var $component = this.append(); - equal($component.text().trim(), 'Markdown is fun'); -}); - -test('it properly parses the markdown', function() { - var component = this.subject(); - component.set('text', '# Markdown is fun'); - - var $component = this.append(); - equal($component.find('h1').length, 1); -}); - -test('it correctly creates a link from a url', function() { - var component = this.subject(); - component.set('linkify', true); - component.set('text', '# Markdown is fun www.google.com'); - - var $component = this.append(); - equal($component.find('a').length, 1); -}); - -test('it correctly identifies the syntax highlighting', function() { - var component = this.subject(); - component.set('text', '# Markdown is fun\n ```js\nvar awesome = require("awesome");```'); - - var $component = this.append(); - equal($component.find('.language-js').length, 1); -}); - -test('it does not highlight when there is no language specified', function() { - var component = this.subject(); - component.set('text', '# Markdown is fun\n ```var awesome = require("awesome");```'); - - var $component = this.append(); - equal($component.find('.language-js').length, 0); -}); - -test('it does not render html when the html option is set to false', function() { - var component = this.subject(); - component.set('text', '

Markdown is fun

'); - - var $component = this.append(); - equal($component.find('h1').length, 0); -}); - -test('it renders html when the html option is set to true', function() { - var component = this.subject(); - component.set('html', true); - component.set('text', '

Markdown is fun

'); - - var $component = this.append(); - equal($component.find('h1').length, 1); -}); diff --git a/tests/unit/helpers/md-remarkable-test.js b/tests/unit/helpers/md-remarkable-test.js deleted file mode 100644 index 99c9472..0000000 --- a/tests/unit/helpers/md-remarkable-test.js +++ /dev/null @@ -1,10 +0,0 @@ -import { - mdRemarkable -} from 'ember-remarkable/helpers/md-remarkable'; - -module('MdRemarkableHelper'); - -test('it correctly converts markdown to html', function() { - var result = mdRemarkable('# This should be a h1'); - equal(result.toString().trim(), '

This should be a h1

'); -});