Skip to content

Commit e153fd3

Browse files
committed
Update tests to use async/await
1 parent 0cdb9aa commit e153fd3

File tree

3 files changed

+186
-325
lines changed

3 files changed

+186
-325
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
root: true,
33
parserOptions: {
4-
ecmaVersion: 6,
4+
ecmaVersion: 10,
55
sourceType: 'module'
66
},
77
extends: 'eslint:recommended',

tests/unit/index-test.js

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ describe("redis plugin", function() {
523523
var plugin;
524524
var context;
525525

526-
it("uploads the index", function() {
526+
it("uploads the index", async function() {
527527
plugin = subject.createDeployPlugin({
528528
name: "redis"
529529
});
@@ -550,14 +550,13 @@ describe("redis plugin", function() {
550550
plugin.beforeHook(context);
551551
plugin.configure(context);
552552

553-
return assert.isFulfilled(plugin.upload(context)).then(function(result) {
554-
assert.deepEqual(result, { redisKey: "test-prefix:123abc" });
555-
});
553+
let result = await assert.isFulfilled(plugin.upload(context));
554+
assert.deepEqual(result, { redisKey: "test-prefix:123abc" });
556555
});
557556
});
558557

559558
describe("activate hook", function() {
560-
it("activates revision", function() {
559+
it("activates revision", async function() {
561560
var activateCalled = false;
562561

563562
var plugin = subject.createDeployPlugin({
@@ -585,15 +584,12 @@ describe("redis plugin", function() {
585584
};
586585
plugin.beforeHook(context);
587586

588-
return assert
589-
.isFulfilled(plugin.activate(context))
590-
.then(function(result) {
591-
assert.ok(activateCalled);
592-
assert.equal(result.revisionData.activatedRevisionKey, "123abc");
593-
});
587+
let result = await assert.isFulfilled(plugin.activate(context));
588+
assert.ok(activateCalled);
589+
assert.equal(result.revisionData.activatedRevisionKey, "123abc");
594590
});
595591

596-
it("rejects if an error is thrown when activating", function() {
592+
it("rejects if an error is thrown when activating", async function() {
597593
var plugin = subject.createDeployPlugin({
598594
name: "redis"
599595
});
@@ -619,9 +615,8 @@ describe("redis plugin", function() {
619615
};
620616

621617
plugin.beforeHook(context);
622-
return assert.isRejected(plugin.activate(context)).then(function(error) {
623-
assert.equal(error, "some-error");
624-
});
618+
let error = await assert.isRejected(plugin.activate(context));
619+
assert.equal(error, "some-error");
625620
});
626621
});
627622
describe("didDeploy hook", function() {
@@ -666,7 +661,7 @@ describe("redis plugin", function() {
666661
});
667662

668663
describe("fetchInitialRevisions hook", function() {
669-
it("fills the initialRevisions variable on context", function() {
664+
it("fills the initialRevisions variable on context", async function() {
670665
var plugin;
671666
var context;
672667

@@ -701,23 +696,20 @@ describe("redis plugin", function() {
701696
plugin.beforeHook(context);
702697
plugin.configure(context);
703698

704-
return assert
705-
.isFulfilled(plugin.fetchInitialRevisions(context))
706-
.then(function(result) {
707-
assert.deepEqual(result, {
708-
initialRevisions: [
709-
{
710-
active: false,
711-
revision: "a"
712-
}
713-
]
714-
});
715-
});
699+
let result = await assert.isFulfilled(plugin.fetchInitialRevisions(context));
700+
assert.deepEqual(result, {
701+
initialRevisions: [
702+
{
703+
active: false,
704+
revision: "a"
705+
}
706+
]
707+
});
716708
});
717709
});
718710

719711
describe("fetchRevisions hook", function() {
720-
it("fills the revisions variable on context", function() {
712+
it("fills the revisions variable on context", async function() {
721713
var plugin;
722714
var context;
723715

@@ -752,18 +744,15 @@ describe("redis plugin", function() {
752744
plugin.beforeHook(context);
753745
plugin.configure(context);
754746

755-
return assert
756-
.isFulfilled(plugin.fetchRevisions(context))
757-
.then(function(result) {
758-
assert.deepEqual(result, {
759-
revisions: [
760-
{
761-
active: false,
762-
revision: "a"
763-
}
764-
]
765-
});
766-
});
747+
let result = await assert.isFulfilled(plugin.fetchRevisions(context));
748+
assert.deepEqual(result, {
749+
revisions: [
750+
{
751+
active: false,
752+
revision: "a"
753+
}
754+
]
755+
});
767756
});
768757
});
769758
});

0 commit comments

Comments
 (0)