smartnpm/test/test.ts

47 lines
1.5 KiB
TypeScript
Raw Normal View History

2018-09-01 14:40:42 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartnpm from '../ts/index';
2019-09-06 09:12:23 +00:00
import { NpmRegistry } from '../ts/index';
2017-08-14 15:50:48 +00:00
2019-09-06 09:12:23 +00:00
let npmRegistry: smartnpm.NpmRegistry;
let verdaccioRegistry: smartnpm.NpmRegistry;
2018-09-01 14:40:42 +00:00
let testPackage: smartnpm.NpmPackage;
2017-08-15 15:03:21 +00:00
2019-09-06 09:12:23 +00:00
// lets test things with the standard npm registry
2017-08-15 15:03:21 +00:00
tap.test('should create valid instances', async () => {
2019-09-06 09:12:23 +00:00
npmRegistry = new smartnpm.NpmRegistry();
expect(npmRegistry).to.be.instanceof(smartnpm.NpmRegistry);
2017-08-15 15:03:21 +00:00
2020-03-17 00:38:58 +00:00
testPackage = new smartnpm.NpmPackage(npmRegistry);
2018-09-01 14:40:42 +00:00
expect(testPackage).to.be.instanceof(smartnpm.NpmPackage);
});
2017-08-15 15:03:21 +00:00
2018-02-14 22:51:08 +00:00
tap.test('should produce a valid search string and this return npmts', async () => {
2020-03-17 00:38:58 +00:00
const packages = await npmRegistry.searchOnNpm({
2020-10-02 13:28:39 +00:00
name: '@pushrocks/smartupdate',
2018-09-01 14:40:42 +00:00
});
2019-09-06 11:22:54 +00:00
expect(packages[0].name).to.equal('@pushrocks/smartupdate');
2018-09-01 14:40:42 +00:00
});
2017-08-14 15:50:48 +00:00
2019-09-06 09:12:23 +00:00
// lets test things with the verdaccio registry
tap.test('should create a verdaccio registry', async () => {
verdaccioRegistry = new NpmRegistry({
2020-10-02 13:28:39 +00:00
npmRegistryUrl: 'https://verdaccio.lossless.one',
2019-09-06 09:12:23 +00:00
});
expect(verdaccioRegistry).to.be.instanceOf(smartnpm.NpmRegistry);
});
2020-03-17 00:38:58 +00:00
tap.test('should get package from verdaccio', async () => {
2019-09-06 11:22:54 +00:00
const npmPackage = await verdaccioRegistry.getPackageInfo('@pushrocks/smartupdate');
2020-03-17 00:38:58 +00:00
console.log(npmPackage);
2019-09-06 11:22:54 +00:00
expect(npmPackage.license).to.equal('MIT');
2019-09-06 09:12:23 +00:00
});
2020-03-17 00:38:58 +00:00
tap.test('should get a specific file from a package', async () => {
const bundleFile = await verdaccioRegistry.getFileFromPackage(
'@pushrocks/websetup',
'dist_bundle/bundle.js'
);
});
2018-09-01 14:40:42 +00:00
tap.start();