-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
197 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use strict"; | ||
|
||
const OptionHelper = require("../OptionHelper"); | ||
|
||
class TestOptionHelper extends OptionHelper { | ||
getDefaultOptions() { | ||
return {}; | ||
} | ||
} | ||
|
||
module.exports = TestOptionHelper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import OptionHelper from "../__mocks__/TestOptionHelper"; | ||
|
||
describe("OptionHelper", () => { | ||
test("supports functions as options", () => { | ||
const options = () => ({ mode: "production" }); | ||
const helper = new OptionHelper({ | ||
config: { | ||
getRaw() { | ||
return options; | ||
}, | ||
get() { | ||
return options; | ||
}, | ||
process(value) { | ||
return value; | ||
}, | ||
}, | ||
}); | ||
|
||
helper.preloadOptions(() => { | ||
expect(helper.getOptions()).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
test("supports Promise as options", () => { | ||
const options = Promise.resolve({ | ||
mode: "production", | ||
}); | ||
const helper = new OptionHelper({ | ||
config: { | ||
getRaw() { | ||
return options; | ||
}, | ||
get() { | ||
return options; | ||
}, | ||
process(value) { | ||
return value; | ||
}, | ||
}, | ||
}); | ||
|
||
helper.preloadOptions(() => { | ||
expect(helper.getOptions()).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/options/__tests__/__snapshots__/OptionHelper.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`OptionHelper supports Promise as options 1`] = ` | ||
Object { | ||
"mode": "production", | ||
} | ||
`; | ||
|
||
exports[`OptionHelper supports functions as options 1`] = ` | ||
Object { | ||
"mode": "production", | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters