StarRailCopilot/webapp/packages/preload/tests/modifyYaml.test.ts
2023-09-10 00:22:01 +08:00

16 lines
716 B
TypeScript

import {test, expect} from 'vitest';
import {modifyYaml} from '../../common/utils/modifyYaml';
import getAlasABSPath from '../../common/utils/getAlasABSPath';
const path = require('path');
const fs = require('fs');
test('test write yaml', () => {
const absPath = getAlasABSPath();
const yamlPath = path.join(absPath, './config/deploy.yaml');
modifyYaml(yamlPath, {Branch: 'dev'});
const newYamlConfig1 = require('yaml').parse(fs.readFileSync(yamlPath, 'utf8'));
expect(newYamlConfig1.Deploy.Git.Branch).toBe('dev');
modifyYaml(yamlPath, {Branch: 'master'});
const newYamlConfig2 = require('yaml').parse(fs.readFileSync(yamlPath, 'utf8'));
expect(newYamlConfig2.Deploy.Git.Branch).toBe('master');
});