Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ember Suave & Ember CLI Template Lin #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"preset": "ember-suave"
}
6 changes: 6 additions & 0 deletions .template-lintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* jshint node:true */
'use strict';

module.exports = {
extends: 'recommended'
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
"ember-cli-qunit": "^1.4.0",
"ember-cli-release": "^0.2.9",
"ember-cli-sri": "^2.1.0",
"ember-cli-template-lint": "0.4.11",
"ember-cli-uglify": "^1.2.0",
"ember-disable-prototype-extensions": "^1.1.0",
"ember-export-application-global": "^1.0.5",
"ember-load-initializers": "^0.5.1",
"ember-resolver": "^2.0.3",
"ember-suave": "4.0.0",
"loader.js": "^4.0.1"
},
"keywords": [
Expand Down
18 changes: 9 additions & 9 deletions tests/acceptance/interactions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module('Acceptance: Interactions', {
test('#checkByLabel finds a checkbox and checks it', (assert) => {
andThen(checkByLabel('This is the second checkbox'));
andThen(() => {
const checkedInput = find('#checkbox2:checked');
let checkedInput = find('#checkbox2:checked');

assert.equal('second_checkbox', checkedInput.val(), `expected the second checkbox to be checked but found ${checkedInput.val()}`);
});
Expand All @@ -60,46 +60,46 @@ test('#clickLink finds a link by its text and clicks it', function(assert) {

andThen(clickLink('First link'));
andThen(() => {
const url = currentURL();
let url = currentURL();
assert.equal(url, '/first-link-target');
});
});

test('#clickRadioByLabel adds checked attribute to corresponding input', (assert) => {
andThen(clickRadioByLabel('Label for first radio'));
andThen(() => {
const checkedInput = find('input:checked');
let checkedInput = find('input:checked');
assert.equal('radio_1', checkedInput.val(), 'expected radio 1 to be checked');
});
andThen(clickRadioByLabel('Label for second radio'));
andThen(() => {
const checkedInput = find('input:checked');
let checkedInput = find('input:checked');
assert.equal('radio_2', checkedInput.val(), 'expected radio 2 to be checked');
});
});

test('#fillInByLabel enters text into an input corresponding to a label', function(assert) {
const targetInput = 'form input.node-2';
const targetValue = 'Jane Doe';
let targetInput = 'form input.node-2';
let targetValue = 'Jane Doe';

assert.expect(2);

andThen(() => {
const val = find(targetInput).val();
let val = find(targetInput).val();
assert.notEqual(val, targetValue, 'did not expect the input to contain the target value yet');
});

andThen(fillInByLabel('Name', targetValue));
andThen(() => {
const val = find(targetInput).val();
let val = find(targetInput).val();
assert.equal(val, targetValue, 'expected the input to contain the target value');
});
});

test('#selectByLabel selects a dropdown option by label and option', (assert) => {
andThen(selectByLabel('Label for first select', 'Value 2'));
andThen(() => {
const selectedOption = find('option:selected');
let selectedOption = find('option:selected');
assert.equal('value2', selectedOption.val(), 'expected option 2 to be selected');
});
});
4 changes: 3 additions & 1 deletion tests/dummy/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';

const { Application } = Ember;

let App;

Ember.MODEL_FACTORY_INJECTIONS = true;

App = Ember.Application.extend({
App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';

let { Controller } = Ember;
const { Controller } = Ember;

export default Controller.extend({
buttonClickedText: null
Expand Down
4 changes: 3 additions & 1 deletion tests/dummy/app/router.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Ember from 'ember';
import config from './config/environment';

let Router = Ember.Router.extend({
const { Router: emberRouter } = Ember;

let Router = emberRouter.extend({
location: config.locationType
});

Expand Down
6 changes: 4 additions & 2 deletions tests/dummy/app/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Ember from 'ember';

const { Route } = Ember;
const set = Ember.set;
const {
Route,
set
} = Ember;

export default Route.extend({
actions: {
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
{{partial "elements/select"}}
{{partial "elements/table"}}
{{partial "elements/ul"}}
{{link-to 'First link' 'firstLink'}}
{{link-to "First link" "firstLink"}}
14 changes: 3 additions & 11 deletions tests/dummy/app/templates/elements/article.hbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
<article class='post' id='post_3'>
This is an article for John Doe.
</article>

<article class='post' id='post_1'>
This is an article for Jane Doe.
</article>

<article class='post' id='post_2'>
This is another article for Jane Doe.
</article>
<article class="post" id="post_3">This is an article for John Doe.</article>
<article class="post" id="post_1">This is an article for Jane Doe.</article>
<article class="post" id="post_2">This is another article for Jane Doe.</article>
15 changes: 3 additions & 12 deletions tests/dummy/app/templates/elements/aside.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
<!-- aside -->
<aside class='post' id='post_1'>
John Doe
</aside>

<aside class='post' id='post_2'>
Jane Doe
</aside>

<aside class='post' id='post_3'>
Jane Doe
</aside>
<aside class="post" id="post_1">John Doe</aside>
<aside class="post" id="post_2">Jane Doe</aside>
<aside class="post" id="post_3">Jane Doe </aside>
15 changes: 3 additions & 12 deletions tests/dummy/app/templates/elements/footer.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
<!-- footer -->
<footer class='post' id='post_1'>
John Doe
</footer>

<footer class='post' id='post_2'>
Jane Doe
</footer>

<footer class='post' id='post_3'>
Jane Doe
</footer>
<footer class="post" id="post_1">John Doe</footer>
<footer class="post" id="post_2">Jane Doe</footer>
<footer class="post" id="post_3">Jane Doe</footer>
23 changes: 11 additions & 12 deletions tests/dummy/app/templates/elements/form.hbs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<!-- form -->
<form class='node-4 post' id='post_1'>
<form class="node-4 post" id="post_1">
John Doe
<label class='node-1' for='name'>Name</label>
<input class='node-2' id='name' value='John Doe'>
<label class='node-3' for='email'>Email</label>
<input class='node-5' id='email' value='[email protected]'>
<label class="node-1" for="name">Name</label>
<input class="node-2" id="name" value="John Doe">
<label class="node-3" for="email">Email</label>
<input class="node-5" id="email" value="[email protected]">
<button {{action "buttonClicked" "First target button clicked"}}>First Target Button</button>
</form>

<form class='node-6 post' id='post_2'>
<form class="node-6 post" id="post_2">
Jane Doe
<input class='node-7' id='name' value='Jane Doe'>
<input class='node-8' id='email' value='[email protected]'>
<input class="node-7" id="name" value="Jane Doe">
<input class="node-8" id="email" value="[email protected]">
<input type="button" {{action "buttonClicked" "Second target button clicked"}} value="Second Target Button">
</form>

<form class='node-9 post' id='post_3'>
<form class="node-9 post" id="post_3">
Jane Doe
<input class='node-10' id='name' value='Jane Doe'>
<input class='node-11' id='email' value='[email protected]'>
<input class="node-10" id="name" value="Jane Doe">
<input class="node-11" id="email" value="[email protected]">
</form>
15 changes: 3 additions & 12 deletions tests/dummy/app/templates/elements/header.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
<!-- header -->
<header class='post' id='post_1'>
John Doe
</header>

<header class='post' id='post_2'>
Jane Doe
</header>

<header class='post' id='post_3'>
Jane Doe
</header>
<header class="post" id="post_1">John Doe</header>
<header class="post" id="post_2">Jane Doe</header>
<header class="post" id="post_3">Jane Doe</header>
3 changes: 1 addition & 2 deletions tests/dummy/app/templates/elements/img.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<!-- img -->
<img src='http://example.com/johndoe' alt='John Doe'/>
<img src="http://example.com/johndoe" alt="John Doe">
2 changes: 0 additions & 2 deletions tests/dummy/app/templates/elements/input-radio.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<!-- input: radio -->
<!-- radio inside of a radiogroup -->
<fieldset>
<input type="radio" id="radio_1" name="test" value="radio_1">
<label for="radio_1">Label for first radio</label>
Expand Down
14 changes: 3 additions & 11 deletions tests/dummy/app/templates/elements/nav.hbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
<nav class='post' id='post_1'>
John Doe
</nav>

<nav class='post' id='post_2'>
Jane Doe
</nav>

<nav class='post' id='post_3'>
Jane Doe
</nav>
<nav class="post" id="post_1">John Doe</nav>
<nav class="post" id="post_2">Jane Doe</nav>
<nav class="post" id="post_3">Jane Doe</nav>
17 changes: 3 additions & 14 deletions tests/dummy/app/templates/elements/ol.hbs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
<!-- ol -->
<ol class='posts' id='post_3'>
John Doe
</ol>

<ol class='posts' id='post_2'>
Jane Doe
</ol>

<ol class='posts' id='post_1'>
Jane Doe
</ol>


<ol class="posts" id="post_3">John Doe</ol>
<ol class="posts" id="post_2">Jane Doe</ol>
<ol class="posts" id="post_1">Jane Doe</ol>
7 changes: 3 additions & 4 deletions tests/dummy/app/templates/elements/p.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<!-- p -->
<p class='post' id='post_3'>
<p class="post" id="post_3">
This is a paragraph with the unique string of John Doe.
</p>

<p class='post' id='post_2'>
<p class="post" id="post_2">
The first paragraph for Jane Doe.
</p>

<p class='post' id='post_1'>
<p class="post" id="post_1">
The second paragraph for Jane Doe.
</p>
7 changes: 3 additions & 4 deletions tests/dummy/app/templates/elements/section.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<!-- section -->
<section class='post' id='post_3'>
<section class="post" id="post_3">
A section with John Doe.
</section>

<section class='post' id='post_1'>
<section class="post" id="post_1">
A section with Jane Doe.
</section>

<section class='post' id='post_2'>
<section class="post" id="post_2">
Another section with Jane Doe.
</section>
1 change: 0 additions & 1 deletion tests/dummy/app/templates/elements/select.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<!-- selects -->
<label for="select_1">Label for first select</label>
<select id="select_1" name="select_1">
<option value="value1" selected>Value 1</option>
Expand Down
3 changes: 1 addition & 2 deletions tests/dummy/app/templates/elements/table.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<!-- table -->
<head>
<meta name='title' content='CapybaraExtensions!' />
<meta name="title" content="CapybaraExtensions!">
</head>
<h1>Posts by John</h1>
<table>
Expand Down
21 changes: 6 additions & 15 deletions tests/dummy/app/templates/elements/ul.hbs
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
<!-- ul -->
<ul class='posts' id='post_3'>
John Doe
</ul>

<ul class='posts' id='post_2'>
Jane Doe
</ul>

<ul class='posts' id='post_1'>
Jane Doe
</ul>
<ul class="posts" id="post_3">John Doe</ul>
<ul class="posts" id="post_2">Jane Doe</ul>
<ul class="posts" id="post_1">Jane Doe</ul>

<ul>
<li class='post' id='post_3'>foo</li>
<li class='post' id='post_2'>bar</li>
<li class='post' id='post_1'>bar</li>
<li class="post" id="post_3">foo</li>
<li class="post" id="post_2">bar</li>
<li class="post" id="post_1">bar</li>
</ul>
4 changes: 3 additions & 1 deletion tests/helpers/destroy-app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Ember from 'ember';

const { run } = Ember;

export default function destroyApp(application) {
Ember.run(application, 'destroy');
run(application, 'destroy');
}
4 changes: 2 additions & 2 deletions tests/helpers/module-for-acceptance.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export default function(name, options = {}) {
this.application = startApp();

if (options.beforeEach) {
return options.beforeEach.apply(this, arguments);
return options.beforeEach(...arguments);
}
},

afterEach() {
let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
let afterEach = options.afterEach && options.afterEach(...arguments);
return Promise.resolve(afterEach).then(() => destroyApp(this.application));
}
});
Expand Down
11 changes: 8 additions & 3 deletions tests/helpers/start-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';

const {
merge,
run
} = Ember;

export default function startApp(attrs) {
let application;

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;

Ember.run(() => {
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
Expand Down
Loading