StarRailCopilot/webapp/packages/preload/tests/modifyYaml.test.ts

16 lines
716 B
TypeScript
Raw Normal View History

2023-09-09 16:22:01 +00:00
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');
});