Skip to content

Instantly share code, notes, and snippets.

View gs00s's full-sized avatar

Gábor Soós gs00s

  • Budapest
View GitHub Profile
@gs00s
gs00s / 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');
});
@gs00s
gs00s / 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);
}
@gs00s
gs00s / Footer.spec.js
Created July 22, 2020 16:04
Svelte Testing Crash Course - part 7
@gs00s
gs00s / Footer.svelte
Created July 22, 2020 16:03
Svelte Testing Crash Course - part 6
@gs00s
gs00s / Footer.spec.js
Created July 22, 2020 16:03
Svelte Testing Crash Course - part 5
@gs00s
gs00s / Footer.spec.js
Created July 22, 2020 16:02
Svelte Testing Crash Course - part 4
@gs00s
gs00s / Footer.svelte
Created July 22, 2020 16:01
Svelte Testing Crash Course - part 3
@gs00s
gs00s / 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');
@gs00s
gs00s / jest.config.js
Created July 22, 2020 15:59
Svelte Testing Crash Course - part 1
module.exports = {
transform: {
'^.+\\.js$': 'babel-jest',
'^.+\\.svelte$': 'svelte-jester'
}
};
@gs00s
gs00s / 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) };
}