非常に単純なクラスといくつかの単体テストを作成しました。カバレッジ レポートは 100% である必要がありますが、ブランチでは 75% と表示されます。
100% に到達する方法と、何が欠けているかを理解するためにどこを見ればよいかわかりません。
アップデート
単体テスト:
/* global describe jest it expect */
import GenericDice from '../generic-dice-vanilla';
jest.unmock('../generic-dice-vanilla');
describe('GenericDice', () => {
it('exists.', () => {
expect(GenericDice).toBeDefined();
});
it('has a default face property set to 1', () => {
const dice = new GenericDice();
expect(dice.face).toBe(1);
});
it('has a default rolling property set to true', () => {
const dice = new GenericDice();
expect(dice.rolling).toBe(true);
});
it('has a default animation property set to an empty string', () => {
const dice = new GenericDice();
expect(dice.animation).toBe('');
});
it('outputs something when the render function is called', () => {
const dice = new GenericDice();
const result = dice.render();
expect(result).toBeDefined();
});
});
Babel.js を使用して、このコードを ES6 から ES5 にトランスパイルしています。
単体テストを実行するには、次のコマンドを使用します。
冗談 ./src/ -u
すべてのコードは Github にあります: https://github.com/gyroscopico/generic-dice/tree/feature/35-vanilla