Bug 1086930 - Add status region to sync calendar sync button #26386
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ suiteGroup('views/settings', function() { | |
' <button class="sync update toolbar-item">', | ||
' <span class="icon"', | ||
' data-l10n-id="drawer-sync-button">Sync</span>', | ||
' <span class="sync-progress" role="progressbar"></span>', | ||
' </button>', | ||
' </div>', | ||
' </div>', | ||
|
@@ -170,6 +171,10 @@ suiteGroup('views/settings', function() { | |
assert.ok(subject.syncProgressTarget); | ||
}); | ||
|
||
test('#syncProgress', function() { | ||
assert.ok(subject.syncProgress); | ||
}); | ||
|
||
suite('#_observeAccountStore', function() { | ||
var accounts = testSupport.calendar.dbFixtures( | ||
'account', | ||
|
@@ -336,16 +341,27 @@ suiteGroup('views/settings', function() { | |
}); | ||
}); | ||
|
||
test('sync', function() { | ||
var controller = app.syncController; | ||
var calledWith; | ||
suite('syncProgress', function() { | ||
|
||
controller.all = function() { | ||
calledWith = arguments; | ||
}; | ||
test('syncStart', function(done) { | ||
app.syncController.on('syncStart', function () { | ||
assert.ok(subject.syncProgress.classList.contains('syncing')); | ||
assert.equal(subject.syncProgress.getAttribute('data-l10n-id'), | ||
'sync-progress-syncing'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these assertions are not working the way you expect.. the proper way to test this is to create 2 async tests like: suite('syncProgress', function() {
var syncController = app.syncController;
test('syncStart', function(done) {
syncController.on('syncStart', function () {
assert.ok(subject.syncProgress.classList.contains('syncing'));
assert.equal(subject.syncProgress.getAttribute('data-l10n-id'),
'sync-progress-syncing');
done();
});
syncController.emit('syncStart');
});
test('syncComplete', function(done) {
syncController.on('syncComplete', function () {
assert.equal(subject.syncProgress.getAttribute('data-l10n-id'),
'sync-progress-complete');
assert.notOk(subject.syncProgress.classList.contains('syncing'));
done();
});
syncController.emit('syncComplete');
});
}); or if you are really want to test the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @millermedeiros thanks for the explanation. I made the changes you recommended as it's probably enough in this case to test the actions of the events. The only change I made was to call app.syncController directly in the test blocks as app does not seem to be in scope for the suite. |
||
done(); | ||
}); | ||
app.syncController.emit('syncStart'); | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also check before triggering the initial state |
||
triggerEvent(subject.syncButton, 'click'); | ||
assert.ok(calledWith); | ||
test('syncComplete', function(done) { | ||
app.syncController.on('syncComplete', function () { | ||
assert.equal(subject.syncProgress.getAttribute('data-l10n-id'), | ||
'sync-progress-complete'); | ||
assert.notOk(subject.syncProgress.classList.contains('syncing')); | ||
done(); | ||
}); | ||
app.syncController.emit('syncComplete'); | ||
}); | ||
}); | ||
|
||
suite('#_onCalendarDisplayToggle', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment like this: https://github.com/jobara/gaia/blob/1086930/apps/calendar/locales/calendar.en-US.properties#L254-L255 here