smartnpm/test/test.ts

39 lines
1.3 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
2018-09-01 14:40:42 +00:00
testPackage = new smartnpm.NpmPackage({});
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 () => {
2019-09-06 09:12:23 +00:00
const packages = await npmRegistry.search({
2017-08-15 15:03:21 +00:00
name: 'npmts'
2018-09-01 14:40:42 +00:00
});
expect(packages[0].name).to.equal('npmts');
});
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({
npmRegistryUrl: 'https://verdaccio.lossless.one'
});
expect(verdaccioRegistry).to.be.instanceOf(smartnpm.NpmRegistry);
});
tap.test('should get package from verdaccui', async () => {
const packageInfo = await verdaccioRegistry.getPackageInfo('@pushrocks/smartupdate');
expect(packageInfo.license).to.equal('MIT');
});
2018-09-01 14:40:42 +00:00
tap.start();