-
Notifications
You must be signed in to change notification settings - Fork 598
/
index-test.js
41 lines (33 loc) 路 1.12 KB
/
index-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
* @emails oncall+metro_bundler
*/
'use strict';
jest.mock('fs', () => new (require('metro-memory-fs'))());
const fs = require('fs');
const getCacheKey = require('../index');
beforeAll(() => {
fs.writeFileSync('/a.txt', 'fake content for a.txt');
fs.writeFileSync('/copy_of_a.txt', 'fake content for a.txt');
fs.writeFileSync('/b.txt', 'fake content for b.txt');
});
test('calculates a cache key for a list of files', () => {
expect(getCacheKey(['/a.txt'])).toMatchInlineSnapshot(
`"651e28171df9ff5d72a4115295dfce6b"`,
);
expect(getCacheKey(['/a.txt', '/b.txt'])).toMatchInlineSnapshot(
`"40457a98d325b546bed62a34c7d7cf96"`,
);
});
test('generates different keys for different files', () => {
expect(getCacheKey(['/a.txt'])).not.toEqual(getCacheKey(['/b.txt']));
});
test('generates identical keys for identical files', () => {
expect(getCacheKey(['/a.txt'])).toEqual(getCacheKey(['/copy_of_a.txt']));
});