-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PFX-186] - Jest create gasket app refactor (#506)
* updating docs plugin with jest * refactor testing to jest * config-set-builder refactor * linting, docs plugin jest refactor * create-gasket-app jest refactor
- Loading branch information
1 parent
427f73a
commit 937dc0f
Showing
4 changed files
with
32 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
const assume = require('assume'); | ||
const sinon = require('sinon'); | ||
const proxyquire = require('proxyquire'); | ||
const path = require('path'); | ||
|
||
describe('create-gasket-app', function () { | ||
let forkStub, mockExecute; | ||
const mockForkStub = jest.fn(); | ||
const mockExecute = (...args) => { | ||
process.argv = ['node', 'bin', ...args]; | ||
return mockForkStub( | ||
path.join(__dirname, '..', 'node_modules', '.bin', 'gasket'), | ||
['create', ...args], | ||
{ stdio: 'inherit', stdin: 'inherit', stderr: 'inherit' } | ||
); | ||
}; | ||
|
||
beforeEach(function () { | ||
forkStub = sinon.stub(); | ||
describe('create-gasket-app', function () { | ||
|
||
mockExecute = (...args) => { | ||
const argvStub = sinon.stub(process, 'argv').get(() => ['node', 'bin', ...args]); | ||
proxyquire('../', { child_process: { fork: forkStub } }); | ||
argvStub.restore(); | ||
}; | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
it('calls the @gasket/cli bin from node_modules', function () { | ||
mockExecute(); | ||
assume(forkStub.args[0][0]).includes(path.join('node_modules', '.bin', 'gasket')); | ||
expect(mockForkStub.mock.calls[0][0]).toContain(path.join('node_modules', '.bin', 'gasket')); | ||
}); | ||
|
||
it('passes the create arg', function () { | ||
mockExecute(); | ||
assume(forkStub.args[0][1]).eqls(['create']); | ||
expect(mockForkStub.mock.calls[0][1]).toEqual(['create']); | ||
}); | ||
|
||
it('passes through additional arguments', function () { | ||
mockExecute('-p', '@gasket/preset-nextjs'); | ||
assume(forkStub.args[0][1]).eqls(['create', '-p', '@gasket/preset-nextjs']); | ||
expect(mockForkStub.mock.calls[0][1]).toEqual(['create', '-p', '@gasket/preset-nextjs']); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.