This repository has been archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20efaff
commit 16ae1bc
Showing
9 changed files
with
70 additions
and
57 deletions.
There are no files selected for viewing
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,62 +1,64 @@ | ||
const { spawnSync } = require('child_process') | ||
const path = require('path') | ||
const rimraf = require('rimraf') | ||
const {spawnSync} = require('child_process'); | ||
const path = require('path'); | ||
const rimraf = require('rimraf'); | ||
|
||
const scriptPath = path.resolve(__dirname, '../index.js') | ||
const packagePath = path.resolve(__dirname, '../__fixtures__/package') | ||
const emptyPackagePath = path.resolve(__dirname, '../__fixtures__/emptyPackage') | ||
const scriptPath = path.resolve(__dirname, '../index.js'); | ||
const packagePath = path.resolve(__dirname, '../__fixtures__/package'); | ||
const fixturesPath = path.resolve(__dirname, '../__fixtures__'); | ||
|
||
require('./to-run-successfully-matcher') | ||
require('./to-run-successfully-matcher'); | ||
|
||
describe('[CLI] init', () => { | ||
describe('react-tv init', () => { | ||
let slug = 'react-tv' | ||
let slug = 'react-tv'; | ||
|
||
beforeEach((done) => rimraf(path.resolve(packagePath, slug), done)) | ||
afterEach((done) => rimraf(path.resolve(packagePath, slug), done)) | ||
beforeEach(done => rimraf(path.resolve(packagePath, slug), done)); | ||
afterEach(done => rimraf(path.resolve(packagePath, slug), done)); | ||
|
||
it('should create react-tv folder', () => { | ||
const subject = spawnSync('node', [ | ||
scriptPath, | ||
'init' | ||
], { cwd: packagePath }) | ||
const subject = spawnSync('node', [scriptPath, 'init'], { | ||
cwd: packagePath, | ||
}); | ||
|
||
const createdAppPath = path.resolve(packagePath, slug) | ||
const appInfo = require(path.resolve(createdAppPath, 'webos/appinfo.json')) | ||
const createdAppPath = path.resolve(packagePath, slug); | ||
const appInfo = require(path.resolve( | ||
createdAppPath, | ||
'webos/appinfo.json' | ||
)); | ||
|
||
expect(appInfo.id).toEqual('react.tv.app') | ||
expect(appInfo.title).toEqual('package') | ||
expect(subject).toRunSuccessfully() | ||
}) | ||
expect(appInfo.id).toEqual('react.tv.app'); | ||
expect(appInfo.title).toEqual('package'); | ||
expect(subject).toRunSuccessfully(); | ||
}); | ||
|
||
it('should fail when package.json not exists', () => { | ||
const subject = spawnSync('node', [ | ||
scriptPath, | ||
'init' | ||
], { cwd: emptyPackagePath }) | ||
const subject = spawnSync('node', [scriptPath, 'init'], { | ||
cwd: fixturesPath, | ||
}); | ||
|
||
expect(subject).not.toRunSuccessfully() | ||
}) | ||
}) | ||
expect(subject).not.toRunSuccessfully(); | ||
}); | ||
}); | ||
|
||
describe('react-tv init <appName>', () => { | ||
const appName = 'russell-crowe' | ||
const appName = 'russell-crowe'; | ||
|
||
beforeEach((done) => rimraf(path.resolve(emptyPackagePath, appName), done)) | ||
afterEach((done) => rimraf(path.resolve(emptyPackagePath, appName), done)) | ||
beforeEach(done => rimraf(path.resolve(fixturesPath, appName), done)); | ||
afterEach(done => rimraf(path.resolve(fixturesPath, appName), done)); | ||
|
||
it('should create custom app', () => { | ||
const subject = spawnSync('node', [ | ||
scriptPath, | ||
'init', | ||
appName | ||
], { cwd: emptyPackagePath }) | ||
|
||
const createdAppPath = path.resolve(emptyPackagePath, appName) | ||
const createdPackageJson = require(path.resolve(createdAppPath, 'package.json')) | ||
|
||
expect(subject).toRunSuccessfully() | ||
expect(createdPackageJson.name).toEqual('russell-crowe') | ||
}) | ||
}) | ||
}) | ||
const subject = spawnSync('node', [scriptPath, 'init', appName], { | ||
cwd: fixturesPath, | ||
}); | ||
|
||
const createdAppPath = path.resolve(fixturesPath, appName); | ||
const createdPackageJson = require(path.resolve( | ||
createdAppPath, | ||
'package.json' | ||
)); | ||
|
||
expect(subject).toRunSuccessfully(); | ||
expect(createdPackageJson.name).toEqual('russell-crowe'); | ||
}); | ||
}); | ||
}); |
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,17 +1,20 @@ | ||
expect.extend({ | ||
toRunSuccessfully(received) { | ||
const pass = received.status === 0 | ||
const pass = received.status === 0; | ||
|
||
if (pass) { | ||
return { | ||
message: () => `expected exit code not to be 0`, | ||
pass: true, | ||
} | ||
}; | ||
} else { | ||
return { | ||
message: () => `expected exit code to be 0, was ${received.status} with error: \n${received.output}`, | ||
message: () => | ||
`expected exit code to be 0, was ${received.status} with error: \n${ | ||
received.output | ||
}`, | ||
pass: false, | ||
} | ||
}; | ||
} | ||
} | ||
}) | ||
}, | ||
}); |
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
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
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