Skip to content

Commit

Permalink
Add test for issue #98
Browse files Browse the repository at this point in the history
  • Loading branch information
Robdel12 committed Mar 10, 2016
1 parent ac50f39 commit 71ff2eb
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 19 deletions.
5 changes: 4 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "emberx-select",
"dependencies": {
"ember": "1.13.13",
"ember": "2.3.0",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
"ember-mocha": "0.8.8",
Expand All @@ -10,5 +10,8 @@
"ember-resolver": "~0.1.18",
"jquery": "1.11.3",
"loader.js": "ember-cli/loader.js#3.2.1"
},
"resolutions": {
"ember": "2.3.0"
}
}
68 changes: 57 additions & 11 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,63 @@
module.exports = {
scenarios: [
{
name: 'default',
dependencies: { }
name: 'Ember 1.13.0',
// this is a bug in ember. See:
//https://github.com/emberjs/ember.js/pull/11651
allowedToFail: true,
bower: {
dependencies: {
'ember': '1.13.0'
}
}
},
{
name: 'Ember 1.13.4',
bower: {
dependencies: {
'ember': '1.13.4'
}
}
},
{
name: 'Ember 2.0.0',
bower: {
dependencies: {
'ember': '2.0.0'
}
}
},
{
name: 'Ember 2.1.0',
bower: {
dependencies: {
'ember': '2.1.0'
}
}
},
{
name: 'Ember 2.2.0',
bower: {
dependencies: {
'ember': '2.2.0'
}
}
},
{
name: 'Ember 2.3.0',
bower: {
dependencies: {
'ember': '2.3.0'
}
}
},
{
name: 'Ember 2.4.0',
bower: {
dependencies: {
'ember': '2.4.0'
}
}
},
{
name: 'ember-release',
Expand All @@ -21,15 +76,6 @@ module.exports = {
resolutions: {
'ember': 'beta'
}
},
{
name: 'ember-canary',
dependencies: {
'ember': 'components/ember#canary'
},
resolutions: {
'ember': 'canary'
}
}
]
};
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"broccoli-asset-rev": "^2.1.2",
"ember-cli": "1.13.8",
"ember-cli-app-version": "0.5.0",
"ember-cli-content-security-policy": "0.4.0",
"ember-cli-dependency-checker": "^1.0.1",
"ember-cli-github-pages": "0.0.6",
"ember-cli-htmlbars": "0.7.9",
Expand All @@ -34,7 +33,7 @@
"ember-disable-prototype-extensions": "^1.0.0",
"ember-disable-proxy-controllers": "^1.0.0",
"ember-export-application-global": "^1.0.3",
"ember-try": "0.0.6"
"ember-try": "0.2.0"
},
"keywords": [
"ember-addon",
Expand Down
38 changes: 38 additions & 0 deletions tests/acceptance/sandbox-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* jshint expr:true */
import { describe, it, beforeEach, afterEach } from 'mocha';
import { expect } from 'chai';
import startApp from '../helpers/start-app';
import Ember from 'ember';

describe.only('Acceptance: Sandbox', function() {
let application;

beforeEach(function() {
application = startApp();
return visit('/sandbox');
});

afterEach(function() {
Ember.run(application, 'destroy');
});

it('can visit /sandbox', function() {
expect(currentPath()).to.equal('sandbox');
});

it("issue 98 has two options", function() {
expect($('.spec-issue-98').find('option').length).to.equal(2);
});

describe("toggling streak", function() {
beforeEach(function() {
click('.spec-toggle-streak');
});

it("adds 3 options to x-select", function() {
expect($('.spec-issue-98').find('option').length).to.equal(5);
});
});


});
22 changes: 19 additions & 3 deletions tests/dummy/app/controllers/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@ import Ember from 'ember';

export default Ember.Controller.extend({
makes: Ember.computed(function() {
return [{name: "Acura"}, {name: "Audi"}, {name: "Bentley"}, {name: "BMW"}, {name: "Ford"}];
return ["Acura", "Audi", "Bentley", "BMW", "Ford"];
}),

models: Ember.computed('selectedMake', function() {
if (this.get('selectedMake.name') === "Ford") {
return [{model: "Focus"}, {model: "Edge"}, {model: "Explorer"}, {model: "GT"}, {model: "Mustang"}]
return ["Focus", "Edge", "Explorer", "GT", "Mustang"];
}
})
}),

isStreak: true,
formats: Ember.computed(function () {
return ["thing", "another thing"];
}),

buildStatesFormats: Ember.computed(function () {
return ["Hello", "is it me?", "you're looking for"];
}),

actions: {
toggleStreak() {
this.toggleProperty('isStreak');
return false;
}
}
});
20 changes: 18 additions & 2 deletions tests/dummy/app/templates/sandbox.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,31 @@
<p>Make:</p>
{{#x-select value=selectedMake}}
{{#each makes as |make|}}
{{#x-option value=make}}{{make.name}}{{/x-option}}
{{#x-option value=make}}{{make}}{{/x-option}}
{{/each}}
{{/x-select}}
</div>
<div>
<p>Model:</p>
{{#x-select value=selectedModel}}
{{#each models as |model|}}
{{#x-option value=model}}{{model.model}}{{/x-option}}
{{#x-option value=model}}{{model}}{{/x-option}}
{{/each}}
{{/x-select}}
</div>


<div style="margin-top: 40px">
<h3>Issue #98</h3>
{{#x-select value=format class="spec-issue-98"}}
{{#each formats as |format|}}
{{#x-option value=format}}{{format}}{{/x-option}}
{{/each}}
{{#unless isStreak}}
{{#each buildStatesFormats as |format|}}
{{#x-option value=format}}{{format}}{{/x-option}}
{{/each}}
{{/unless}}
{{/x-select}}
<p><button {{action "toggleStreak"}} class="spec-toggle-streak">Toggle streak</button></p>
</div>

0 comments on commit 71ff2eb

Please sign in to comment.