项目作者: glippi

项目描述 :
:de: :clock1: Berlin Clock kata
高级语言: JavaScript
项目地址: git://github.com/glippi/berlin-clock.git
创建时间: 2019-06-27T08:39:00Z
项目社区:https://github.com/glippi/berlin-clock

开源协议:

下载


CircleCI


Berlin Clock


berlin-clock

> implementation of the berlin clock kata

Simple implementation of the berlin clock kata. It’s made of
two main parts: the clock engine and the UI. Everything is completely
driven by tests, with Jest and @testing-library/react.

Clock engine

The file clockEngine.js contains the code responsible for translating the Date
into the format expected by the Berlin Clock. This was a good case for
leveraging parameterized tests (see clockEngine.test.js).

The function startClock is responsible for starting the timer, and expects a
Date. For this reason, in the tests startClock.test.js we used mocked date in
order to have full control of the expected output of the function unders test.

UI

The UI is built using React. The components are tested with
@testing-library/react, using data-testid attributes on the elements. For
testing some more complicated scenarios, like when we have to determine which
divs should be enlighted or not, we use snapshots checking that the output is
what we expected.

CI/CD

The project is built with circleci, where we have two jobs, one for running
the tests and the other for deploy the application, only if the tests are
passing.

GitHub Pages

Leveraging the capability of circleci to run scripts, if all the jobs goes
well, we then launch the deploy.sh script, responsible for the creation of the
branch gh-pages and we shipped an optimized build of the app on github pages.

The Kata

For more info about the kata, like rules etc., please check:

Local Development

As the app was created with create-react-app, you have all the scripts that
are shipped by default with cra, so:

  • install packages: yarn install
  • run tests: yarn test
  • run local server: yarn start
  • build for production: yarn build