Files
test-repo/tests_integration/__tests__/load-toml.js
T
Jorge Gonzalez 7d78ce68ef feat(config): support TOML configuration files (#4877)
* Add initial support for TOML in configuration files

* Missed brace

* Fix snapshots

* refactor: move loadToml to utils

* Use @iarna/toml

* Add tests for loadToml

* Fix test for CI

* Remove jest-extended

* Create snapshot for load-toml

* Add feat to docs

* lint docs

* Use @iarna/toml/parse-string

* Change path string
2018-08-03 06:27:19 -04:00

38 lines
838 B
JavaScript

"use strict";
const loadToml = require("../../src/utils/load-toml");
describe("TOML", () => {
const exampleFilePath = "example.toml";
const exampleToml = `
# This is a TOML document.
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00 # First class dates
[database]
server = "192.168.1.1"
ports = [ 8001, 8001, 8002 ]
connection_max = 5000
enabled = true
`;
const wrongToml = "///ERROR///";
test("loads toml successfully", () => {
const parsedToml = loadToml(exampleFilePath, exampleToml);
expect(parsedToml).toMatchSnapshot();
});
test("throws error on incorrect toml", () => {
expect(() => {
loadToml(exampleFilePath, wrongToml);
}).toThrow();
expect(() => {
loadToml(exampleFilePath, wrongToml);
}).toThrowErrorMatchingSnapshot();
});
});