Commit Graph

19 Commits

Author SHA1 Message Date
Guangcong Luo
e489b36856 Fix Confusion message grouping 2019-01-07 21:45:58 -06:00
Guangcong Luo
fd5f54c99c Autoconvert old protocol messages
Instead of needing to support old protocol messages, we now introduce
BattleTextParser.upgradeArgs, which automatically upgrades them to new
protocol messages.

Fixes #1199
2019-01-07 21:12:00 -06:00
Guangcong Luo
2471482fb4 Battle.lineParse -> BattleTextParser.parseLine
BattleTextParser.parseLine -> BattleTextParser.parseArgs

This makes it so Battle depends on BattleTextParser, rather than
BattleTextParser depending on Battle.

This is probably better, because someone is way more likely to want
BattleTextParser standalone, than to want Battle standalone.

...which I'm sure matters to literally no one but me, but whatever. I
think it makes more sense this way.
2019-01-05 05:41:05 -06:00
Guangcong Luo
d05fe62375 Use require instead of eval in ./test/parse
I still don't like how everything's a global in Node, but for now we
don't have a better solution.
2019-01-05 05:15:37 -06:00
Guangcong Luo
dcb3a6f769 Ugly hack to support tests in Node.js
Previously, we used the `eval` hack to "import" our code into test
files. The biggest problem with that approach is that we don't get
line numbers.

Now, we're assigning relevant variables to globals in Node.js for
tests. It's ugly, but it works. There's no simple way to import local
variables only if we're in Node.

Ideally, we'd build this in two different ways: A .mjs file for Node,
and a .js file for the browser. Or maybe use UMD. I'll figure it out
later, I guess.
2019-01-03 03:58:06 -06:00
Guangcong Luo
e186f57f41 Rename .mocha.js -> .test.js
This spec file is, incidentally, Jest-compatible. I benchmarked and
Jest is noticeably slower right now, so I'll stick with Mocha, but
if we ever need Jest features, it'll be useful to be able to easily
switch.
2019-01-03 03:42:13 -06:00
Guangcong Luo
38b66272f2 Fix issues identified by LGTM
Out of 12 issues found:

3 bugs:

- duplicate property - caught a bug in Gen 1 Light Screen
- duplicate property - caught a bug in Gen 1 Reflect
- unused variable - caught a bug in type animations

7 harmless but good for code quality:

- unused variable - harmless but good for code quality
- unused variable - harmless but good for code quality
- unused variable - harmless but good for code quality
- unused variable - harmless but good for code quality
- duplicate case - harmless but important for code quality
- unused variable - harmless but good for code quality
- unused variable - harmless but important for code quality

2 not-bugs that had to be worked around:

- unused variable - used for an `eval` trick, had to use a workaround
- unused variable - used for readable destructuring

I think on balance, LGTM does more good than bad. Catching bugs early
is worth some amount of hassle.

(Also like half these problems are problems tslint could catch if I
actually bothered to set it up...)
2018-11-15 18:52:53 -06:00
Guangcong Luo
80684f698c Drop BattleLog dependency from headless Battles
Mostly, this involves removing `BattleLog.escapeHTML` from `battle.ts`.
All previous use-cases have been replaced with something like
`Tools.sanitizeName`.

Technically, the dependency remains for `|controlshtml|` and
`|fieldhtml|`, but these will be dropped for BattleRoom/GameRoom
separation, to be done in the Preact rewrite.
2018-11-15 18:52:53 -06:00
Guangcong Luo
aa2eecb7cc Add script for testing the new battle parser
(Run `./test/parse` and pipe protocol messages to stdin.)
2018-11-15 18:52:53 -06:00
Guangcong Luo
5f05adc856 Split battle-log.ts off from battle-dex.ts
This splits battle-dex.ts up into:

- `battle-dex.ts`
  - dex data access, misc tools
- `battle-log.ts`
  - manipulating HTML, especially in battle logs

This turned out to be a pretty significant portion of what was
previously battle-dex.
2018-11-15 18:52:53 -06:00
Guangcong Luo
f86245febb Add mocha tests to npm test 2018-10-16 03:31:27 -05:00
Guangcong Luo
fb4f83a580 Remove testcafe dependency
It was unused and vulnerable.
2018-10-16 03:04:52 -05:00
Dan Huang
ee91a72dc6 Support headless client Battle (#1151) 2018-10-16 02:48:59 -05:00
Guangcong Luo
a0421462c8 Comment out VGC teambuilder test 2017-11-23 01:39:06 -06:00
Konrad Borowski
ccf4621c7d Use different Pokemon in tests to avoid failures
I would prefer if the test would still test if a mega gets an item,
which is why Charizard-Mega-Y was picked. It's unlikely to be banned,
but is powerful enough to stay in OU.

A safer choice would be an Arceus, but there is no code yet that
automatically gives a correct item to formes (may be worth fixing).
2017-08-07 22:53:54 +02:00
asgdf
8eb42e83b3 Allow export of the 'uncategorized' format folder (#976) 2017-08-02 20:29:18 -04:00
Konrad Borowski
f41ef9d245 Test if Trump Card has 5 PP (#965)
Test if Trump Card has 5 PP

This I believe was a regression that was fixed by 2fac7642f6.
2017-07-06 20:31:51 -05:00
Konrad Borowski
cfd87a91c1 Add level 50 Pokemon test for VGC (#964) 2017-07-06 15:34:20 +09:00
Konrad Borowski
156b5bf3d5 Add testclient unit tests (#957) 2017-06-27 17:43:54 -07:00