-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from regal/feat/5-ts-option
feat(bundle): Implement bundler.input.ts option
- Loading branch information
Showing
10 changed files
with
162 additions
and
20 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,7 +1,6 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
collectCoverageFrom: [ | ||
"src/**" | ||
] | ||
}; | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
collectCoverageFrom: ["src/**"], | ||
setupTestFrameworkScriptFile: "<rootDir>/test/jest-setup.js" | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { GameApi } from "regal"; | ||
import { lines } from "../../test-utils"; | ||
|
||
// @ts-ignore: import will be resolved | ||
import { bundle } from "../../../dist/regal-bundler.cjs.js"; | ||
|
||
describe("Case: JS Basic", () => { | ||
beforeAll(async () => { | ||
await bundle({ configLocation: __dirname }); | ||
}); | ||
|
||
it("Creates a functional bundle without typescript", async () => { | ||
// @ts-ignore: import will be resolved | ||
const Game: GameApi = await import("./js-basic.regal.js"); | ||
|
||
let response = Game.postStartCommand(); | ||
expect(response.output.wasSuccessful).toBe(true); | ||
expect(lines(response)).toEqual(["Game initialized to zero."]); | ||
|
||
response = Game.postPlayerCommand(response.instance, "inc"); | ||
expect(response.output.wasSuccessful).toBe(true); | ||
expect(lines(response)).toEqual([ | ||
"Game state incremented from 0 to 1." | ||
]); | ||
|
||
for (let i = 0; i < 5; i++) { | ||
response = Game.postPlayerCommand(response.instance, "dec"); | ||
} | ||
expect(response.output.wasSuccessful).toBe(true); | ||
expect(lines(response)).toEqual([ | ||
"Game state decremented from -3 to -4." | ||
]); | ||
|
||
response = Game.postPlayerCommand(response.instance, "woof"); | ||
expect(response.output.wasSuccessful).toBe(true); | ||
expect(lines(response)).toEqual(["Command not recognized: 'woof'."]); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "js-basic", | ||
"author": "author", | ||
"regal": { | ||
"bundler": { | ||
"input": { | ||
"ts": false | ||
} | ||
} | ||
}, | ||
"dependencies": { | ||
"regal": "^0.7.1" | ||
} | ||
} |
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,29 @@ | ||
const regal = require("regal"); | ||
|
||
const init = regal.on("INIT", game => { | ||
game.output.write("Game initialized to zero."); | ||
game.state.num = 0; | ||
}); | ||
|
||
const incr = regal.on("INCR", game => | ||
game.output.write( | ||
`Game state incremented from ${game.state.num} to ${++game.state.num}.` | ||
) | ||
); | ||
|
||
const decr = regal.on("DECR", game => | ||
game.output.write( | ||
`Game state decremented from ${game.state.num} to ${--game.state.num}.` | ||
) | ||
); | ||
|
||
regal.onStartCommand(init); | ||
regal.onPlayerCommand(cmd => game => { | ||
if (cmd.startsWith("i")) { | ||
return incr; | ||
} else if (cmd.startsWith("d")) { | ||
return decr; | ||
} | ||
game.output.write(`Command not recognized: '${cmd}'.`); | ||
return regal.noop; | ||
}); |
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 @@ | ||
jest.setTimeout(10000); |
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