-
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.
refactor: Change UMD global name; add test cases
- Loading branch information
Showing
7 changed files
with
73 additions
and
36 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,40 +1,10 @@ | ||
import * as path from "path"; | ||
import * as fs from "fs"; | ||
import { GameApi } from "regal"; | ||
import { lines } from "../../test-utils"; | ||
import { bundleHeader } from "../../../src/bundle"; | ||
|
||
// @ts-ignore: import will be resolved | ||
import { bundle } from "../../../dist/regal-bundler.cjs.js"; | ||
|
||
describe("Case: ESM", () => { | ||
beforeAll( | ||
async () => | ||
await bundle({ | ||
configLocation: __dirname | ||
}) | ||
); | ||
|
||
it("TODO", async () => { | ||
// @ts-ignore: import will be resolved | ||
// const Game: GameApi = await import("./the-smallest-game.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'."]); | ||
it("Bundles successfully", async () => { | ||
await bundle({ | ||
configLocation: __dirname | ||
}); | ||
}); | ||
}); |
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 @@ | ||
{} |
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 @@ | ||
{ | ||
"game": { | ||
"name": "My UMD Game", | ||
"author": "Joe Cowman" | ||
}, | ||
"bundler": { | ||
"input": { | ||
"file": "../basic/src/index.ts" | ||
}, | ||
"output": { | ||
"format": "umd" | ||
} | ||
} | ||
} |
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,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title>UMD Test</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<script src="my-umd-game.regal.js"></script> | ||
</head> | ||
<body> | ||
|
||
</body> | ||
</html> |
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,39 @@ | ||
// @ts-ignore: import will be resolved | ||
import { bundle } from "../../../dist/regal-bundler.cjs.js"; | ||
import { lines } from "../../test-utils"; | ||
import { GameApi } from "regal"; | ||
|
||
describe("Case: UMD", () => { | ||
beforeAll(async () => { | ||
await bundle({ | ||
configLocation: __dirname | ||
}); | ||
}); | ||
|
||
it("Creates a functional bundle", async () => { | ||
// @ts-ignore: import will be resolved | ||
const Game: GameApi = await import("./my-umd-game.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'."]); | ||
}); | ||
}); |
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