projectinfo/test/test.ts

33 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

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