Skip to content

Commit

Permalink
Merge pull request #165 from san650/uncomment_default_properties_acce…
Browse files Browse the repository at this point in the history
…ptance_test

Nice!
  • Loading branch information
jeradg committed Apr 19, 2016
2 parents 3600a8b + fe9423e commit c483fab
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 76 deletions.
152 changes: 81 additions & 71 deletions tests/acceptance/default-properties-test.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,81 @@
// import { test } from 'qunit';
// import moduleForAcceptance from '../helpers/module-for-acceptance';
// import PageObject from '../page-object';
//
// moduleForAcceptance('Acceptance | default properties');
//
// var {
// visitable
// } = PageObject;
//
// test('Adds default properties', function(assert) {
// var page = PageObject.create({
// visit: visitable('/calculator'),
//
// one: {
// scope: '.numbers button:nth-of-type(1)'
// },
//
// screen: {
// scope: '.screen'
// }
// });
//
// page
// .visit()
// .clickOn('9')
// .one()
// .click();
//
// andThen(function() {
// assert.equal(page.screen().text(), '91', 'text');
// assert.ok(page.screen().contains('91'), 'contains');
// assert.ok(!page.screen().contains('99'), 'not contains');
// assert.ok(page.screen().isVisible(), 'isVisible');
// assert.ok(!page.screen().isHidden(), 'isHidden');
// });
// });
//
// test('Overrides default properties', function(assert) {
// var page = PageObject.create({
// dummy: {
// isHidden() {
// return 'isHidden';
// },
// isVisible() {
// return 'isVisible';
// },
// clickOn() {
// return 'clickOn';
// },
// click() {
// return 'click';
// },
// contains() {
// return 'contains';
// },
// text() {
// return 'text';
// }
// }
// });
//
// andThen(function() {
// assert.equal(page.dummy().isHidden(), 'isHidden');
// assert.equal(page.dummy().isVisible(), 'isVisible');
// assert.equal(page.dummy().clickOn(), 'clickOn');
// assert.equal(page.dummy().click(), 'click');
// assert.equal(page.dummy().contains(), 'contains');
// assert.equal(page.dummy().text(), 'text');
// });
// });
import { test } from 'qunit';
import moduleForAcceptance from '../helpers/module-for-acceptance';
import PageObject from '../page-object';

moduleForAcceptance('Acceptance | default properties');

var {
visitable
} = PageObject;

test('Adds default properties', function(assert) {
var page = PageObject.create({
visit: visitable('/calculator'),

one: {
scope: '.numbers button:nth-of-type(1)'
},

screen: {
scope: '.screen',

expression: {
scope: 'input'
},

result: {
scope: '.result'
}
}
});

page
.visit()
.clickOn('9')
.one
.click();

page.clickOn('=');

andThen(function() {
assert.equal(page.screen.result.text, '91', 'text');
assert.ok(page.screen.result.contains('91'), 'contains');
assert.ok(!page.screen.result.contains('99'), 'not contains');
assert.ok(page.screen.isVisible, 'isVisible');
assert.ok(!page.screen.isHidden, 'isHidden');
});
});

test('Overrides default properties', function(assert) {
var page = PageObject.create({
dummy: {
isHidden() {
return 'isHidden';
},
isVisible() {
return 'isVisible';
},
clickOn() {
return 'clickOn';
},
click() {
return 'click';
},
contains() {
return 'contains';
},
text() {
return 'text';
}
}
});

andThen(function() {
assert.equal(page.dummy.isHidden(), 'isHidden');
assert.equal(page.dummy.isVisible(), 'isVisible');
assert.equal(page.dummy.clickOn(), 'clickOn');
assert.equal(page.dummy.click(), 'click');
assert.equal(page.dummy.contains(), 'contains');
assert.equal(page.dummy.text(), 'text');
});
});
10 changes: 6 additions & 4 deletions tests/dummy/app/controllers/calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default Ember.Controller.extend({
init() {
this.setProperties({
result: '',
expression: '',
op: ''
});
},
Expand All @@ -18,7 +19,7 @@ export default Ember.Controller.extend({

actions: {
keyPress(key) {
var result = this.get('result'),
var result = this.get('expression'),
stack = this.get('stack'),
op = this.get('op');

Expand All @@ -27,10 +28,11 @@ export default Ember.Controller.extend({
case '-':
case '=':
stack.push(parseInt(op + result));
this.set('result', '');
this.set('result', result);
this.set('expression', '');
break;
default:
this.set('result', result + key.toString());
this.set('expression', result + key.toString());
break;
}

Expand All @@ -40,7 +42,7 @@ export default Ember.Controller.extend({
break;
case '=':
result = stack.reduce((result, value) => result + value , 0);
this.set('result', result.toString());
this.set('expression', result.toString());
break;
}
}
Expand Down
5 changes: 4 additions & 1 deletion tests/dummy/app/templates/calculator.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<div class="calculator">
<div class="screen">
{{input value=result}}
{{input value=expression}}
<div class="result">
{{result}}
</div>
</div>
<div class="keyboard">
<div class="numbers">
Expand Down
3 changes: 3 additions & 0 deletions tests/dummy/app/templates/components/calculating-device.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<div class="calculator">
<div class="screen">
{{result}}
<div class="expression">
{{expression}}
</div>
</div>
<div class="keyboard">
<div class="numbers">
Expand Down

0 comments on commit c483fab

Please sign in to comment.