Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function toHandleFile (fileName) {
const loaders = getLoaders(this.actual);
const compatibleLoaders = loaders.filter(l => l.regexp.test(fileName));
expect.assert(
compatibleLoaders.length < 2,
'%s is handled by more than one loader: %s',
fileName,
compatibleLoaders.map(l => l.name).join(', ')
);
expect.assert(
compatibleLoaders.length === 1,
'%s is not handled by loaders',
fileName
)
}
() => {
expect.assert(
false,
'A blocked should not emit a new location'
)
}
]
toBeAFunction() {
expect.assert(
(typeof this.actual === 'function'),
'expected %s to be a function',
this.actual
);
}
});
toBeDefined() {
expect.assert(
this.actual !== undefined,
'expected %s to be defined',
this.actual
);
}
});
() => {
expect.assert(
false,
'A blocked should not emit a new location'
)
}
]
function toNotHavePlugin (pluginName) {
const plugins = getPlugins(this.actual);
const matchingPlugins = plugins.filter(p => p.name == pluginName);
expect.assert(
matchingPlugins.length === 0,
'Plugin %s wasn\'t expected in config',
pluginName
);
}
function toHavePlugin (pluginName, options) {
const plugins = getPlugins(this.actual);
const matchingPlugins = plugins.filter(p => p.name == pluginName);
expect.assert(
matchingPlugins.length > 0,
'No plugin matching %s in %s',
pluginName,
plugins.map(p => p.name)
);
if (options) {
var matchingOptions = matchingPlugins.filter(p => matches(p.options, options));
expect.assert(
matchingOptions.length > 0,
'No plugin named %s with options %s in %s',
pluginName,
options,
matchingPlugins.map(p => p.options)
);
}
}
function toNotHavePlugin (pluginName) {
export function toHaveAttribute(name, value, message) {
assert(
isDOMNode(this.actual),
'The "actual" argument in expect(actual).toHaveAttribute() must be a DOM node, %s was given',
this.actual
)
if (value == null) {
assert(
this.actual.getAttribute(name),
(message || 'Expected %s to have a %s attribute, but it did not'),
this.actual,
name
)
} else {
assert(
this.actual.getAttribute(name) === value,
(message || 'Expected %s to have a %s attribute of %s, but it was %s'),
this.actual,
name,
value,
this.actual.getAttribute(name)
)
}
}
export function toHaveText(text, message) {
assert(
isDOMNode(this.actual),
'The "actual" argument in expect(actual).toHaveText() must be a DOM node, %s was given',
this.actual
)
assert(
this.actual.textContent === text,
(message || 'Expected %s to have %s text, but had %s instead'),
this.actual,
text,
this.actual.textContent
)
}
export function toHaveAttribute(name, value, message) {
assert(
isDOMNode(this.actual),
'The "actual" argument in expect(actual).toHaveAttribute() must be a DOM node, %s was given',
this.actual
)
if (value == null) {
assert(
this.actual.getAttribute(name),
(message || 'Expected %s to have a %s attribute, but it did not'),
this.actual,
name
)
} else {
assert(
this.actual.getAttribute(name) === value,
(message || 'Expected %s to have a %s attribute of %s, but it was %s'),
this.actual,
name,
value,
this.actual.getAttribute(name)
)
}
}