Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit ef22587

Browse files
author
Ruben Schmidmeister
committed
Move algorithm to separate folder
1 parent 367700d commit ef22587

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed

algorithms/fair-dice-roll.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// chosen by fair dice roll.
2+
// guaranteed to be random.
3+
const random = () => 4
4+
5+
module.exports = random

index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
// chosen by fair dice roll.
2-
// guaranteed to be random.
3-
module.exports = () => 4
1+
const fairDiceRoll = require('./algorithms/fair-dice-roll')
2+
module.exports = Object.assign(fairDiceRoll, { fairDiceRoll })

test/fair-dice-roll.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
const assert = require('assert')
4+
const { fairDiceRoll } = require('../index')
5+
6+
describe('fair dice roll', () => {
7+
it('always returns the same number', () => {
8+
assert.equal(fairDiceRoll(), fairDiceRoll())
9+
})
10+
})

test/legacy-export.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
const assert = require('assert')
4+
const random = require('../index')
5+
6+
describe('legacy default export', () => {
7+
it('should be the same as fair dice roll', () => {
8+
assert.equal(random.fairDiceRoll, random)
9+
})
10+
})

test/test.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)