Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/emmet/src/test/reflectCssValue.test.ts
4774 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import 'mocha';
7
import * as assert from 'assert';
8
import { Selection } from 'vscode';
9
import { withRandomFileEditor, closeAllEditors } from './testUtils';
10
import { reflectCssValue as reflectCssValueImpl } from '../reflectCssValue';
11
12
function reflectCssValue(): Thenable<boolean> {
13
const result = reflectCssValueImpl();
14
assert.ok(result);
15
return result!;
16
}
17
18
suite('Tests for Emmet: Reflect CSS Value command', () => {
19
teardown(closeAllEditors);
20
21
const cssContents = `
22
.header {
23
margin: 10px;
24
padding: 10px;
25
transform: rotate(50deg);
26
-moz-transform: rotate(20deg);
27
-o-transform: rotate(50deg);
28
-webkit-transform: rotate(50deg);
29
-ms-transform: rotate(50deg);
30
}
31
`;
32
33
const htmlContents = `
34
<html>
35
<style>
36
.header {
37
margin: 10px;
38
padding: 10px;
39
transform: rotate(50deg);
40
-moz-transform: rotate(20deg);
41
-o-transform: rotate(50deg);
42
-webkit-transform: rotate(50deg);
43
-ms-transform: rotate(50deg);
44
}
45
</style>
46
</html>
47
`;
48
49
test('Reflect Css Value in css file', function (): any {
50
return withRandomFileEditor(cssContents, '.css', (editor, doc) => {
51
editor.selections = [new Selection(5, 10, 5, 10)];
52
return reflectCssValue().then(() => {
53
assert.strictEqual(doc.getText(), cssContents.replace(/\(50deg\)/g, '(20deg)'));
54
return Promise.resolve();
55
});
56
});
57
});
58
59
test('Reflect Css Value in css file, selecting entire property', function (): any {
60
return withRandomFileEditor(cssContents, '.css', (editor, doc) => {
61
editor.selections = [new Selection(5, 2, 5, 32)];
62
return reflectCssValue().then(() => {
63
assert.strictEqual(doc.getText(), cssContents.replace(/\(50deg\)/g, '(20deg)'));
64
return Promise.resolve();
65
});
66
});
67
});
68
69
test('Reflect Css Value in html file', function (): any {
70
return withRandomFileEditor(htmlContents, '.html', (editor, doc) => {
71
editor.selections = [new Selection(7, 20, 7, 20)];
72
return reflectCssValue().then(() => {
73
assert.strictEqual(doc.getText(), htmlContents.replace(/\(50deg\)/g, '(20deg)'));
74
return Promise.resolve();
75
});
76
});
77
});
78
79
test('Reflect Css Value in html file, selecting entire property', function (): any {
80
return withRandomFileEditor(htmlContents, '.html', (editor, doc) => {
81
editor.selections = [new Selection(7, 4, 7, 34)];
82
return reflectCssValue().then(() => {
83
assert.strictEqual(doc.getText(), htmlContents.replace(/\(50deg\)/g, '(20deg)'));
84
return Promise.resolve();
85
});
86
});
87
});
88
89
});
90
91