Update some of the exercises

This commit is contained in:
Steve Kinney
2024-09-16 13:13:38 -06:00
parent a028678660
commit 1747f705a6
15 changed files with 1617 additions and 597 deletions

View File

@@ -0,0 +1,9 @@
import { describe, it, expect } from 'vitest';
describe.todo('add', () => {});
describe.todo('subtract', () => {});
describe.todo('multiply', () => {});
describe.todo('divide', () => {});

View File

@@ -1 +0,0 @@
import { describe, it, expect } from 'vitest';

View File

@@ -0,0 +1,16 @@
let value = 0;
export const counter = {
get value() {
return value;
},
increment() {
value++;
},
decrement() {
value--;
},
reset() {
value = 0;
},
};

View File

@@ -0,0 +1,21 @@
import { expect, it, describe } from 'vitest';
import { counter } from './counter';
// For added fun, we can try `describe.shuffle`.
describe.todo('Counter', () => {
it('starts at zero', () => {
expect(counter.value).toBe(0);
});
it('can increment', () => {
counter.increment();
expect(counter.value).toBe(1);
});
// Let's get this test to *not* fail.
it('can decrement', () => {
counter.increment();
counter.decrement();
expect(counter.value).toBe(0);
});
});