Skip to content

Commit

Permalink
Added and corrected test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Jul 15, 2021
1 parent 61c8fd7 commit 8cd146f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ expectType<{
defaultOne: string,
defaultTwo: number,
version: string,
}>(BaseLevelTwo.defaultOptions);
}>({ ...BaseLevelTwo.defaultOptions });

// Because 'version' is already provided, this needs no argument
new BaseLevelTwo();
Expand Down Expand Up @@ -88,7 +88,7 @@ expectType<{
defaultTwo: number,
defaultThree: string[],
version: string,
}>(BaseLevelThree.defaultOptions);
}>({ ...BaseLevelThree.defaultOptions });

// Because 'version' is already provided, this needs no argument
new BaseLevelThree();
Expand Down
10 changes: 10 additions & 0 deletions test/base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,20 @@ test(".defaults({foo: 'bar'})", () => {
const BaseWithDefaults = Base.defaults({ foo: "bar" });
const defaultsTest = new BaseWithDefaults();
const mergedOptionsTest = new BaseWithDefaults({ baz: "daz" });
assert.equal(BaseWithDefaults.defaultOptions, { foo: "bar" });
assert.equal(defaultsTest.options, { foo: "bar" });
assert.equal(mergedOptionsTest.options, { foo: "bar", baz: "daz" });
});

test(".defaults({foo: 'bar', baz: 'daz' })", () => {
const BaseWithDefaults = Base.defaults({ foo: "bar" }).defaults({ baz: "daz" });
const defaultsTest = new BaseWithDefaults();
const mergedOptionsTest = new BaseWithDefaults({ faz: "boo" });
assert.equal(BaseWithDefaults.defaultOptions, { foo: "bar", baz: "daz" });
assert.equal(defaultsTest.options, { foo: "bar", baz: "daz" });
assert.equal(mergedOptionsTest.options, { foo: "bar", baz: "daz", faz: "boo" });
});

test(".plugin().defaults()", () => {
const BaseWithPluginAndDefaults = Base.plugin(fooPlugin).defaults({
baz: "daz",
Expand Down

0 comments on commit 8cd146f

Please sign in to comment.