mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-02-23 14:39:32 +08:00
fix(build): Add writeBuildArtifact test.
This commit is contained in:
parent
f6f35a9134
commit
350f25faf8
41
packages/build/src/utils/files/writeBuildArtifact.test.js
Normal file
41
packages/build/src/utils/files/writeBuildArtifact.test.js
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import createWriteBuildArtifact from './writeBuildArtifact';
|
||||
|
||||
const outputDirectory = path.resolve(process.cwd(), 'src/test/fileSetter');
|
||||
|
||||
test('writeFile', async () => {
|
||||
const filePath = path.resolve(outputDirectory, 'writeFile.txt');
|
||||
try {
|
||||
fs.unlinkSync(filePath);
|
||||
} catch (error) {
|
||||
//pass
|
||||
}
|
||||
expect(fs.existsSync(filePath)).toBe(false);
|
||||
const writeBuildArtifact = createWriteBuildArtifact({ outputDirectory });
|
||||
|
||||
await writeBuildArtifact({
|
||||
filePath: 'writeFile.txt',
|
||||
content: 'Test fileSetter file',
|
||||
});
|
||||
const res = fs.readFileSync(filePath, 'utf8');
|
||||
expect(res).toEqual('Test fileSetter file');
|
||||
try {
|
||||
fs.unlinkSync(filePath);
|
||||
} catch (error) {
|
||||
//pass
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user