mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
773eefc059
* Initial try at creating GitHub actions * Fix Git checkout * Just Mac for now * Add Windows back * Try change run for WIndows * Configure msvs * Try again * Try again * Try downgrading windows * Change msvs version * Separate Windows steps * Try adding Ubuntu * Linux packages * SUdo? * Try something else * Make test more robust
35 lines
972 B
JavaScript
35 lines
972 B
JavaScript
const path = require('path');
|
|
const tag = require('..').templateTags[0];
|
|
|
|
function assertTemplate(args, expected) {
|
|
return async function() {
|
|
const result = await tag.run(null, ...args);
|
|
expect(result).toBe(expected);
|
|
};
|
|
}
|
|
|
|
function assertTemplateFails(args, expected) {
|
|
return async function() {
|
|
try {
|
|
await tag.run(null, ...args);
|
|
fail(`Render should have thrown ${expected}`);
|
|
} catch (err) {
|
|
expect(err.message).toContain(expected);
|
|
}
|
|
};
|
|
}
|
|
|
|
describe('FileExtension', () => {
|
|
const filename = path.resolve(__dirname, path.join('./test.txt'));
|
|
const escaped = filename.replace(/\\/g, '\\\\');
|
|
it('reads from string', assertTemplate([escaped], 'Hello World!'));
|
|
it(
|
|
'fails on missing file',
|
|
assertTemplateFails(
|
|
[path.resolve('/foo')],
|
|
`ENOENT: no such file or directory, open '${path.resolve('/foo')}'`,
|
|
),
|
|
);
|
|
it('fails on no 2nd param', assertTemplateFails([], 'No file selected'));
|
|
});
|