1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
Description: switch upstream test from ava to tape
Author: Xavier Guimard <yadd@debian.org>
Forwarded: not-needed
Last-Update: 2022-10-12
--- a/packages/json/test/test.js
+++ b/packages/json/test/test.js
@@ -1,13 +1,13 @@
const { readFileSync } = require('fs');
-const test = require('ava');
+const test = require('tape');
const { rollup } = require('rollup');
const { nodeResolve } = require('@rollup/plugin-node-resolve');
const { testBundle } = require('../../../util/test');
-const json = require('..'); // eslint-disable-line import/no-unresolved
+const json = require('@rollup/plugin-json'); // eslint-disable-line import/no-unresolved
const read = (file) => readFileSync(file, 'utf-8');
@@ -52,6 +52,7 @@
t.is(result.version, '1.33.7');
t.is(code.indexOf('this-should-be-excluded'), -1, 'should exclude unused properties');
+ t.end();
});
test('resolves extensionless imports in conjunction with the node-resolve plugin', async (t) => {
@@ -87,52 +88,21 @@
t.is(plugin, 'json');
t.is(position, 1);
t.is(message, 'Could not parse JSON file');
- t.regex(id, /(.*)bad.json$/);
+ t.ok(id.match(/(.*)bad.json$/));
+ t.end();
});
test('does not generate an AST', async (t) => {
// eslint-disable-next-line no-undefined
t.is(json().transform(read('fixtures/form/input.json'), 'input.json').ast, undefined);
+ t.end();
});
test('does not generate source maps', async (t) => {
t.deepEqual(json().transform(read('fixtures/form/input.json'), 'input.json').map, {
mappings: ''
});
-});
-
-test('generates properly formatted code', async (t) => {
- const { code } = json().transform(read('fixtures/form/input.json'), 'input.json');
- t.snapshot(code);
-});
-
-test('generates correct code with preferConst', async (t) => {
- const { code } = json({ preferConst: true }).transform(
- read('fixtures/form/input.json'),
- 'input.json'
- );
- t.snapshot(code);
-});
-
-test('uses custom indent string', async (t) => {
- const { code } = json({ indent: ' ' }).transform(read('fixtures/form/input.json'), 'input.json');
- t.snapshot(code);
-});
-
-test('generates correct code with compact=true', async (t) => {
- const { code } = json({ compact: true }).transform(
- read('fixtures/form/input.json'),
- 'input.json'
- );
- t.snapshot(code);
-});
-
-test('generates correct code with namedExports=false', async (t) => {
- const { code } = json({ namedExports: false }).transform(
- read('fixtures/form/input.json'),
- 'input.json'
- );
- t.snapshot(code);
+ t.end();
});
test('correctly formats arrays with compact=true', async (t) => {
@@ -148,6 +118,7 @@
).code,
'export default[1,{x:1}];'
);
+ t.end();
});
test('handles empty keys', async (t) => {
@@ -155,4 +126,5 @@
json().transform(`{"":"a", "b": "c"}`, 'input.json').code,
'export var b = "c";\nexport default {\n\t"": "a",\n\tb: b\n};\n'
);
+ t.end();
});
|