-
Notifications
You must be signed in to change notification settings - Fork 15k
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
test: update power/notification specs to expect #13497
Conversation
spec/api-power-monitor-spec.js
Outdated
after(async () => { | ||
await reset() | ||
}) | ||
after(async () => { await reset() }) |
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.
Just pass reset
to the after()
call.
reset
function returns a Promise
, and after
can properly handle it.
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.
done
spec/api-notification-spec.js
Outdated
assert.equal(n.actions[0].text, '3') | ||
assert.equal(n.actions[1].type, 'button') | ||
assert.equal(n.actions[1].text, '4') | ||
expect(n.actions[0].type).to.equal('button') |
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.
Shouldn't we check that n.actions
is an array of the expected size first?
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.
done
spec/api-notification-spec.js
Outdated
assert.equal(n.actions[0].text, '1') | ||
assert.equal(n.actions[1].type, 'button') | ||
assert.equal(n.actions[1].text, '2') | ||
expect(n.actions[0].type).to.equal('button') |
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.
Shouldn't we check that n.actions
is an array of the expected size first?
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.
done
spec/api-power-monitor-spec.js
Outdated
logindMock.on('MethodCalled', onceMethodCalled(done)) | ||
// lazy load powerMonitor after we listen to MethodCalled mock signal | ||
dbusMockPowerMonitor = require('electron').remote.powerMonitor | ||
}) | ||
|
||
it('should call Inhibit to delay suspend', async () => { | ||
const calls = await getCalls() | ||
assert.equal(calls.length, 1) | ||
assert.deepEqual(calls[0].slice(1), [ | ||
expect(calls.length).to.equal(1) |
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.
Array of length 1?
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.
fixed
spec/api-power-monitor-spec.js
Outdated
dbusMockPowerMonitor.once('resume', () => done()) | ||
emitSignal('org.freedesktop.login1.Manager', 'PrepareForSleep', | ||
'b', [['b', false]]) | ||
}) | ||
|
||
it('should have called Inhibit again', async () => { | ||
const calls = await getCalls() | ||
assert.equal(calls.length, 2) | ||
assert.deepEqual(calls[1].slice(1), [ | ||
expect(calls.length).to.equal(2) |
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.
Array of length 2?
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.
fixed
assert.ok(idleState) | ||
it('notify current system idle state', done => { | ||
powerMonitor.querySystemIdleState(1, idleState => { | ||
expect(idleState).to.be.true() | ||
done() |
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.
I've heard that async/await is cool =)
it('notify current system idle state', async () => {
const idleState = await new Promise(
resolve => powerMonitor.querySystemIdleState(1, resolve))
expect(idleState).to.be.true()
})
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.
It feels forced in this simple case, I would leave it as is
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.
Ok =/
spec/api-power-save-blocker-spec.js
Outdated
const id = powerSaveBlocker.start('prevent-app-suspension') | ||
assert.ok(id != null) | ||
assert.equal(powerSaveBlocker.isStarted(id), true) | ||
expect(id).to.not.be.null() |
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.
If it's not null
, what it is? A number, an object, a symbol?
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.
fixed
@codebytere Sorry for a slow reaction to your PRs =/ |
@alexeykuzmin no worries 😁 i'm just coming back online after PTO so i'm gonna follow up and address these soon! |
5bd9cc7
to
659cc92
Compare
@codebytere, @alexeykuzmin I've rebased the branch to fix the conflict with |
3e93255
to
b260387
Compare
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.
LGTM.
I agree with @alexeykuzmin about using async / await but it's not a blocker for an expectification PR
Only gn builds failed and only because the branch is relatively old. |
No Release Notes |
Description of Change
This PR updates the
notification
,power-monitor
, andpower-save-monitor
specs as part of ongoing work to migrate our specs fromassert
to chai'sexpect
withdirty-chai
for better error messages./cc @alexeykuzmin
Checklist
npm test
passesRelease Notes
Notes: no-notes