Fix snapshot tests failing on windows (#1229)
Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/1229 Fix snapshot tests which are currently failing on Windows. Reviewed By: mweststrate Differential Revision: D21928445 fbshipit-source-id: 85ad79f5e01204fedecbef6828c978f76c0380f8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
db3f04a2d7
commit
9604e33f3a
@@ -31,6 +31,8 @@ test('getPluginDetailsV1', async () => {
|
|||||||
jest.mock('fs-extra', () => jest.fn());
|
jest.mock('fs-extra', () => jest.fn());
|
||||||
fs.readJson = jest.fn().mockImplementation(() => pluginV1);
|
fs.readJson = jest.fn().mockImplementation(() => pluginV1);
|
||||||
const details = await getPluginDetails(pluginPath);
|
const details = await getPluginDetails(pluginPath);
|
||||||
|
details.dir = normalizeOnWindows(details.dir);
|
||||||
|
details.entry = normalizeOnWindows(details.entry);
|
||||||
expect(details).toMatchInlineSnapshot(`
|
expect(details).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"bugs": undefined,
|
"bugs": undefined,
|
||||||
@@ -66,6 +68,8 @@ test('getPluginDetailsV2', async () => {
|
|||||||
jest.mock('fs-extra', () => jest.fn());
|
jest.mock('fs-extra', () => jest.fn());
|
||||||
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
||||||
const details = await getPluginDetails(pluginPath);
|
const details = await getPluginDetails(pluginPath);
|
||||||
|
details.dir = normalizeOnWindows(details.dir);
|
||||||
|
details.entry = normalizeOnWindows(details.entry);
|
||||||
expect(details).toMatchInlineSnapshot(`
|
expect(details).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"bugs": undefined,
|
"bugs": undefined,
|
||||||
@@ -101,6 +105,8 @@ test('id used as title if the latter omited', async () => {
|
|||||||
jest.mock('fs-extra', () => jest.fn());
|
jest.mock('fs-extra', () => jest.fn());
|
||||||
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
||||||
const details = await getPluginDetails(pluginPath);
|
const details = await getPluginDetails(pluginPath);
|
||||||
|
details.dir = normalizeOnWindows(details.dir);
|
||||||
|
details.entry = normalizeOnWindows(details.entry);
|
||||||
expect(details).toMatchInlineSnapshot(`
|
expect(details).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"bugs": undefined,
|
"bugs": undefined,
|
||||||
@@ -135,6 +141,8 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite
|
|||||||
jest.mock('fs-extra', () => jest.fn());
|
jest.mock('fs-extra', () => jest.fn());
|
||||||
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
||||||
const details = await getPluginDetails(pluginPath);
|
const details = await getPluginDetails(pluginPath);
|
||||||
|
details.dir = normalizeOnWindows(details.dir);
|
||||||
|
details.entry = normalizeOnWindows(details.entry);
|
||||||
expect(details).toMatchInlineSnapshot(`
|
expect(details).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"bugs": undefined,
|
"bugs": undefined,
|
||||||
@@ -155,3 +163,11 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite
|
|||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const normalizeOnWindows = (path: string): string => {
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
path = path.replace(/\\/g, '/');
|
||||||
|
path = path.substring(path.indexOf('/'));
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user