reblend-testing-library
Version:
Simple and complete Reblendjs testing utilities that encourage good testing practices.
62 lines (61 loc) • 2.01 kB
JavaScript
;
var _ = require("../");
describe('configuration API', () => {
let originalConfig;
beforeEach(() => {
// Grab the existing configuration so we can restore
// it at the end of the test
(0, _.configure)(existingConfig => {
originalConfig = existingConfig;
// Don't change the existing config
return {};
});
});
afterEach(() => {
(0, _.configure)(originalConfig);
});
describe('DTL options', () => {
test('configure can set by a plain JS object', () => {
const testIdAttribute = 'not-data-testid';
(0, _.configure)({
testIdAttribute
});
expect((0, _.getConfig)().testIdAttribute).toBe(testIdAttribute);
});
test('configure can set by a function', () => {
// setup base option
const baseTestIdAttribute = 'data-testid';
(0, _.configure)({
testIdAttribute: baseTestIdAttribute
});
const modifiedPrefix = 'modified-';
(0, _.configure)(existingConfig => ({
testIdAttribute: `${modifiedPrefix}${existingConfig.testIdAttribute}`
}));
expect((0, _.getConfig)().testIdAttribute).toBe(`${modifiedPrefix}${baseTestIdAttribute}`);
});
});
describe('RTL options', () => {
test('configure can set by a plain JS object', () => {
(0, _.configure)({
reblendStrictMode: true
});
expect((0, _.getConfig)().reblendStrictMode).toBe(true);
});
test('configure can set by a function', () => {
(0, _.configure)(existingConfig => ({
reblendStrictMode: !existingConfig.reblendStrictMode
}));
expect((0, _.getConfig)().reblendStrictMode).toBe(true);
});
});
test('configure can set DTL and RTL options at once', () => {
const testIdAttribute = 'not-data-testid';
(0, _.configure)({
testIdAttribute,
reblendStrictMode: true
});
expect((0, _.getConfig)().testIdAttribute).toBe(testIdAttribute);
expect((0, _.getConfig)().reblendStrictMode).toBe(true);
});
});