2021-04-23 16:58:48 +00:00
|
|
|
import { getName, loadFixture } from '../../../test/util';
|
2020-02-05 00:14:31 +00:00
|
|
|
import { extractPackageFile } from '.';
|
2019-04-15 13:07:54 +00:00
|
|
|
|
2021-04-23 16:58:48 +00:00
|
|
|
const brokenYaml = loadFixture(__filename, 'update.yaml');
|
|
|
|
const packageFile = loadFixture(__filename, 'extract.yaml');
|
2019-04-15 13:07:54 +00:00
|
|
|
|
2021-04-13 10:07:57 +00:00
|
|
|
describe(getName(__filename), () => {
|
2019-04-15 13:07:54 +00:00
|
|
|
describe('extractPackageFile', () => {
|
|
|
|
it('should return null if package does not contain any deps', () => {
|
|
|
|
const res = extractPackageFile('foo: bar', 'pubspec.yaml');
|
2020-05-18 12:33:44 +00:00
|
|
|
expect(res).toBeNull();
|
2019-04-15 13:07:54 +00:00
|
|
|
});
|
|
|
|
it('should return null if package is invalid', () => {
|
|
|
|
const res = extractPackageFile(brokenYaml, 'pubspec.yaml');
|
2020-05-18 12:33:44 +00:00
|
|
|
expect(res).toBeNull();
|
2019-04-15 13:07:54 +00:00
|
|
|
});
|
|
|
|
it('should return valid dependencies', () => {
|
|
|
|
const res = extractPackageFile(packageFile, 'pubspec.yaml');
|
|
|
|
expect(res).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|