cli: refactor transform tests to separate out printing
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -26,7 +26,7 @@ import { default as defaultA } from './a-default';
|
||||
// import { default as defaultB } from './b-default';
|
||||
import { default as defaultC } from './c-default';
|
||||
|
||||
async function resolveAll(obj) {
|
||||
async function resolveAll(obj): Promise<unknown> {
|
||||
const val = await obj;
|
||||
if (typeof val !== 'object' || val === null) {
|
||||
return val;
|
||||
@@ -44,7 +44,7 @@ async function resolveAll(obj) {
|
||||
);
|
||||
}
|
||||
|
||||
resolveAll({
|
||||
export const values = resolveAll({
|
||||
depCommonJs,
|
||||
// depModule,
|
||||
depDefault,
|
||||
@@ -67,4 +67,4 @@ resolveAll({
|
||||
defaultB: import('./b-default').then(m => m.default),
|
||||
defaultC: import('./c-default').then(m => m.default.default),
|
||||
},
|
||||
}).then(obj => console.log(JSON.stringify(obj, null, 2)));
|
||||
});
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2024 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { values } from './main';
|
||||
|
||||
values.then(obj => console.log(JSON.stringify(obj, null, 2)));
|
||||
@@ -26,7 +26,7 @@ import { default as defaultA } from './a-default';
|
||||
// import { default as defaultB } from './b-default';
|
||||
import { default as defaultC } from './c-default';
|
||||
|
||||
async function resolveAll(obj) {
|
||||
async function resolveAll(obj): Promise<unknown> {
|
||||
const val = await obj;
|
||||
if (typeof val !== 'object' || val === null) {
|
||||
return val;
|
||||
@@ -44,7 +44,7 @@ async function resolveAll(obj) {
|
||||
);
|
||||
}
|
||||
|
||||
resolveAll({
|
||||
export const values = resolveAll({
|
||||
depCommonJs,
|
||||
// depModule,
|
||||
depDefault,
|
||||
@@ -67,4 +67,4 @@ resolveAll({
|
||||
defaultB: import('./b-default').then(m => m.default),
|
||||
defaultC: import('./c-default').then(m => m.default.default),
|
||||
},
|
||||
}).then(obj => console.log(JSON.stringify(obj, null, 2)));
|
||||
});
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2024 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { values } from './main';
|
||||
|
||||
values.then(obj => console.log(JSON.stringify(obj, null, 2)));
|
||||
@@ -29,7 +29,7 @@ import cDefault from './c-default';
|
||||
const { default: defaultC } = cDefault;
|
||||
const { value: namedC } = cNamed;
|
||||
|
||||
async function resolveAll(obj) {
|
||||
async function resolveAll(obj): Promise<unknown> {
|
||||
const val = await obj;
|
||||
if (typeof val !== 'object' || val === null) {
|
||||
return val;
|
||||
@@ -47,7 +47,7 @@ async function resolveAll(obj) {
|
||||
);
|
||||
}
|
||||
|
||||
resolveAll({
|
||||
export const values = resolveAll({
|
||||
depCommonJs,
|
||||
depModule,
|
||||
depDefault,
|
||||
@@ -70,4 +70,4 @@ resolveAll({
|
||||
defaultB: import('./b-default').then(m => m.default),
|
||||
defaultC: import('./c-default').then(m => m.default.default),
|
||||
},
|
||||
}).then(obj => console.log(JSON.stringify(obj, null, 2)));
|
||||
});
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2024 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { values } from './main';
|
||||
|
||||
values.then(obj => console.log(JSON.stringify(obj, null, 2)));
|
||||
@@ -65,7 +65,7 @@ function loadFixture(fixture: string) {
|
||||
|
||||
describe('node runtime module transforms', () => {
|
||||
it('should load from commonjs format', async () => {
|
||||
expect(loadFixture('pkg-commonjs/main.ts')).toEqual({
|
||||
expect(loadFixture('pkg-commonjs/print.ts')).toEqual({
|
||||
depCommonJs: expectedExports.commonJs,
|
||||
depDefault: expectedExports.commonJs,
|
||||
dynCommonJs: expectedExports.commonJs,
|
||||
@@ -77,7 +77,7 @@ describe('node runtime module transforms', () => {
|
||||
});
|
||||
|
||||
it('should load from default format', async () => {
|
||||
expect(loadFixture('pkg-default/main.ts')).toEqual({
|
||||
expect(loadFixture('pkg-default/print.ts')).toEqual({
|
||||
depCommonJs: expectedExports.commonJs,
|
||||
depDefault: expectedExports.commonJs,
|
||||
dynCommonJs: expectedExports.commonJs,
|
||||
@@ -89,7 +89,7 @@ describe('node runtime module transforms', () => {
|
||||
});
|
||||
|
||||
it('should load from module format', async () => {
|
||||
expect(loadFixture('pkg-module/main.ts')).toEqual({
|
||||
expect(loadFixture('pkg-module/print.ts')).toEqual({
|
||||
depCommonJs: expectedExports.commonJs,
|
||||
depDefault: expectedExports.commonJs,
|
||||
depModule: expectedExports.module,
|
||||
|
||||
Reference in New Issue
Block a user