mirror of
https://github.com/directus/directus.git
synced 2026-02-12 12:34:57 -05:00
@@ -10,6 +10,7 @@ vi.mock('../env');
|
||||
|
||||
let mockStorage: StorageManager;
|
||||
let mockDriver: typeof Driver;
|
||||
|
||||
let sample: {
|
||||
name: string;
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@ let sample: {
|
||||
};
|
||||
locations: string[];
|
||||
};
|
||||
|
||||
let mockStorage: StorageManager;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -42,9 +43,11 @@ beforeEach(() => {
|
||||
} as unknown as StorageManager;
|
||||
|
||||
vi.mocked(getConfigFromEnv).mockImplementation((name) => sample.options[name]!);
|
||||
|
||||
vi.mocked(getEnv).mockReturnValue({
|
||||
STORAGE_LOCATIONS: sample.locations.join(', '),
|
||||
});
|
||||
|
||||
vi.mocked(toArray).mockReturnValue(sample.locations);
|
||||
});
|
||||
|
||||
@@ -61,6 +64,7 @@ test('Gets config for each location', async () => {
|
||||
await registerLocations(mockStorage);
|
||||
|
||||
expect(getConfigFromEnv).toHaveBeenCalledTimes(sample.locations.length);
|
||||
|
||||
sample.locations.forEach((location) =>
|
||||
expect(getConfigFromEnv).toHaveBeenCalledWith(`STORAGE_${location.toUpperCase()}_`)
|
||||
);
|
||||
@@ -70,6 +74,7 @@ test('Registers location with driver options for each location', async () => {
|
||||
await registerLocations(mockStorage);
|
||||
|
||||
expect(mockStorage.registerLocation).toHaveBeenCalledTimes(sample.locations.length);
|
||||
|
||||
sample.locations.forEach((location) => {
|
||||
const { driver, ...options } = sample.options[`STORAGE_${location.toUpperCase()}_`]!;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user