Files
projectinfo/test/test.ts

38 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

import { tap, expect } from '@git.zone/tstest/tapbundle';
2023-08-08 18:06:23 +02:00
import * as smartpath from '@push.rocks/smartpath';
2022-04-18 22:16:46 +02:00
import * as projectinfo from '../ts/index.js';
2017-09-22 23:46:43 +02:00
2022-04-18 22:16:46 +02:00
import * as path from 'path';
let testBasePath = path.resolve(smartpath.get.dirnameFromImportMetaUrl(import.meta.url));
2016-02-20 05:05:07 +01:00
let myNpm: projectinfo.ProjectinfoNpm;
tap.test('should create ProjectinfoNpm instance', async () => {
myNpm = await projectinfo.ProjectinfoNpm.create(testBasePath, { gitAccessToken: 'sometoken' });
});
2017-09-22 23:46:43 +02:00
tap.test('should have .packageJson', async () => {
2022-04-18 22:16:46 +02:00
expect(myNpm.packageJson).property('version').toEqual('1.0.0');
expect(myNpm.packageJson).property('name').toEqual('testpackage');
2018-09-02 14:21:05 +02:00
});
2016-02-20 05:05:07 +01:00
2017-09-22 23:46:43 +02:00
tap.test('should have .version', async () => {
2022-04-18 22:16:46 +02:00
expect(myNpm).property('version').toEqual('1.0.0');
2018-09-02 14:21:05 +02:00
});
2016-02-21 17:17:31 +01:00
2017-09-22 23:46:43 +02:00
tap.test('should have .name', async () => {
2022-04-18 22:16:46 +02:00
expect(myNpm).property('name').toEqual('testpackage');
2018-09-02 14:21:05 +02:00
});
2016-02-20 06:06:43 +01:00
2017-09-22 23:46:43 +02:00
tap.test('should have .license', async () => {
2022-04-18 22:16:46 +02:00
expect(myNpm).property('license').toEqual('MIT');
2018-09-02 14:21:05 +02:00
});
2017-09-22 23:46:43 +02:00
tap.test('should have .git', async () => {
expect(myNpm.git!.httpsUrl).toEqual('https://sometoken@github.com/someuser/somerepo.git');
2018-09-02 14:21:05 +02:00
});
2017-09-22 23:46:43 +02:00
tap.test('should return a name', async () => {
expect(await projectinfo.getNpmNameForDir(testBasePath)).toEqual('testpackage');
2018-09-02 14:21:05 +02:00
});
2017-09-22 23:46:43 +02:00
export default tap.start();