Skip to content

Commit

Permalink
Implement Sequence.reset()
Browse files Browse the repository at this point in the history
  • Loading branch information
bartblast committed Oct 18, 2024
1 parent 54ff6e3 commit 469c34b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions assets/js/sequence.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
"use strict";

export default class Sequence {
// Made public to make tests easier
static value = 0;

static next() {
Sequence.value += 1;
return Sequence.value;
$.value += 1;
return $.value;
}

static reset() {
$.value = 0;
}
}

const $ = Sequence;
7 changes: 7 additions & 0 deletions test/javascript/sequence_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ describe("Sequence", () => {
assert.equal(Sequence.next(), 1);
assert.equal(Sequence.next(), 2);
});

it("reset()", () => {
Sequence.value = 123;
Sequence.reset();

assert.equal(Sequence.value, 0);
});
});

0 comments on commit 469c34b

Please sign in to comment.