@apistudio/apim-cli
Version:
CLI for API Management Products
120 lines (102 loc) • 3.25 kB
JavaScript
/**
* Copyright IBM Corp. 2024, 2025
*/
describe('APICFileInfo', () => {
it('should create an APICFileInfo object with required properties', () => {
const fileInfo = {
isModified: false,
path: '/path/to/file',
fileUrl: 'https://example.com/file',
orgId: 'org123',
};
expect(fileInfo.isModified).toBe(false);
expect(fileInfo.path).toBe('/path/to/file');
expect(fileInfo.fileUrl).toBe('https://example.com/file');
expect(fileInfo.orgId).toBe('org123');
});
it('should validate APICFileInfo properties', () => {
const fileInfo = {
isModified: true,
path: '/path/to/file',
fileUrl: 'https://example.com/file',
orgId: 'org123',
};
// Check that all required properties exist
expect(fileInfo).toHaveProperty('isModified');
expect(fileInfo).toHaveProperty('path');
expect(fileInfo).toHaveProperty('fileUrl');
expect(fileInfo).toHaveProperty('orgId');
// Check property types
expect(typeof fileInfo.isModified).toBe('boolean');
expect(typeof fileInfo.path).toBe('string');
expect(typeof fileInfo.fileUrl).toBe('string');
expect(typeof fileInfo.orgId).toBe('string');
});
it('should handle different boolean values for isModified', () => {
const fileInfo1 = {
isModified: true,
path: '/path/to/file',
fileUrl: 'https://example.com/file',
orgId: 'org123',
};
const fileInfo2 = {
isModified: false,
path: '/path/to/file',
fileUrl: 'https://example.com/file',
orgId: 'org123',
};
expect(fileInfo1.isModified).toBe(true);
expect(fileInfo2.isModified).toBe(false);
});
it('should handle different path values', () => {
const fileInfo1 = {
isModified: false,
path: '/path/to/file1',
fileUrl: 'https://example.com/file',
orgId: 'org123',
};
const fileInfo2 = {
isModified: false,
path: '/path/to/file2',
fileUrl: 'https://example.com/file',
orgId: 'org123',
};
expect(fileInfo1.path).toBe('/path/to/file1');
expect(fileInfo2.path).toBe('/path/to/file2');
expect(fileInfo1.path).not.toBe(fileInfo2.path);
});
it('should handle different fileUrl values', () => {
const fileInfo1 = {
isModified: false,
path: '/path/to/file',
fileUrl: 'https://example.com/file1',
orgId: 'org123',
};
const fileInfo2 = {
isModified: false,
path: '/path/to/file',
fileUrl: 'https://example.com/file2',
orgId: 'org123',
};
expect(fileInfo1.fileUrl).toBe('https://example.com/file1');
expect(fileInfo2.fileUrl).toBe('https://example.com/file2');
expect(fileInfo1.fileUrl).not.toBe(fileInfo2.fileUrl);
});
it('should handle different orgId values', () => {
const fileInfo1 = {
isModified: false,
path: '/path/to/file',
fileUrl: 'https://example.com/file',
orgId: 'org1',
};
const fileInfo2 = {
isModified: false,
path: '/path/to/file',
fileUrl: 'https://example.com/file',
orgId: 'org2',
};
expect(fileInfo1.orgId).toBe('org1');
expect(fileInfo2.orgId).toBe('org2');
expect(fileInfo1.orgId).not.toBe(fileInfo2.orgId);
});
});