-
Notifications
You must be signed in to change notification settings - Fork 0
/
buffered-proxy-test.js
102 lines (73 loc) · 3.55 KB
/
buffered-proxy-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('buffered-proxy', 'Integration | Component | buffered proxy', {
integration: true
});
test('smoke test', function(assert) {
assert.expect(15);
this.set('model', {
name: 'Ferdinand'
});
this.render(hbs`
<span class="outer-value">{{model.name}}</span>
{{#buffered-proxy content=model as |content apply discard hasChanges|}}
{{input value=content.name}}
<span class="inner-value">{{content.name}}</span>
<span class="has-changes">{{hasChanges}}</span>
<button {{action apply}} class="apply-button">Apply</button>
<button {{action discard}} class="discard-button">Discard</button>
{{/buffered-proxy}}
`);
assert.equal(this.$('.outer-value').text().trim(), 'Ferdinand');
assert.equal(this.$('.inner-value').text().trim(), 'Ferdinand');
assert.equal(this.$('.has-changes').text().trim(), 'false');
this.$('input').val('Wilhem').change();
assert.equal(this.$('.outer-value').text().trim(), 'Ferdinand');
assert.equal(this.$('.inner-value').text().trim(), 'Wilhem');
assert.equal(this.$('.has-changes').text().trim(), 'true');
this.$('.apply-button').click();
assert.equal(this.$('.outer-value').text().trim(), 'Wilhem');
assert.equal(this.$('.inner-value').text().trim(), 'Wilhem');
assert.equal(this.$('.has-changes').text().trim(), 'false');
this.$('input').val('Albert').change();
assert.equal(this.$('.outer-value').text().trim(), 'Wilhem');
assert.equal(this.$('.inner-value').text().trim(), 'Albert');
assert.equal(this.$('.has-changes').text().trim(), 'true');
this.$('.discard-button').click();
assert.equal(this.$('.outer-value').text().trim(), 'Wilhem');
assert.equal(this.$('.inner-value').text().trim(), 'Wilhem');
assert.equal(this.$('.has-changes').text().trim(), 'false');
});
test('smoke test wrapped primitive value', function(assert) {
assert.expect(15);
this.set('model', 'Ferdinand');
this.render(hbs`
<span class="outer-value">{{model}}</span>
{{#buffered-proxy content=model wrap=true as |content apply discard hasChanges|}}
{{input value=content.value}}
<span class="inner-value">{{content.value}}</span>
<span class="has-changes">{{hasChanges}}</span>
<button {{action apply}} class="apply-button">Apply</button>
<button {{action discard}} class="discard-button">Discard</button>
{{/buffered-proxy}}
`);
assert.equal(this.$('.outer-value').text().trim(), 'Ferdinand');
assert.equal(this.$('.inner-value').text().trim(), 'Ferdinand');
assert.equal(this.$('.has-changes').text().trim(), 'false');
this.$('input').val('Wilhem').change();
assert.equal(this.$('.outer-value').text().trim(), 'Ferdinand');
assert.equal(this.$('.inner-value').text().trim(), 'Wilhem');
assert.equal(this.$('.has-changes').text().trim(), 'true');
this.$('.apply-button').click();
assert.equal(this.$('.outer-value').text().trim(), 'Wilhem');
assert.equal(this.$('.inner-value').text().trim(), 'Wilhem');
assert.equal(this.$('.has-changes').text().trim(), 'false');
this.$('input').val('Albert').change();
assert.equal(this.$('.outer-value').text().trim(), 'Wilhem');
assert.equal(this.$('.inner-value').text().trim(), 'Albert');
assert.equal(this.$('.has-changes').text().trim(), 'true');
this.$('.discard-button').click();
assert.equal(this.$('.outer-value').text().trim(), 'Wilhem');
assert.equal(this.$('.inner-value').text().trim(), 'Wilhem');
assert.equal(this.$('.has-changes').text().trim(), 'false');
});