Skip to content

Instantly share code, notes, and snippets.

@jamesblashill
Created April 24, 2020 15:00
Show Gist options
  • Save jamesblashill/219d518de4f2a6c69801969a7f6945fe to your computer and use it in GitHub Desktop.
Save jamesblashill/219d518de4f2a6c69801969a7f6945fe to your computer and use it in GitHub Desktop.
describe('ViewState', () => {
test('default state', () => {
const viewState = new ViewState();
expect(viewState.showSomething).toBe(false);
});
test('toggleShowingSomething()', () => {
const viewState = new ViewState();
viewState.toggleShowingSomething();
expect(viewState.showSomething).toBe(true);
viewState.toggleShowingSomething();
expect(viewState.showSomething).toBe(false);
});
});
class ViewState {
@observable
showSomething: boolean = false;
toggleShowingSomething() {
this.showSomething = !this.showSomething;
}
}
@jamesblashill
Copy link
Author

@psalv, I agree tests aren't adding value here. But they're also super simple to write and pave the way for future good behaviours. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment