This repository has been archived by the owner on Sep 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
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
5509369
commit 1af9ab4
Showing
61 changed files
with
482 additions
and
490 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,84 +1,87 @@ | ||
import { join } from "path" | ||
import { exec } from "child_process" | ||
|
||
import test from "ava" | ||
import { exec } from "child_process" | ||
|
||
const target = join(__dirname, "..", "test-phenomic-theme-base") | ||
const execOpts = { cwd: target } | ||
|
||
const phenomic = "node ./node_modules/.bin/phenomic" | ||
const timing = process.env.CI ? 10000 : 5000 | ||
|
||
test.cb("should throw if a CLI flag is NOT recognized", (t) => { | ||
const child = exec( | ||
`${ phenomic } start --open=false --lol`, execOpts, | ||
(err) => { | ||
if (err && !err.killed) { | ||
clearTimeout(timeout) | ||
t.truthy(err.message.indexOf("Unknown argument") > -1) | ||
t.end() | ||
} | ||
} | ||
) | ||
describe("Integration: CLI", () => { | ||
beforeEach(() => { | ||
process.env.BABEL_ENV = "development" | ||
}) | ||
|
||
const timeout = setTimeout(() => { | ||
child.kill() | ||
t.fail() | ||
t.end() | ||
}, timing) | ||
}) | ||
it("should throw if a CLI flag is NOT recognized", () => { | ||
return new Promise((resolve, reject) => { | ||
const child = exec( | ||
`${ phenomic } start --open=false --lol`, execOpts, | ||
(err) => { | ||
if (err && !err.killed) { | ||
clearTimeout(timeout) | ||
expect(err.message.indexOf("Unknown argument") > -1).toBeTruthy() | ||
resolve() | ||
} | ||
} | ||
) | ||
|
||
test.cb("should NOT throw if a CLI flag is recognized", (t) => { | ||
const child = exec( | ||
`${ phenomic } start --open=false --devPort=4000`, execOpts, | ||
const timeout = setTimeout(() => { | ||
child.kill() | ||
reject("Test didn't finish before timeout") | ||
}, timing) | ||
}) | ||
}) | ||
|
||
// should die quickly... | ||
(err) => { | ||
if (err && !err.killed) { | ||
console.log(err) | ||
clearTimeout(timeout) | ||
t.fail() | ||
t.end() | ||
} | ||
} | ||
) | ||
it("should NOT throw if a CLI flag is recognized", () => { | ||
return new Promise((resolve, reject) => { | ||
const child = exec( | ||
`${ phenomic } start --open=false --devPort=4000`, execOpts, | ||
|
||
// ...or be ok quickly | ||
// (so we assume it's ok and kill the process, we don't need the actual build) | ||
const timeout = setTimeout(() => { | ||
child.kill() | ||
t.pass() | ||
t.end() | ||
}, timing) | ||
}) | ||
// should die quickly... | ||
(err) => { | ||
if (err && !err.killed) { | ||
clearTimeout(timeout) | ||
reject(err) | ||
} | ||
} | ||
) | ||
|
||
test.cb("should NOT throw if port is used", (t) => { | ||
const app = require("express")() | ||
// ...or be ok quickly | ||
// we assume it's ok and kill the process | ||
// we don't need the actual build | ||
const timeout = setTimeout(() => { | ||
child.kill() | ||
resolve() | ||
}, timing) | ||
}) | ||
}) | ||
|
||
const server = app.listen(8081, (err) => { | ||
if (err) { | ||
t.fail() | ||
t.end() | ||
} | ||
it("should NOT throw if port is used", () => { | ||
return new Promise((resolve, reject) => { | ||
const app = require("express")() | ||
const server = app.listen(3333, (err) => { | ||
if (err) { | ||
reject(err) | ||
} | ||
|
||
const child = exec( | ||
`${ phenomic } start --open=false --devPort=8081`, execOpts, | ||
const child = exec( | ||
`${ phenomic } start --open=false --devPort=3333`, execOpts, | ||
|
||
(err) => { | ||
if (err && !err.killed) { | ||
console.log(err) | ||
clearTimeout(timeout) | ||
t.fail() | ||
t.end() | ||
} | ||
} | ||
) | ||
(err) => { | ||
if (err && !err.killed) { | ||
clearTimeout(timeout) | ||
reject(err) | ||
} | ||
} | ||
) | ||
|
||
const timeout = setTimeout(() => { | ||
child.kill() | ||
server.close() | ||
t.pass() | ||
t.end() | ||
}, timing * 2) | ||
const timeout = setTimeout(() => { | ||
child.kill() | ||
server.close() | ||
resolve() | ||
}, timing * 2) | ||
}) | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"testRegex": "__tests__/.*\\.js$", | ||
"setupTestFrameworkScriptFile": "<rootDir>/scripts/jest-framework-setup.js", | ||
"testPathDirs": [ | ||
"__tests__" | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"testRegex": "__tests__/.*\\.js$", | ||
"setupTestFrameworkScriptFile": "<rootDir>/scripts/jest-framework-setup.js", | ||
"testPathDirs": [ | ||
"__tests__" | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000 // 30s |
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,4 +1,4 @@ | ||
import test from "ava" | ||
import test from "jest-ava-api" | ||
|
||
import beautifyHTML from ".." | ||
|
||
|
Oops, something went wrong.