This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('should modify state', () => { | |
| const { store, onModify } = createStore(); | |
| let info; | |
| store.subscribe(value => info = value); | |
| onModify('Modified by click'); | |
| expect(info).toEqual('Modified by click'); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { writable } from 'svelte/store'; | |
| export const createStore = () => { | |
| const state = writable('Click to modify'); | |
| return { | |
| state, | |
| onModify(value) { | |
| state.update(() => value); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('toUpperCase', () => { | |
| it('should convert string to upper case', () => { | |
| // Arrange | |
| const toUpperCase = info => info.toUpperCase(); | |
| // Act | |
| const result = toUpperCase('Click to modify'); | |
| // Assert | |
| expect(result).toEqual('CLICK TO MODIFY'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| transform: { | |
| '^.+\\.js$': 'babel-jest', | |
| '^.+\\.svelte$': 'svelte-jester' | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { reactive, readonly } from 'vue'; | |
| export const createStore = () => { | |
| const state = reactive({ counter: 0 }); | |
| const increment = () => state.counter++; | |
| return { increment, state: readonly(state) }; | |
| } |