2022-02-23 22:53:39 +01:00
|
|
|
/*
|
2021-06-18 13:05:06 +02:00
|
|
|
* @jest-environment jsdom
|
|
|
|
*/
|
|
|
|
import Atom from '../Atom'
|
|
|
|
import iterateOver from './iterateOver'
|
|
|
|
|
|
|
|
describe(`iterateOver()`, () => {
|
|
|
|
test('it should work', () => {
|
2022-12-01 18:54:14 +01:00
|
|
|
const a = new Atom(0)
|
|
|
|
let iter = iterateOver(a.pointer)
|
2021-06-18 13:05:06 +02:00
|
|
|
expect(iter.next().value).toEqual(0)
|
2022-12-01 18:54:14 +01:00
|
|
|
a.set(1)
|
|
|
|
a.set(2)
|
2021-06-18 13:05:06 +02:00
|
|
|
expect(iter.next()).toMatchObject({value: 2, done: false})
|
|
|
|
iter.return()
|
2022-12-01 18:54:14 +01:00
|
|
|
iter = iterateOver(a.pointer)
|
2021-06-18 13:05:06 +02:00
|
|
|
expect(iter.next().value).toEqual(2)
|
2022-12-01 18:54:14 +01:00
|
|
|
a.set(3)
|
2021-06-18 13:05:06 +02:00
|
|
|
expect(iter.next()).toMatchObject({done: false, value: 3})
|
|
|
|
iter.return()
|
|
|
|
})
|
|
|
|
})
|