Skip to content

Commit

Permalink
test: Refactor to async functions (#11833)
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepwithcoffee committed Mar 20, 2023
1 parent 5b87661 commit f57705e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions test/unit/lib/plugins/plugin/lib/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('PluginUtils', () => {
let fetchStub;
let pluginWithFetchStub;

beforeEach(() => {
beforeEach(async () => {
fetchStub = sinon.stub().returns(
BbPromise.resolve({
json: sinon.stub().returns(BbPromise.resolve(plugins)),
Expand All @@ -55,7 +55,7 @@ describe('PluginUtils', () => {
});
});

it('should fetch and return the plugins from the plugins repository', () => {
it('should fetch and return the plugins from the plugins repository', async () => {
const endpoint = 'https://raw.githubusercontent.com/serverless/plugins/master/plugins.json';

return pluginWithFetchStub.getPlugins().then((result) => {
Expand Down
6 changes: 3 additions & 3 deletions test/unit/lib/plugins/plugin/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('PluginList', () => {
expect(pluginList.hooks['plugin:list:list']).to.not.equal(undefined);
});

it('should run promise chain in order for "plugin:list:list" hook', () =>
it('should run promise chain in order for "plugin:list:list" hook', async () =>
expect(pluginList.hooks['plugin:list:list']()).to.be.fulfilled.then(() => {
expect(listStub.calledOnce).to.equal(true);
}));
Expand All @@ -53,7 +53,7 @@ describe('PluginList', () => {
let getPluginsStub;
let displayStub;

beforeEach(() => {
beforeEach(async () => {
getPluginsStub = sinon.stub(pluginList, 'getPlugins').returns(BbPromise.resolve());
displayStub = sinon.stub(pluginList, 'display').returns(BbPromise.resolve());
});
Expand All @@ -63,7 +63,7 @@ describe('PluginList', () => {
pluginList.display.restore();
});

it('should print a list with all available plugins', () =>
it('should print a list with all available plugins', async () =>
pluginList.list().then(() => {
expect(getPluginsStub.calledOnce).to.equal(true);
expect(displayStub.calledOnce).to.equal(true);
Expand Down
8 changes: 4 additions & 4 deletions test/unit/lib/plugins/plugin/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('PluginSearch', () => {
describe('#constructor()', () => {
let searchStub;

beforeEach(() => {
beforeEach(async () => {
searchStub = sinon.stub(pluginSearch, 'search').returns(BbPromise.resolve());
});

Expand All @@ -68,7 +68,7 @@ describe('PluginSearch', () => {
expect(pluginSearch.hooks['plugin:search:search']).to.not.equal(undefined);
});

it('should run promise chain in order for "plugin:search:search" hook', () =>
it('should run promise chain in order for "plugin:search:search" hook', async () =>
expect(pluginSearch.hooks['plugin:search:search']()).to.be.fulfilled.then(() => {
expect(searchStub.calledOnce).to.equal(true);
}));
Expand All @@ -78,7 +78,7 @@ describe('PluginSearch', () => {
let getPluginsStub;
let displayStub;

beforeEach(() => {
beforeEach(async () => {
getPluginsStub = sinon.stub(pluginSearch, 'getPlugins').returns(BbPromise.resolve(plugins));
displayStub = sinon.stub(pluginSearch, 'display').returns(BbPromise.resolve());
});
Expand All @@ -88,7 +88,7 @@ describe('PluginSearch', () => {
pluginSearch.display.restore();
});

it('should return a list of plugins based on the search query', () => {
it('should return a list of plugins based on the search query', async () => {
pluginSearch.options.query = 'serverless-plugin-1';

return expect(pluginSearch.search()).to.be.fulfilled.then(() => {
Expand Down

0 comments on commit f57705e

Please sign in to comment.