-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add test for options parsing (#651)
* tests: add test for options parsing * fix: remove snapshot and test '4500000' * chore: update dev container * tests: improve setup block test * fix: wording * fix: lint * fix: tests
- Loading branch information
Showing
7 changed files
with
157 additions
and
23 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node | ||
{ | ||
"name": "Node.js & TypeScript", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye", | ||
"features": { | ||
"ghcr.io/devcontainers/features/rust:1": {}, | ||
"ghcr.io/lee-orr/rusty-dev-containers/wasm32-unknown-unknown:0": {}, | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "yarn install", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# Please see the documentation for more information: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
# https://containers.dev/guide/dependabot | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "npm" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "monthly" | ||
- package-ecosystem: "devcontainers" | ||
directory: "/" | ||
schedule: | ||
interval: weekly |
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,69 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { readdirSync } from 'fs' | ||
import _ from 'lodash' | ||
import path from 'path' | ||
|
||
import { configSchema, fetchConfig } from './index.js' | ||
|
||
function getAllFiles(dirPath: string) { | ||
const files = readdirSync(dirPath) | ||
const arrayOfFiles: string[] = [] | ||
files.forEach(function (file) { | ||
arrayOfFiles.push(path.join(dirPath, '/', file)) | ||
}) | ||
|
||
return arrayOfFiles | ||
} | ||
|
||
describe('Existing configs', async () => { | ||
const configPaths = getAllFiles(path.join(__dirname, '../../../../configs')) | ||
it.each(configPaths.map((p) => ({ name: _.last(p.split('/')), path: p })))( | ||
'$name config parsing is correct', | ||
async ({ path }) => { | ||
const config = await fetchConfig(path) | ||
expect(() => configSchema.parse(config)).not.toThrow() | ||
}, | ||
) | ||
}) | ||
|
||
describe('Parsed options', () => { | ||
const defaults = { | ||
port: 8000, | ||
'build-block-mode': 'Batch', | ||
} | ||
it('parsed multi type options should work', () => { | ||
expect( | ||
configSchema.parse({ | ||
block: 4500000, | ||
}), | ||
).toEqual({ | ||
block: 4500000, | ||
...defaults, | ||
}) | ||
|
||
expect( | ||
configSchema.parse({ | ||
block: '4500000', | ||
}), | ||
).toEqual({ | ||
block: '4500000', | ||
...defaults, | ||
}) | ||
|
||
expect( | ||
configSchema.parse({ | ||
block: '0xb10f03bbc183da4d26e27528d28f6a73ddaf182fb6400ca363b77d2411ea5b0c', | ||
}), | ||
).toEqual({ | ||
block: '0xb10f03bbc183da4d26e27528d28f6a73ddaf182fb6400ca363b77d2411ea5b0c', | ||
...defaults, | ||
}) | ||
|
||
expect(() => | ||
configSchema.parse({ | ||
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision | ||
block: 0xb10f03bbc183da4d26e27528d28f6a73ddaf182fb6400ca363b77d2411ea5b0c, | ||
}), | ||
).toThrowError(/you are uing a hex string/) | ||
}) | ||
}) |
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