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