mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-26 19:55:20 +00:00
* relocate .vscode
* Switch to transloadit linter
* Update .eslintrc.json
* autofix code
* unlink and install eslint-config-transloadit@1.1.1
* Change 0 to "off"
* Don't change 'use strict'
* Do not vertically align
* disable key-spacing
* add import/no-extraneous-dependencies per package
* add more react/a11y warnings
* Revert "autofix code"
This reverts commit 14c8a8cde8.
* add import/no-extraneous-dependencies per example and main package
* autofix code (2)
* Allow devDependencies in ./bin
* Change import/no-extraneous-dependencies to warn again
* upgrade linter
* Set import/no-extraneous-dependencies to warn
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
const DefaultStore = require('./index')
|
|
|
|
describe('DefaultStore', () => {
|
|
it('can be created with or without new', () => {
|
|
let store = DefaultStore()
|
|
expect(typeof store).toBe('object')
|
|
store = new DefaultStore()
|
|
expect(typeof store).toBe('object')
|
|
})
|
|
|
|
it('merges in state using `setState`', () => {
|
|
const store = DefaultStore()
|
|
expect(store.getState()).toEqual({})
|
|
|
|
store.setState({
|
|
a: 1,
|
|
b: 2,
|
|
})
|
|
expect(store.getState()).toEqual({ a: 1, b: 2 })
|
|
|
|
store.setState({ b: 3 })
|
|
expect(store.getState()).toEqual({ a: 1, b: 3 })
|
|
})
|
|
|
|
it('notifies subscriptions when state changes', () => {
|
|
let expected = []
|
|
let calls = 0
|
|
function listener (prevState, nextState, patch) {
|
|
calls++
|
|
expect([prevState, nextState, patch]).toEqual(expected)
|
|
}
|
|
|
|
const store = DefaultStore()
|
|
store.subscribe(listener)
|
|
|
|
expected = [{}, { a: 1, b: 2 }, { a: 1, b: 2 }]
|
|
store.setState({
|
|
a: 1,
|
|
b: 2,
|
|
})
|
|
|
|
expected = [{ a: 1, b: 2 }, { a: 1, b: 3 }, { b: 3 }]
|
|
store.setState({ b: 3 })
|
|
|
|
expect(calls).toBe(2)
|
|
})
|
|
})
|