This is a repo for a test assessment, it will be deleted after assessment.
UI Demo - (if resource was not loading correctly, try reload in browser with webkit engine)
This is a very small NodeJS CLI application. The comments are in JSDoc style, can be used to generate documentation easily. CircleCI is used as a service for continuous integration during development. esm here is used for ECMAScript module loading.
How to
Requirements
- yarn
- git
yarn
is recommended(npm
should work too, but it is not used during development)
Run the app
git clone https://github.com/tim-hub/buses-9923
cd buses-9923
yarn
yarn start r [file path]
absolute or relative path are supported, commands must be separated by lines. for exampleyarn start r ./test/data/input/case1.bcmd
r
stands for read, to read commands from a file, a file path is required here.
- The output in console will be
0,1,NORTH
About Input/Output
Input
- Input, from a file which contains the commands, sample files are in
test/data/input/
, for example incase3.bcmd
, commands are
PLACE 1,2,EAST
MOVE
MOVE
LEFT
MOVE
REPORT
All commands must be separated by new line.
Currently there are 5 valid commands, MOVE
, LEFT
, RIGHT
, REPORT
and PLACE [x],[y],[direction]
, a proper PLACE
command requires 3 parameters,
x
andy
which both are between 0 to 4, x,y stands for the position of bus will be parked.direction
which isNORTH
orEAST
orSOUTH
orWEST
Output
- Output, standard output (to console by default), samples files are in
test/data/output/
If run the commands like the example above, the output will be
3,3,NORTH
Testing
Mocha and Chai are used as test framework ans assertion library.
yarn test
will test all testing.yarn test-cli
will test functionality of cli only.
All testing cases in
test/data/
will be used to test the app.
Sample Data
Sample data is included, which is stored at test/data/
folder. Fot the testing purpose, both input commands and expected output are stored in the folder (input
and output
). For example,
input/case1.bcmd
is the file which includes commands to runoutput/case1.bout
is the relative file which contains the expected result.