Skip to content

Commit

Permalink
fix all auto-fixable eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kuceb committed Jul 1, 2019
1 parent 6cc6bfc commit 4cf9408
Show file tree
Hide file tree
Showing 105 changed files with 481 additions and 256 deletions.
5 changes: 4 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
"compounds": [
{
"name": "dev-debug w/ electron",
"configurations": ["dev-debug", "electron"]
"configurations": [
"dev-debug",
"electron"
]
}
]
}
2 changes: 0 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
Expand Down
4 changes: 2 additions & 2 deletions cli/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const spaceDelimitedSpecsMsg = (files) => {
If you are trying to pass multiple spec filenames, separate them by commas instead:
cypress run --spec spec1,spec2,spec3
`)

logger.log()
}

Expand Down Expand Up @@ -73,8 +74,7 @@ const parseOpts = (opts) => {
'project', 'spec', 'reporter', 'reporterOptions', 'path', 'destination',
'port', 'env', 'cypressVersion', 'config', 'record', 'key',
'browser', 'detached', 'headed', 'global', 'dev', 'force', 'exit',
'cachePath', 'cacheList', 'cacheClear', 'parallel', 'group', 'ciBuildId'
)
'cachePath', 'cacheList', 'cacheClear', 'parallel', 'group', 'ciBuildId')

if (opts.exit) {
opts = _.omit(opts, 'exit')
Expand Down
10 changes: 8 additions & 2 deletions cli/lib/tasks/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ const start = (options = {}) => {
debug('environment variable CYPRESS_INSTALL_BINARY = 0, skipping install')
logger.log(
stripIndent`
${chalk.yellow('Note:')} Skipping binary installation: Environment variable CYPRESS_INSTALL_BINARY = 0.`)
${chalk.yellow('Note:')} Skipping binary installation: Environment variable CYPRESS_INSTALL_BINARY = 0.`
)

logger.log()

return Promise.resolve()
Expand All @@ -184,7 +186,9 @@ const start = (options = {}) => {
${chalk.yellow('Note:')} Overriding Cypress cache directory to: ${chalk.cyan(envCache)}
Previous installs of Cypress may not be found.
`)
`
)

logger.log()
}

Expand Down Expand Up @@ -217,6 +221,7 @@ const start = (options = {}) => {
logger.log(stripIndent`
Cypress ${chalk.green(binaryVersion)} is installed in ${chalk.cyan(installDir)}
`)

logger.log()

if (options.force) {
Expand Down Expand Up @@ -254,6 +259,7 @@ const start = (options = {}) => {
These versions may not work properly together.
`)
)

logger.log()
}

Expand Down
3 changes: 2 additions & 1 deletion cli/lib/tasks/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ const writeBinaryVerifiedAsync = (verified, binaryDir) => {
return fs.outputJsonAsync(
getBinaryStatePath(binaryDir),
_.extend(contents, { verified }),
{ spaces: 2 })
{ spaces: 2 }
)
})
}

Expand Down
1 change: 1 addition & 0 deletions cli/lib/tasks/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ const start = (options = {}) => {
This overrides the default Cypress binary path used.
`)

logger.log()

return util.isExecutableAsync(envBinaryPath)
Expand Down
1 change: 1 addition & 0 deletions cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const logBrokenGtkDisplayWarning = () => {
Cypress will attempt to fix the problem and rerun.
`)

logger.warn()
}

Expand Down
3 changes: 3 additions & 0 deletions cli/scripts/post-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ shell.sed(
'<reference path="../chai/index.d.ts" />',
join('types', 'chai-jquery', 'index.d.ts')
)

shell.sed(
'-i',
'<reference types="jquery" />',
Expand All @@ -42,6 +43,7 @@ shell.sed(
'<reference path="../chai/index.d.ts" />',
sinonChaiFilename
)

// also use relative import via path for sinon-chai
// there is reference comment line we need to fix to be relative
shell.sed(
Expand All @@ -50,5 +52,6 @@ shell.sed(
'<reference path="../sinon/index.d.ts" />',
sinonChaiFilename
)

// and an import sinon line to be changed to relative path
shell.sed('-i', 'from \'sinon\';', 'from \'../sinon\';', sinonChaiFilename)
1 change: 1 addition & 0 deletions cli/test/lib/build_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('package.json build', () => {
name: 'test',
engines: 'test engines',
})

sinon.stub(fs, 'outputJsonAsync').resolves()
})

Expand Down
2 changes: 2 additions & 0 deletions cli/test/lib/cli_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ describe('cli', () => {
beforeEach(() => {
sinon.stub(state, 'getBinaryDir').returns(binaryDir)
})

it('reports package version', (done) => {
sinon.stub(util, 'pkgVersion').returns('1.2.3')
sinon
Expand Down Expand Up @@ -325,6 +326,7 @@ describe('cli', () => {
done()
})
})

context('cypress verify', () => {
it('verify calls verify.start with force: true', () => {
sinon.stub(verify, 'start').resolves()
Expand Down
1 change: 1 addition & 0 deletions cli/test/lib/exec/spawn_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('lib/exec/spawn', function () {
on: sinon.stub().returns(undefined),
},
}

sinon.stub(process, 'stdin').value(new EE)
sinon.stub(cp, 'spawn').returns(this.spawnedProcess)
sinon.stub(xvfb, 'start').resolves()
Expand Down
3 changes: 3 additions & 0 deletions cli/test/lib/exec/versions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ describe('lib/exec/versions', function () {
sinon.stub(state, 'getBinaryPkgVersionAsync').withArgs('/cache/1.2.3/Cypress.app').resolves('1.2.3')
sinon.stub(util, 'pkgVersion').returns('4.5.6')
})

describe('.getVersions', function () {
it('gets the correct binary and package version', function () {
return versions.getVersions().then(({ package, binary }) => {
expect(package).to.eql('4.5.6')
expect(binary).to.eql('1.2.3')
})
})

it('gets correct binary version if CYPRESS_RUN_BINARY', function () {
sinon.stub(state, 'parseRealPlatformBinaryFolderAsync').resolves('/my/cypress/path')
process.env.CYPRESS_RUN_BINARY = '/my/cypress/path'
state.getBinaryPkgVersionAsync
.withArgs('/my/cypress/path')
.resolves('7.8.9')

return versions.getVersions().then(({ package, binary }) => {
expect(package).to.eql('4.5.6')
expect(binary).to.eql('7.8.9')
Expand Down
6 changes: 4 additions & 2 deletions cli/test/lib/tasks/cache_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('lib/tasks/cache', () => {
},
},
})

sinon.stub(state, 'getCacheDir').returns('/.cache/Cypress')
this.stdout = stdout.capture()
})
Expand All @@ -37,6 +38,7 @@ describe('lib/tasks/cache', () => {
expect(this.stdout.toString()).to.eql('/.cache/Cypress\n')
})
})

describe('.clear', () => {
it('deletes cache folder and everything inside it', () => {
return cache.clear()
Expand All @@ -45,10 +47,10 @@ describe('lib/tasks/cache', () => {
.then((exists) => {
return expect(exists).to.eql(false)
})
}
)
})
})
})

describe('.list', () => {
it('lists all versions of cached binary', () => {
return cache.list()
Expand Down
4 changes: 4 additions & 0 deletions cli/test/lib/tasks/install_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ describe('/lib/tasks/install', function () {
mockfs({
[version]: 'asdf',
})

process.env.CYPRESS_INSTALL_BINARY = version

const installDir = state.getVersionDir()
Expand Down Expand Up @@ -352,6 +353,7 @@ describe('/lib/tasks/install', function () {
expect(download.start).to.not.be.called
})
})

it('uses cache when mismatch version given URL ', function () {
state.getBinaryPkgVersionAsync.resolves('1.2.3')
util.pkgVersion.returns('4.0.0')
Expand All @@ -362,6 +364,7 @@ describe('/lib/tasks/install', function () {
expect(download.start).to.not.be.called
})
})

it('uses cache when correct version installed given Zip', function () {
sinon.stub(fs, 'pathExistsAsync').withArgs('/path/to/zip.zip').resolves(true)

Expand All @@ -375,6 +378,7 @@ describe('/lib/tasks/install', function () {
expect(unzip.start).to.not.be.called
})
})

it('uses cache when mismatch version given Zip ', function () {
sinon.stub(fs, 'pathExistsAsync').withArgs('/path/to/zip.zip').resolves(true)

Expand Down
24 changes: 20 additions & 4 deletions cli/test/lib/tasks/state_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('lib/tasks/state', function () {
.stub(fs, 'pathExistsAsync')
.withArgs(binaryPkgPath)
.resolves(true)

sinon
.stub(fs, 'readJsonAsync')
.withArgs(binaryPkgPath)
Expand Down Expand Up @@ -66,6 +67,7 @@ describe('lib/tasks/state', function () {
.stub(fs, 'pathExistsAsync')
.withArgs(customBinaryPackageDir)
.resolves(true)

sinon
.stub(fs, 'readJsonAsync')
.withArgs(customBinaryPackageDir)
Expand All @@ -88,6 +90,7 @@ describe('lib/tasks/state', function () {
macExecutable
)
})

it('resolves path on linux', function () {
os.platform.returns('linux')
const linuxExecutable = '.cache/Cypress/1.2.3/Cypress/Cypress'
Expand All @@ -96,10 +99,12 @@ describe('lib/tasks/state', function () {
linuxExecutable
)
})

it('resolves path on windows', function () {
os.platform.returns('win32')
expect(state.getPathToExecutable(state.getBinaryDir())).to.endWith('.exe')
})

it('resolves from custom binaryDir', function () {
const customBinaryDir = 'home/downloads/cypress.app'

Expand Down Expand Up @@ -144,8 +149,7 @@ describe('lib/tasks/state', function () {
os.platform.returns('unknown')
expect(() => {
return state.getBinaryDir().to.throw('Platform: "unknown" is not supported.')
}
)
})
})
})

Expand All @@ -159,6 +163,7 @@ describe('lib/tasks/state', function () {
return expect(isVerified).to.be.equal(true)
})
})

it('resolves undefined if not verified', function () {
const err = new Error()

Expand All @@ -171,13 +176,15 @@ describe('lib/tasks/state', function () {
return expect(isVerified).to.be.equal(undefined)
})
})

it('can accept custom binaryDir', function () {
const customBinaryDir = '/custom/binary/dir'

sinon
.stub(fs, 'pathExistsAsync')
.withArgs('/custom/binary/dir/binary_state.json')
.resolves({ verified: true })

sinon
.stub(fs, 'readJsonAsync')
.withArgs('/custom/binary/dir/binary_state.json')
Expand All @@ -190,13 +197,16 @@ describe('lib/tasks/state', function () {
})
})
})

context('.writeBinaryVerified', function () {
beforeEach(() => {
mockfs({})
})

afterEach(() => {
mockfs.restore()
})

it('writes to binary state verified:true', function () {
sinon.stub(fs, 'outputJsonAsync').resolves()

Expand Down Expand Up @@ -224,10 +234,10 @@ describe('lib/tasks/state', function () {
{ verified: false },
{ spaces: 2 }
)
}
)
})
})
})

context('.getCacheDir', function () {
it('uses cachedir()', function () {
const ret = state.getCacheDir()
Expand All @@ -249,6 +259,7 @@ describe('lib/tasks/state', function () {
expect(ret).to.eql(path.resolve('local-cache/folder'))
})
})

context('.parseRealPlatformBinaryFolderAsync', function () {
beforeEach(function () {
sinon.stub(fs, 'realpathAsync').callsFake((path) => {
Expand All @@ -267,6 +278,7 @@ describe('lib/tasks/state', function () {
return expect(path).to.eql('/Documents/Cypress.app')
})
})

it('can parse on linux', function () {
os.platform.returns('linux')

Expand All @@ -276,6 +288,7 @@ describe('lib/tasks/state', function () {
return expect(path).to.eql('/Documents/Cypress')
})
})

it('can parse on darwin', function () {
os.platform.returns('win32')

Expand All @@ -285,6 +298,7 @@ describe('lib/tasks/state', function () {
return expect(path).to.eql('/Documents/Cypress')
})
})

it('throws when invalid on darwin', function () {
os.platform.returns('darwin')

Expand All @@ -294,6 +308,7 @@ describe('lib/tasks/state', function () {
return expect(path).to.eql(false)
})
})

it('throws when invalid on linux', function () {
os.platform.returns('linux')

Expand All @@ -303,6 +318,7 @@ describe('lib/tasks/state', function () {
return expect(path).to.eql(false)
})
})

it('throws when invalid on windows', function () {
os.platform.returns('win32')

Expand Down
Loading

0 comments on commit 4cf9408

Please sign in to comment.