Skip to content

Instantly share code, notes, and snippets.

View sonicoder86's full-sized avatar

Gábor Soós sonicoder86

View GitHub Profile
@sonicoder86
sonicoder86 / store.spec.js
Created July 22, 2020 16:06
Svelte Testing Crash Course - part 9
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');
});
@sonicoder86
sonicoder86 / store.js
Created July 22, 2020 16:05
Svelte Testing Crash Course - part 8
import { writable } from 'svelte/store';
export const createStore = () => {
const state = writable('Click to modify');
return {
state,
onModify(value) {
state.update(() => value);
}
@sonicoder86
sonicoder86 / Footer.spec.js
Created July 22, 2020 16:04
Svelte Testing Crash Course - part 7
@sonicoder86
sonicoder86 / Footer.svelte
Created July 22, 2020 16:03
Svelte Testing Crash Course - part 6
@sonicoder86
sonicoder86 / Footer.spec.js
Created July 22, 2020 16:03
Svelte Testing Crash Course - part 5
@sonicoder86
sonicoder86 / Footer.spec.js
Created July 22, 2020 16:02
Svelte Testing Crash Course - part 4
@sonicoder86
sonicoder86 / Footer.svelte
Created July 22, 2020 16:01
Svelte Testing Crash Course - part 3
@sonicoder86
sonicoder86 / unit.spec.js
Created July 22, 2020 16:00
Svelte Testing Crash Course - part 2
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');
@sonicoder86
sonicoder86 / jest.config.js
Created July 22, 2020 15:59
Svelte Testing Crash Course - part 1
module.exports = {
transform: {
'^.+\\.js$': 'babel-jest',
'^.+\\.svelte$': 'svelte-jester'
}
};
@sonicoder86
sonicoder86 / store.js
Created July 14, 2020 08:00
You Might Not Need Vuex - part 6
import { reactive, readonly } from 'vue';
export const createStore = () => {
const state = reactive({ counter: 0 });
const increment = () => state.counter++;
return { increment, state: readonly(state) };
}