Skip to content

Commit

Permalink
refactor(test): use Counter() inside computation test
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Apr 15, 2019
1 parent 09cf8dd commit f67e627
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions test/Computation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {scheduler} from 'ts-scheduler'

import {IO} from '../'

import {Counter} from './internals/Counter'
import {IOCollector} from './internals/IOCollector'
import {RejectingIOSpec, ResolvingIOSpec} from './internals/IOSpecification'

Expand Down Expand Up @@ -78,15 +79,15 @@ describe('Computation', () => {
)
})
it('should not cancel a cancelled IO', () => {
let count = 1000
const io = IO.from(() => () => (count += 1))
const counter = Counter(1000)
const io = counter.inc
const {scheduler: S, fork} = IOCollector(io)
S.runTo(200)
const cancel = fork()
S.runTo(210)
cancel()
cancel()
cancel()
assert.strictEqual(count, 1001)
assert.strictEqual(counter.getCount(), 1001)
})
})
4 changes: 2 additions & 2 deletions test/internals/Counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import {IO} from '../../src/IO'

export const Counter = () => {
let count = 0
export const Counter = (n: number = 0) => {
let count = n

return {
getCount: () => count,
Expand Down

0 comments on commit f67e627

Please sign in to comment.